Browse Source

Show All button works now

master
Cristina Cochior 4 years ago
parent
commit
5f21bdec74
  1. 75
      templates/layout.html

75
templates/layout.html

@ -6,9 +6,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>Library</title> <title>Library</title>
<link rel="stylesheet" href="{{ url_for('static', filename='css/main.css') }}"> <link rel="stylesheet" href="{{ url_for('static', filename='css/main.css') }}">
<!--TEST-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.3/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.3/jquery.min.js"></script>
<script src="{{ url_for('static', filename='js/highlight.js') }}"></script> <script src="{{ url_for('static', filename='js/highlight.js') }}"></script>
@ -74,7 +71,9 @@
location.href = address; location.href = address;
}; };
}); });
/////DISPLAY FILES/////////////
/////DISPLAY FILENAMES/////////////
$(".file-names").click(function(event){ $(".file-names").click(function(event){
// alert(listofselecteddocs); // alert(listofselecteddocs);
@ -86,14 +85,11 @@
// iterate in test[i].librarian to find where the name is present // iterate in test[i].librarian to find where the name is present
//to get the test[i].debris that goes with it //to get the test[i].debris that goes with it
var allpeeps = [];
var category = null; var category = null;
for (var i = 0; i < test.length; ++i) { for (var i = 0; i < test.length; ++i) {
var item = test[i]; var item = test[i];
if(item.debrisname.includes(thefile)){ if(item.debrisname.includes(thefile)){
ledocument = item.debrispath; ledocument = item.debrispath;
// allpeeps.push(ledocument);
var extension = ledocument.replace(/^.*\./, ''); var extension = ledocument.replace(/^.*\./, '');
// var classname = ledocument.substring(ledocument.lastIndexOf('/')+1); // var classname = ledocument.substring(ledocument.lastIndexOf('/')+1);
// classname = classname.substr(0, classname.lastIndexOf('.')) || classname; // classname = classname.substr(0, classname.lastIndexOf('.')) || classname;
@ -101,6 +97,7 @@
console.log(ledocument); console.log(ledocument);
// check or unchecked checkbox if classname in array // check or unchecked checkbox if classname in array
var checkboite; var checkboite;
if(jQuery.inArray(classname, listofselecteddocs) != -1) { if(jQuery.inArray(classname, listofselecteddocs) != -1) {
console.log("is in array"); console.log("is in array");
@ -136,6 +133,69 @@
}); });
}); });
////DISPLAY FILES/////////////
var flag = true;
$("#showall").click(function(event){
if (flag === true) {
$('.file-names-container span').each(function () {
var current = $(this).attr('id');
$.getJSON('{{ url_for('static', filename='js/mergedjson.json') }}', function(test) {
var category = null;
for (var i = 0; i < test.length; ++i) {
var item = test[i];
if(item.debrisname.includes(current)){
actualdocument = item.debrispath;
var extension = actualdocument.replace(/^.*\./, '');
var classname = actualdocument;
// check or unchecked checkbox if classname in array
var checkboite;
if(jQuery.inArray(classname, listofselecteddocs) != -1) {
console.log("is in array");
checkboite = "<br /><input type='checkbox' class='addtoprint' id='"+classname+"' name='"+classname+"' value='print' checked><label for='"+classname+"'> Add to print</label>";
} else {
checkboite = "<br /><input type='checkbox' class='addtoprint' id='"+classname+"' name='"+classname+"' value='print'><label for='"+classname+"'> Add to print</label>";
}
if ((extension=="jpg") || (extension=="jpeg") || (extension=="png") || (extension=="gif") || (extension=="tiff")) {
$(".name-elements").append("<li><img class='listed-images' src='/files/"+actualdocument+"'>"+checkboite+"</li>");
}
else if (extension=="pdf") {
$(".name-elements").append("<li><object class='listed-pdf' data='files/"+actualdocument+"'/>"+checkboite+"</li>");
}
else if (extension=="epub") {
$(".name-elements").append("<li>"+actualdocument+"</li>");
}
else if ((extension=="mp3") || (extension=="wav") || (extension=="m4a")) {
$(".name-elements").append("<li><audio class='listed-audio' controls><source src='files/"+actualdocument+"'></audio>"+checkboite+"</li>");
}
else if ((extension=="mov") || (extension=="mp4")) {
$(".name-elements").append("<li><video class='listed-videos' controls><source src='files/"+actualdocument+"'></video>"+checkboite+"</li>");
}
else if ((extension=="odt") || (extension=="docx")) {
// something for odt and docx
$(".name-elements").append("<li>"+actualdocument+"</li>");
};
};
category = item.method;
};
});
});
flag = false;
} else {
$(".name-elements").empty();
flag = true;
};
});
///////////CHECKBOXES//////////////// ///////////CHECKBOXES////////////////
var listofselecteddocs = []; var listofselecteddocs = [];
@ -239,7 +299,6 @@ $.ajax({
</div> </div>
<div class="main-column-right"> <div class="main-column-right">
<!--<a href="{{ url_for('static', filename='realjson.json') }}">test link</a>-->
<ul class="name-elements"> <ul class="name-elements">
</ul> </ul>

Loading…
Cancel
Save