Commit 89198a80 authored by Joe TS Dell's avatar Joe TS Dell
Browse files

update

parent 476f9667
...@@ -404,24 +404,22 @@ ...@@ -404,24 +404,22 @@
<!-- /////////////////////////////////////// --> <!-- /////////////////////////////////////// -->
<!-- Language selector --> <!-- Language selector -->
<!-- full jquery needed --> <!-- full jquery needed -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script> <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.6.2/js/bootstrap-select.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.6.2/js/bootstrap-select.min.js"></script>
<script src="./js/popper.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/0.8.2/css/flag-icon.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/0.8.2/css/flag-icon.min.css">
<script src="js/config.js"></script>
<script src="js/citationSheetParse.js"></script>
<script src="js/language.js"></script> <script src="js/language.js"></script>
<script src="js/add_content.js"></script> <script src="js/add_content.js"></script>
<script src="js/add_paper.js"></script> <script src="js/add_paper.js"></script>
<script src="js/config.js"></script>
<!-- search library --> <!-- search library -->
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/fuse.js/dist/fuse.js"></script> <script src="https://cdn.jsdelivr.net/npm/fuse.js/dist/fuse.js"></script>
<link rel="stylesheet" href="./css/search.css"> <link rel="stylesheet" href="./css/search.css">
<link rel="stylesheet" href="./css/language.css"> <link rel="stylesheet" href="./css/language.css">
<script src="js/search.js"></script> <script src="js/search.js"></script>
<!-- KEINE ÄNDERUNGEN NACH DIESER ZEILE -->
<!-- <script src="settings.js"> </script> -->
<!-- <script src="./js/jquery.slim.min.js"></script> -->
<script src="./js/popper.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body> </body>
......
...@@ -13,7 +13,7 @@ function addpaper(item) { ...@@ -13,7 +13,7 @@ function addpaper(item) {
} }
var keywords = ""; var keywords = "";
// check if there is keywords in item // check if there is keywords in item
if ("keywords" in item.item) { if (item.item.keywords !== undefined) {
for (var i = 0; i < item.item.keywords.length; i++) { for (var i = 0; i < item.item.keywords.length; i++) {
console.log(i); console.log(i);
keywords += '<span class="badge badge-pill badge-light">' + item.item.keywords[i] + '</span>' keywords += '<span class="badge badge-pill badge-light">' + item.item.keywords[i] + '</span>'
......
//
// begining of xlsx to json coversion
//
var jsonContent = [];
/* set up XMLHttpRequest */
var url = "./content/CitationSheet.xlsx";
var xmlHttpRequest = new XMLHttpRequest();
xmlHttpRequest.open("GET", url, true);
xmlHttpRequest.responseType = "arraybuffer";
xmlHttpRequest.onload = function (e) {
var arraybuffer = xmlHttpRequest.response;
// convert data to binary string //
var data = new Uint8Array(arraybuffer);
var arr = new Array();
for (var i = 0; i != data.length; ++i) arr[i] = String.fromCharCode(data[i]);
var bstr = arr.join("");
// Call XLSX //
var workbook = XLSX.read(bstr, {
type: "binary"
});
// DO SOMETHING WITH workbook HERE //
var first_sheet_name = workbook.SheetNames[0];
// Get worksheet //
var worksheet = workbook.Sheets[first_sheet_name];
var jsonOutput = XLSX.utils.sheet_to_json(worksheet);
for (i = 0; i < jsonOutput.length; i++) {
var item = {
"item": {
"title": "",
"project": "",
"authors": [],
"imageLink": "",
"keywords": "",
"journal": {
"name": "journal",
"volume": "",
"year": "",
"pages": ""
},
"DOI": ""
},
"links": {
"pdf": "",
"url": "",
"demo": ""
}
}
var authors = jsonOutput[i].Authors.replace("and ", "").trim().split(",");
item["item"].title = jsonOutput[i].Titel;
item["item"].project = jsonOutput[i].Project;
for (j = 0; j < authors.length; j++) {
var author = {
"firstName": "",
"lastName": ""
}
if (authors[j].trim().split(" ").length == 1) {
author["firstName"] = authors[j].trim().split(".")[0];
author["lastName"] = authors[j].trim().split(".")[1];
item["item"].authors.push(author);
} else if (authors[j].trim().split(" ").length == 2) {
author["firstName"] = authors[j].trim().split(" ")[0];
author["lastName"] = authors[j].trim().split(" ")[1];
item["item"].authors.push(author);
} else if (authors[j].trim().split(" ").length == 3) {
author["firstName"] = authors[j].trim().split(" ")[0];
author["lastName"] = authors[j].trim().split(" ")[2];
item["item"].authors.push(author);
}
}
item["item"].imageLink = jsonOutput[i]["Path to demo image"]
if (jsonOutput[i].Keywords != undefined) {
item["item"].keywords = jsonOutput[i].Keywords.split(",");
} else {
item["item"].keywords = jsonOutput[i].Keywords;
}
item["item"].journal.name = jsonOutput[i].Journal;
item["item"].journal.volume = jsonOutput[i].Volume;
item["item"].journal.year = jsonOutput[i].Year;
item["item"].journal.pages = jsonOutput[i].Pages;
item["item"].DOI = jsonOutput[i].DOI;
item["links"].pdf = jsonOutput[i].URL;
item["links"].url = jsonOutput[i].URL;
item["links"].demo = jsonOutput[i].URL;
jsonContent.push(item);
}
// console.log(jsonContent);
}
xmlHttpRequest.send();
//
// ending of xlsx to json coversion
//
...@@ -3,22 +3,25 @@ ...@@ -3,22 +3,25 @@
const options = { const options = {
includeScore: true, includeScore: true,
// Search in `author` and in `tags` array // Search in `author` and in `tags` array
keys: ["item.title","item.keywords", keys: ["item.title", "item.keywords",
"item.author.firstName", "item.author.lastName"] "item.author.firstName", "item.author.lastName"
]
} }
const options_paper = { const options_paper = {
includeScore: true, includeScore: true,
// Search in `author` and in `tags` array // Search in `author` and in `tags` array
keys: ["item.title","item.keywords", keys: ["item.title", "item.keywords",
"item.author.firstName", "item.author.lastName"] "item.author.firstName", "item.author.lastName"
]
} }
// start search // start search
var searchanswer var searchanswer
var searchanswer_paper var searchanswer_paper
function search(){
const fuse = new Fuse(stuff, options); function search() {
searchanswer = fuse.search(document.getElementById("search-input").value) const fuse = new Fuse(stuff, options);
searchanswer = fuse.search(document.getElementById("search-input").value)
var new_row = document.getElementById("row_main") var new_row = document.getElementById("row_main")
new_row.innerHTML = ""; new_row.innerHTML = "";
...@@ -30,9 +33,10 @@ function search(){ ...@@ -30,9 +33,10 @@ function search(){
// alert(searchanswer); // alert(searchanswer);
console.log(searchanswer); console.log(searchanswer);
} }
function search_paper(){
const fuse = new Fuse(stuff_paper, options); function search_paper() {
searchanswer_paper = fuse.search(document.getElementById("search-input_paper").value) const fuse = new Fuse(stuff_paper, options);
searchanswer_paper = fuse.search(document.getElementById("search-input_paper").value)
var new_row = document.getElementById("cont_paper") var new_row = document.getElementById("cont_paper")
new_row.innerHTML = ""; new_row.innerHTML = "";
...@@ -61,133 +65,55 @@ var stuff_paper = [] ...@@ -61,133 +65,55 @@ var stuff_paper = []
// }); // });
//
// begining of xlsx to json coversion
//
var jsonContent = [];
/* set up XMLHttpRequest */
var url = "./content/CitationSheet.xlsx";
var xmlHttpRequest = new XMLHttpRequest();
xmlHttpRequest.open("GET", url, true);
xmlHttpRequest.responseType = "arraybuffer";
xmlHttpRequest.onload = function(e) {
var arraybuffer = xmlHttpRequest.response;
// convert data to binary string //
var data = new Uint8Array(arraybuffer);
var arr = new Array();
for (var i = 0; i != data.length; ++i) arr[i] = String.fromCharCode(data[i]);
var bstr = arr.join("");
// Call XLSX //
var workbook = XLSX.read(bstr, {
type: "binary"
});
// DO SOMETHING WITH workbook HERE //
var first_sheet_name = workbook.SheetNames[0];
// Get worksheet //
var worksheet = workbook.Sheets[first_sheet_name];
var jsonOutput = XLSX.utils.sheet_to_json(worksheet);
for (i=0; i < jsonOutput.length; i++){
var item = {
"item": {"title": "",
"project": "",
"authors": [],
"imageLink":"",
"keywords":"",
"journal": {"name":"journal","volume":"","year":"","pages":""},
"DOI":""},
"links": {"pdf":"","url": "","demo": ""}
}
var authors = jsonOutput[i].Authors.replace("and " ,"").trim().split(",");
item["item"].title = jsonOutput[i].Titel;
item["item"].project = jsonOutput[i].Project;
for (j=0; j < authors.length; j++){
var author = {
"firstName": "",
"lastName": ""
}
if (authors[j].trim().split(" ").length == 1){
author["firstName"] = authors[j].trim().split(".")[0];
author["lastName"] = authors[j].trim().split(".")[1];
item["item"].authors.push(author);
}
else if (authors[j].trim().split(" ").length == 2){
author["firstName"] = authors[j].trim().split(" ")[0];
author["lastName"] = authors[j].trim().split(" ")[1];
item["item"].authors.push(author);
}
else if (authors[j].trim().split(" ").length == 3) {
author["firstName"] = authors[j].trim().split(" ")[0];
author["lastName"] = authors[j].trim().split(" ")[2];
item["item"].authors.push(author);
}
}
item["item"].imageLink = jsonOutput[i]["Path to demo image"]
if (jsonOutput[i].Keywords != undefined){
item["item"].keywords = jsonOutput[i].Keywords.split(",");
}
else {
item["item"].keywords = jsonOutput[i].Keywords;
}
item["item"].journal.name = jsonOutput[i].Journal;
item["item"].journal.volume = jsonOutput[i].Volume;
item["item"].journal.year = jsonOutput[i].Year;
item["item"].journal.pages = jsonOutput[i].Pages;
item["item"].DOI = jsonOutput[i].DOI;
item["links"].pdf = jsonOutput[i].URL;
item["links"].url = jsonOutput[i].URL;
item["links"].demo = jsonOutput[i].URL;
jsonContent.push(item);
}
console.log(jsonContent);
}
xmlHttpRequest.send();
//
// ending of xlsx to json coversion
//
$(document).ready(function () {
$.getJSON("./content/content.json", function (result) {
stuff = result;
var new_row = document.getElementById("row_main")
new_row.innerHTML = "";
var arrayLength = stuff.length;
for (var i = 0; i < arrayLength; i++) {
addcontent(stuff[i]);
//Do something
}
});
$(document).ready(function(){ // get paper content is commented out for back up
$.getJSON("./content/content.json", function(result){ // $.getJSON("./content/paper2.json", function (result) {
stuff = result; // stuff_paper = result;
var new_row = document.getElementById("row_main") // var new_row = document.getElementById("cont_paper")
// new_row.innerHTML = "";
// var arrayLength = stuff_paper.length;
// for (var i = 0; i < arrayLength; i++) {
// if (Math.abs(arrayLength - i) <= max_paper_list) {
// console.log("close to " + i)
// addpaper(stuff_paper[i]);
// }
// //Do something
// }
// });
// get paper from the Sabo result
stuff_paper = jsonContent;
var new_row = document.getElementById("cont_paper")
new_row.innerHTML = ""; new_row.innerHTML = "";
var arrayLength = stuff.length; var arrayLength = stuff_paper.length;
for (var i = 0; i < arrayLength; i++) { for (var i = 0; i < arrayLength; i++) {
addcontent(stuff[i]);
if (Math.abs(arrayLength - i) <= max_paper_list) {
console.log("close to " + i)
addpaper(stuff_paper[i]);
}
//Do something //Do something
} }
});
$.getJSON("./content/paper2.json", function(result){
stuff_paper = result;
var new_row = document.getElementById("cont_paper")
new_row.innerHTML = "";
var arrayLength = stuff_paper.length;
for (var i = 0; i < arrayLength; i++) {
if(Math.abs(arrayLength - i) <= max_paper_list){
console.log("close to " + i)
addpaper(stuff_paper[i]); var userLang = navigator.language || navigator.userLanguage;
}
//Do something
}
});
var userLang = navigator.language || navigator.userLanguage;
console.log("The language is: " + userLang); console.log("The language is: " + userLang);
if (userLang.includes("de")){ if (userLang.includes("de")) {
console.log(true) console.log(true)
var select1 = document.getElementById('selectpicker1'); var select1 = document.getElementById('selectpicker1');
console.log(select1) console.log(select1)
...@@ -204,78 +130,77 @@ $(document).ready(function(){ ...@@ -204,78 +130,77 @@ $(document).ready(function(){
// searchbar and start search // searchbar and start search
function searchToggle(obj, evt){ function searchToggle(obj, evt) {
console.log("arrive") console.log("arrive")
var container = $(obj).closest('.search-wrapper'); var container = $(obj).closest('.search-wrapper');
if(!container.hasClass('active')){ if (!container.hasClass('active')) {
container.addClass('active'); container.addClass('active');
evt.preventDefault(); evt.preventDefault();
console.log("first") console.log("first")
} } else if (container.hasClass('active') && $(obj).closest('.input-holder').length == 0) {
else if(container.hasClass('active') && $(obj).closest('.input-holder').length == 0){ container.removeClass('active');
container.removeClass('active'); // clear input
// clear input console.log("second")
console.log("second") var new_row = document.getElementById("row_main")
var new_row = document.getElementById("row_main") new_row.innerHTML = "";
new_row.innerHTML = ""; var arrayLength = stuff.length;
var arrayLength = stuff.length; for (var i = 0; i < arrayLength; i++) {
for (var i = 0; i < arrayLength; i++) { addcontent(stuff[i]);
addcontent(stuff[i]); //Do something
//Do something
}
container.find('.search-input').val('');
} else {
console.log("search")
search();
// addcontent();
} }
container.find('.search-input').val('');
} else {
console.log("search")
search();
// addcontent();
}
} }
function searchToggle_paper(obj, evt){
function searchToggle_paper(obj, evt) {
console.log("arrive") console.log("arrive")
var container = $(obj).closest('.search-wrapper'); var container = $(obj).closest('.search-wrapper');
if(!container.hasClass('active')){ if (!container.hasClass('active')) {
container.addClass('active'); container.addClass('active');
evt.preventDefault(); evt.preventDefault();
console.log("first") console.log("first")
} } else if (container.hasClass('active') && $(obj).closest('.input-holder').length == 0) {
else if(container.hasClass('active') && $(obj).closest('.input-holder').length == 0){ container.removeClass('active');
container.removeClass('active'); // clear input
// clear input console.log("second")
console.log("second") var new_row = document.getElementById("cont_paper")
var new_row = document.getElementById("cont_paper") new_row.innerHTML = "";
new_row.innerHTML = ""; var arrayLength = stuff_paper.length;
var arrayLength = stuff_paper.length; for (var i = 0; i < arrayLength; i++) {
for (var i = 0; i < arrayLength; i++) { if (Math.abs(arrayLength - i) <= 2) {
if(Math.abs(arrayLength - i) <= 2){ console.log("close to " + i)
console.log("close to " + i) addpaper(stuff_paper[i]);
addpaper(stuff_paper[i]);
}
//Do something
} }
container.find('#search-input_paper').val('');
} else { //Do something
console.log("search")
search_paper();
// addcontent();
} }
container.find('#search-input_paper').val('');
} else {
console.log("search")
search_paper();
// addcontent();
}
} }
// search on enter // search on enter
var input = document.getElementById("search-input"); var input = document.getElementById("search-input");
input.addEventListener("keyup", function(event) { input.addEventListener("keyup", function (event) {
if (event.keyCode === 13) { if (event.keyCode === 13) {
event.preventDefault(); event.preventDefault();
document.getElementById("search-button").click(); document.getElementById("search-button").click();
} }
}); });
var input = document.getElementById("search-input_paper"); var input = document.getElementById("search-input_paper");
input.addEventListener("keyup", function(event) { input.addEventListener("keyup", function (event) {
if (event.keyCode === 13) { if (event.keyCode === 13) {
event.preventDefault(); event.preventDefault();
document.getElementById("search-button_paper").click(); document.getElementById("search-button_paper").click();
} }
}); });
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment