Improvement to filter, you can now see what you have selected

This commit is contained in:
crunk 2020-12-30 00:06:45 +01:00
parent c595ce8658
commit 11b80eb5da
7 changed files with 75 additions and 57 deletions

View File

@ -26,9 +26,9 @@ def getpublications():
pubinfo = { pubinfo = {
"Title": row["Publication"], "Title": row["Publication"],
"Author": row["Author"], "Author": row["Author"],
"Type": row["Type"].lower(), "Type": row["Type"].lower().title(),
"Year": year, "Year": year,
"License": row["LicenseShort"].lower(), "License": row["LicenseShort"].lower().title(),
} }
publications[row["Id"]] = pubinfo publications[row["Id"]] = pubinfo
return publications return publications
@ -40,7 +40,7 @@ def gettypes():
csv_as_dict = csv.DictReader(libcsv) csv_as_dict = csv.DictReader(libcsv)
listoftypes = [] listoftypes = []
for row in csv_as_dict: for row in csv_as_dict:
lowertype = row["Type"].lower() lowertype = row["Type"].lower().title()
if lowertype not in listoftypes: if lowertype not in listoftypes:
listoftypes.append(lowertype) listoftypes.append(lowertype)
return listoftypes return listoftypes
@ -67,9 +67,9 @@ def getlicenses():
csv_as_dict = csv.DictReader(libcsv) csv_as_dict = csv.DictReader(libcsv)
listoflicenses = [] listoflicenses = []
for row in csv_as_dict: for row in csv_as_dict:
license = row["LicenseShort"].lower() license = row["LicenseShort"].lower().title()
if not license: if not license:
license = "no license mentioned" license = "No License Mentioned"
if license not in listoflicenses: if license not in listoflicenses:
listoflicenses.append(license) listoflicenses.append(license)
return listoflicenses return listoflicenses

View File

@ -27,7 +27,7 @@ Id,Publication,Author,Year,Custodian,Fields,Type,Publishers,License,LicenseShort
33,"The immaterial labor union #7: immersive advertisement","Lídia Pereira and Δεριζαματζορ Προμπλεμ ιναυστραλια",,Varia,"labour, Advertisement, immersion, social media",Zine,Self-published,"Zine is published under Gnu free documentation license 1.3 unless otherwise specified ","GNU Free Documentation License",,, 33,"The immaterial labor union #7: immersive advertisement","Lídia Pereira and Δεριζαματζορ Προμπλεμ ιναυστραλια",,Varia,"labour, Advertisement, immersion, social media",Zine,Self-published,"Zine is published under Gnu free documentation license 1.3 unless otherwise specified ","GNU Free Documentation License",,,
34,"The immateriality labor union #10: immateriality","Lídia Pereira and Δεριζαματζορ Προμπλεμ ιναυστραλια",2017,Varia,"Labour, Immateriality",Zine,Self-published,"GNU Free Documentation License","GNU Free Documentation License",,, 34,"The immateriality labor union #10: immateriality","Lídia Pereira and Δεριζαματζορ Προμπλεμ ιναυστραλια",2017,Varia,"Labour, Immateriality",Zine,Self-published,"GNU Free Documentation License","GNU Free Documentation License",,,
35,"The immaterial labor union. Special Issue #1: Homebrew Server Club","Homebrew Server Club",2017,Varia,"Self-Hosting, Servers, DIY",Zine,Self-published,CC-BY-SA,"Creative commons",,, 35,"The immaterial labor union. Special Issue #1: Homebrew Server Club","Homebrew Server Club",2017,Varia,"Self-Hosting, Servers, DIY",Zine,Self-published,CC-BY-SA,"Creative commons",,,
36,"Pervasive labour union. Special issue #2: The Entreprecariat","Silvio Lorusso",2017,Varia,"Entreprecariat, Labour, Precarity",Zine,Self-published,,,,"Between April and May 2017 the Zine's name changed from Immaterial Labor Union to Pervasive Labour Union", 36,"Pervasive labour union. Special issue #2: The Entreprecariat","Silvio Lorusso",2017,Varia,"Entreprecariat, Labour, Precarity",Zine,Self-published,"No license mentioned","No license mentioned",,"Between April and May 2017 the Zine's name changed from Immaterial Labor Union to Pervasive Labour Union",
37,"'Pervasive labour union #13: Fed Up","Lídia Pereira",2019,Varia,"Labour, DIY, federation",Zine,Self-published,"GNU Free Documentation License 1.3, CC-0, Copyright (C) 2019, Julia Janssen, Peer Production License","GNU Free Documentation License",,, 37,"'Pervasive labour union #13: Fed Up","Lídia Pereira",2019,Varia,"Labour, DIY, federation",Zine,Self-published,"GNU Free Documentation License 1.3, CC-0, Copyright (C) 2019, Julia Janssen, Peer Production License","GNU Free Documentation License",,,
38,"Each Page a Function","Raphaël Bastide",2019,Varia,"Automation, Drawing, Web to Print",Paperback,"LeMegot editions","No license mentioned","No license mentioned",,, 38,"Each Page a Function","Raphaël Bastide",2019,Varia,"Automation, Drawing, Web to Print",Paperback,"LeMegot editions","No license mentioned","No license mentioned",,,
39,"In Beweging: Magazine van de Anarchistische Groep Nijmegen","Anarchistische Groep Nijmegen ",2018,Varia,"Anarchism, 1st of May, Nijmegen",Zine,Self-published,"No license mentioned","No license mentioned",,"Anarchistische Bieb de Zwarte Uil. library in Nijmegen open on saturday from 12:00 till 17:30", 39,"In Beweging: Magazine van de Anarchistische Groep Nijmegen","Anarchistische Groep Nijmegen ",2018,Varia,"Anarchism, 1st of May, Nijmegen",Zine,Self-published,"No license mentioned","No license mentioned",,"Anarchistische Bieb de Zwarte Uil. library in Nijmegen open on saturday from 12:00 till 17:30",

1 Id Publication Author Year Custodian Fields Type Publishers License LicenseShort Highlights Comments Currently borrowed by
27 34 The immateriality labor union #10: immateriality Lídia Pereira and Δεριζαματζορ Προμπλεμ ιναυστραλια 2017 Varia Labour, Immateriality Zine Self-published GNU Free Documentation License GNU Free Documentation License
28 35 The immaterial labor union. Special Issue #1: Homebrew Server Club Homebrew Server Club 2017 Varia Self-Hosting, Servers, DIY Zine Self-published CC-BY-SA Creative commons
29 36 Pervasive labour union. Special issue #2: The Entreprecariat Silvio Lorusso 2017 Varia Entreprecariat, Labour, Precarity Zine Self-published No license mentioned No license mentioned Between April and May 2017 the Zine's name changed from Immaterial Labor Union to Pervasive Labour Union
30 37 'Pervasive labour union #13: Fed Up Lídia Pereira 2019 Varia Labour, DIY, federation Zine Self-published GNU Free Documentation License 1.3, CC-0, Copyright (C) 2019, Julia Janssen, Peer Production License GNU Free Documentation License
31 38 Each Page a Function Raphaël Bastide 2019 Varia Automation, Drawing, Web to Print Paperback LeMegot editions No license mentioned No license mentioned
32 39 In Beweging: Magazine van de Anarchistische Groep Nijmegen Anarchistische Groep Nijmegen 2018 Varia Anarchism, 1st of May, Nijmegen Zine Self-published No license mentioned No license mentioned Anarchistische Bieb de Zwarte Uil. library in Nijmegen open on saturday from 12:00 till 17:30
33 40 Deep pockets #2 Shadowbook: Writing throiugh the digital 2014-2018 Miriam Rasch 2018 Varia Language, digital, communication Paperback Institute of Network Cultures CC BY-NC-SA 4.0 Creative Commons

View File

@ -1,12 +1,14 @@
/* Dropdown Button */ /* Dropdown Button */
/* for sorting on Year, Type, License /* for sorting on Year, Type, License
.dropbtn { */
}
/* The container <div> - needed to position the dropdown content */
.filter { .filter {
display: none; display: none;
} }
.activebtn {
background-color: #62b264;
}
.show { .show {
display: block; display: block;
} }

View File

