Commit 6305d8c9 authored by Joe TS Dell's avatar Joe TS Dell
Browse files

Merge branch 'master' of https://transfer.hft-stuttgart.de/gitlab/ugl/website into master

parents ab122067 b4d9db61
...@@ -4,182 +4,171 @@ ...@@ -4,182 +4,171 @@
var jsonContent = []; var jsonContent = [];
var bibAuthors = ""; var bibAuthors = "";
var bit1stAuthorLN = ""; var bit1stAuthorLN ="";
var url = "./content/CitationSheet3.xlsx";
/* set up XMLHttpRequest */
var url = "./content/CitationSheet_June.xlsx";
var xmlHttpRequest = new XMLHttpRequest(); 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"
});
var load_excel_citation = function (cb) { // DO SOMETHING WITH workbook HERE //
xmlHttpRequest.open("GET", url, true); var first_sheet_name = workbook.SheetNames[0];
xmlHttpRequest.responseType = "arraybuffer"; // Get worksheet //
xmlHttpRequest.onload = function (e) { var worksheet = workbook.Sheets[first_sheet_name];
var arraybuffer = xmlHttpRequest.response;
var jsonOutput = XLSX.utils.sheet_to_json(worksheet);
// convert data to binary string // // console.log(jsonOutput);
var data = new Uint8Array(arraybuffer);
var arr = new Array(); for (i = 0; i < jsonOutput.length; i++) {
for (var i = 0; i != data.length; ++i) arr[i] = String.fromCharCode(data[i]); var authors;
var bstr = arr.join(""); if (jsonOutput[i].Authors != undefined){
authors = jsonOutput[i].Authors.replace("and ", "").trim().split(",");
// Call XLSX // }
var workbook = XLSX.read(bstr, { var bibAuthors;
type: "binary" var item = {
}); "item": {
"title": "",
// DO SOMETHING WITH workbook HERE // "project": "",
var first_sheet_name = workbook.SheetNames[0]; "authors": [],
// Get worksheet // "imageLink": "",
var worksheet = workbook.Sheets[first_sheet_name]; "keywords": "",
"journal": {
var jsonOutput = XLSX.utils.sheet_to_json(worksheet); "name": "journal",
// console.log(jsonOutput); "volume": "",
"year": "",
for (i = 0; i < jsonOutput.length; i++) { "pages": ""
var authors;
if (jsonOutput[i].Authors != undefined) {
authors = jsonOutput[i].Authors.replace("and ", "").trim().split(",");
}
var bibAuthors;
var item = {
"item": {
"title": "",
"project": "",
"authors": [],
"imageLink": "",
"keywords": "",
"journal": {
"name": "journal",
"volume": "",
"year": "",
"pages": ""
},
"conference": {
"name": "",
"place": "",
"date": ""
},
"DOI": "",
"publisher": "",
"type": "",
"project": "",
"reviewed": "",
"open": ""
}, },
"links": { "conference":{
"pdf": "", "name":"",
"url": "", "place":"",
"demo": "" "date":""
}, },
"bibtex": "" "DOI": "",
} "publisher":"",
"type":"",
"project":"",
bibAuthors = ""; "reviewed":"",
bit1stAuthorLN = ""; "open":""
for (j = 0; j < authors.length; j++) {
var author = { },
"firstName": "", "links": {
"lastName": "" "pdf": "",
} "url": "",
if (authors[j].trim().split(" ").length == 1) { "demo": ""
author["firstName"] = authors[j].trim().split(".")[0]; },
author["lastName"] = authors[j].trim().split(".")[1]; "bibtex" : ""
item["item"].authors.push(author); }
bibAuthors += authors[j].trim().split(".")[1] + ", " + authors[j].trim().split(".")[0] + " and ";
} else if (authors[j].trim().split(" ").length == 2) {
author["firstName"] = authors[j].trim().split(" ")[0]; bibAuthors = "";
author["lastName"] = authors[j].trim().split(" ")[1]; bit1stAuthorLN ="";
item["item"].authors.push(author); for (j = 0; j < authors.length; j++) {
bibAuthors += authors[j].trim().split(" ")[1] + ", " + authors[j].trim().split(" ")[0] + " and "; var author = {
} else if (authors[j].trim().split(" ").length == 3) { "firstName": "",
author["firstName"] = authors[j].trim().split(" ")[0]; "lastName": ""
author["lastName"] = authors[j].trim().split(" ")[2];
item["item"].authors.push(author);
bibAuthors += authors[j].trim().split(" ")[2] + ", " + authors[j].trim().split(" ")[0] + " and ";
}
}
if (jsonOutput[i].Keywords != undefined) {
item["item"].keywords = jsonOutput[i].Keywords.split(",");
} else {
item["item"].keywords = jsonOutput[i].Keywords;
}
if (authors[0].split(" ").length == 3) {
bit1stAuthorLN = authors[0].split(" ")[2];
} else if (authors[0].split(" ").length == 2) {
bit1stAuthorLN = authors[0].split(" ")[1];
} else if (authors[0].split(" ").length == 1) {
bit1stAuthorLN = authors[0].split(" ")[0];
}
item["item"].title = jsonOutput[i].Titel;
item["item"].project = jsonOutput[i].Project;
item["item"].imageLink = jsonOutput[i]["Path to demo image"]
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"].conference.name = jsonOutput[i].Conference;
item["item"].conference.place = jsonOutput[i]["City and Country"]
item["item"].conference.date = jsonOutput[i].Date;
item["item"].publisher = jsonOutput[i].Publisher;
item["item"].type = jsonOutput[i]["Type of Work"];
item["item"].project = jsonOutput[i].Project;
item["item"].reviewed = jsonOutput[i]["Peer-Reviewed"];
item["item"].open = jsonOutput[i]["Open Access"];
item["item"].DOI = jsonOutput[i].DOI;
item["links"].pdf = jsonOutput[i].PDF_Link;
item["links"].url = jsonOutput[i].URL;
item["links"].demo = jsonOutput[i].Demo;
var month = "";
if (jsonOutput[i].Date != undefined) {
month = jsonOutput[i].Date.split(",")[0].trim();
} }
if (authors[j].trim().split(" ").length == 1) {
author["firstName"] = authors[j].trim().split(".")[0];
//// BibTex ///////////////////// author["lastName"] = authors[j].trim().split(".")[1];
item["bibtex"] = "@article{" + bit1stAuthorLN + jsonOutput[i].Year + "," + item["item"].authors.push(author);
"title={" + jsonOutput[i].Titel + bibAuthors+=authors[j].trim().split(".")[1] + ", "+ authors[j].trim().split(".")[0]+ " and ";
"},author={" + bibAuthors.trim().substring(0, bibAuthors.trim().lastIndexOf(" ")) + } else if (authors[j].trim().split(" ").length == 2) {
"},journal={" + jsonOutput[i].Journal + author["firstName"] = authors[j].trim().split(" ")[0];
"},volume={" + jsonOutput[i].Volume + author["lastName"] = authors[j].trim().split(" ")[1];
"},month={" + month + item["item"].authors.push(author);
"},pages={" + jsonOutput[i].Pages + bibAuthors+=authors[j].trim().split(" ")[1] + ", "+ authors[j].trim().split(" ")[0]+ " and ";
"},year={" + jsonOutput[i].Year + } else if (authors[j].trim().split(" ").length == 3) {
"},DOI ={" + jsonOutput[i].DOI + author["firstName"] = authors[j].trim().split(" ")[0];
"},url ={" + jsonOutput[i].URL + author["lastName"] = authors[j].trim().split(" ")[2];
"}}" item["item"].authors.push(author);
bibAuthors+=authors[j].trim().split(" ")[2] + ", "+ authors[j].trim().split(" ")[0]+ " and ";
jsonContent.push(item);
if (i == jsonOutput.length - 1) {
cb() // callback
} }
} }
// console.log(jsonContent);
if (jsonOutput[i].Keywords != undefined) {
} item["item"].keywords = jsonOutput[i].Keywords.split(",");
xmlHttpRequest.send(); } else {
item["item"].keywords = jsonOutput[i].Keywords;
} }
if (authors[0].split(" ").length == 3 ){
bit1stAuthorLN = authors[0].split(" ")[2];
} else if (authors[0].split(" ").length == 2 ){
bit1stAuthorLN = authors[0].split(" ")[1];
} else if (authors[0].split(" ").length == 1 ){
bit1stAuthorLN = authors[0].split(" ")[0];
}
item["item"].title = jsonOutput[i].Titel;
item["item"].project = jsonOutput[i].Project;
item["item"].imageLink = jsonOutput[i]["Path to demo image"]
item["item"].journal.name = jsonOutput[i].Journal;
item["item"].journal.volume = jsonOutput[i].Volume;
item["item"].journal.year = jsonOutput[i].Year;
// get paper from the Sabo result item["item"].journal.pages = jsonOutput[i].Pages;
load_excel_citation(function () { item["item"].conference.name = jsonOutput[i].Conference;
stuff_paper = jsonContent; item["item"].conference.place = jsonOutput[i]["City and Country"]
var new_row = document.getElementById("cont_paper") item["item"].conference.date = jsonOutput[i].Date;
new_row.innerHTML = ""; item["item"].publisher = jsonOutput[i].Publisher;
var arrayLength = stuff_paper.length; item["item"].type = jsonOutput[i]["Type of Work"];
for (var i = 0; i < arrayLength; i++) { item["item"].project = jsonOutput[i].Project;
item["item"].reviewed = jsonOutput[i]["Peer-Reviewed"];
item["item"].open = jsonOutput[i]["Open Access"];
item["item"].DOI = jsonOutput[i].DOI;
item["links"].pdf = jsonOutput[i].PDF_Link;
item["links"].url = jsonOutput[i].URL;
item["links"].demo = jsonOutput[i].Demo;
if (i < max_paper_list && i <= arrayLength) {
addpaper(stuff_paper[i]); var month = "";
if (jsonOutput[i].Date != undefined){
month = jsonOutput[i].Date.toString().split(",")[0].trim();
} }
//Do something
//// BibTex /////////////////////
item["bibtex"] = "@article{"+ bit1stAuthorLN + jsonOutput[i].Year +","+
"title={"+ jsonOutput[i].Titel +
"},author={"+ bibAuthors.trim().substring(0, bibAuthors.trim().lastIndexOf(" ")) +
"},journal={"+ jsonOutput[i].Journal +
"},volume={"+ jsonOutput[i].Volume +
"},month={"+ month +
"},pages={"+ jsonOutput[i].Pages +
"},year={"+ jsonOutput[i].Year +
"},DOI ={"+ jsonOutput[i].DOI+
"},url ={"+ jsonOutput[i].URL+
"}}"
jsonContent.push(item);
} }
}) //console.log(jsonContent);
\ No newline at end of file
}
xmlHttpRequest.send();
// str = str.substring(0, lastIndex);
//
// ending of xlsx to json coversion
//
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