@ -0,0 +1,56 @@
// Filter section ===================== old school code divider ================
filterSelection("all", "None");
function filterSelection(c, id) {
resetDropDownButtons();
var i;
var button = document.getElementById(id);
if(button){
button.innerText = c;
addClass(button, "activebtn");
}
var allpublications = document.getElementsByClassName("filter");
if (c == "all") {
for (i = 0; i < allpublications.length; i++) {
addClass(allpublications[i], "show");
}
}
else {
for (i = 0; i < allpublications.length; i++) {
removeClass(allpublications[i], "show");
if (allpublications[i].className.indexOf(c) > -1) {
addClass(allpublications[i], "show");
}
}
}
}
function resetDropDownButtons(){
document.getElementById("License").innerText = "License";
document.getElementById("PubType").innerText = "Type";
document.getElementById("Year").innerText = "Year";
allactivebuttons = document.getElementsByClassName("activebtn");
for(var i = 0;allactivebuttons.length; i++) {
removeClass(allactivebuttons[i], "activebtn");
}
}
function addClass(element, name) {
var i, arr1, arr2;
arr1 = element.className.split(" ");
arr2 = name.split(" ");
for (i = 0; i < arr2.length; i++) {
if (arr1.indexOf(arr2[i]) == -1) {element.className += " " + arr2[i];}
}
}
function removeClass(element, name) {
var i, arr1, arr2;
arr1 = element.className.split(" ");
arr2 = name.split(" ");
for (i = 0; i < arr2.length; i++) {
while (arr1.indexOf(arr2[i]) > -1) {
arr1.splice(arr1.indexOf(arr2[i]), 1);
}
}
element.className = arr1.join(" ");
}

View File

@ -23,45 +23,5 @@ const cloud = document.querySelector('#cloud');
function update() { function update() {
cloud.style.boxShadow = boxShadows(30); cloud.style.boxShadow = boxShadows(30);
} }
// Filter section ===================== old school code divider ================
filterSelection("all")
function filterSelection(c) {
var i;
var allpublications = document.getElementsByClassName("filter");
if (c == "all") {
for (i = 0; i < allpublications.length; i++) {
addClass(allpublications[i], "show");
}
}
else {
for (i = 0; i < allpublications.length; i++) {
removeClass(allpublications[i], "show");
if (allpublications[i].className.indexOf(c) > -1) {
addClass(allpublications[i], "show");
}
}
}
}
function addClass(element, name) {
var i, arr1, arr2;
arr1 = element.className.split(" ");
arr2 = name.split(" ");
for (i = 0; i < arr2.length; i++) {
if (arr1.indexOf(arr2[i]) == -1) {element.className += " " + arr2[i];}
}
}
function removeClass(element, name) {
var i, arr1, arr2;
arr1 = element.className.split(" ");
arr2 = name.split(" ");
for (i = 0; i < arr2.length; i++) {
while (arr1.indexOf(arr2[i]) > -1) {
arr1.splice(arr1.indexOf(arr2[i]), 1);
}
}
element.className = arr1.join(" ");
}
window.addEventListener('load', update); window.addEventListener('load', update);

View File

@ -11,5 +11,5 @@
{% endfor%} {% endfor%}
</ul> </ul>
</div> </div>
<script src="{{ url_for('static', filename='js/dropdown.js')}}"></script>
{% endblock %} {% endblock %}

View File

@ -2,26 +2,26 @@
<button id="leftmostbtn" onclick="filterSelection('all')">All books</button> <button id="leftmostbtn" onclick="filterSelection('all')">All books</button>
<button><a href="/upload">Upload</a></button> <button><a href="/upload">Upload</a></button>
<div class="dropdown"> <div class="dropdown">
<button class="dropbtn">Type</button> <button id="PubType" class="dropbtn">Type</button>
<div class="dropdown-content"> <div class="dropdown-content">
{% for pubtype in pubtypes %} {% for pubtype in pubtypes %}
<button type="button" name="button" onclick="filterSelection('{{ pubtype }}')" >{{ pubtype.title() }}</button> <button type="button" name="button" onclick="filterSelection('{{ pubtype }}', 'PubType')" >{{ pubtype.title() }}</button>
{% endfor %} {% endfor %}
</div> </div>
</div> </div>
<div class="dropdown"> <div class="dropdown">
<button class="dropbtn">Year</button> <button id="Year" class="dropbtn">Year</button>
<div class="dropdown-content"> <div class="dropdown-content">
{% for pubyear in pubyears %} {% for pubyear in pubyears %}
<button type="button" name="button" onclick="filterSelection('{{ pubyear }}')" >{{ pubyear }}</button> <button type="button" name="button" onclick="filterSelection('{{ pubyear }}', 'Year')" >{{ pubyear }}</button>
{% endfor %} {% endfor %}
</div> </div>
</div> </div>
<div class="dropdown"> <div class="dropdown">
<button class="dropbtn">License</button> <button id="License" class="dropbtn">License</button>
<div class="dropdown-content"> <div class="dropdown-content">
{% for publicense in publicenses %} {% for publicense in publicenses %}
<button type="button" name="button" onclick="filterSelection('{{ publicense }}')" >{{ publicense }}</button> <button type="button" name="button" onclick="filterSelection('{{ publicense }}', 'License')" >{{ publicense }}</button>
{% endfor %} {% endfor %}
</div> </div>
</div> </div>