Commit 94cdef2e authored by Sini's avatar Sini
Browse files

ExelSheet_June

parent d5ad0814
...@@ -4,16 +4,16 @@ ...@@ -4,16 +4,16 @@
var jsonContent = []; var jsonContent = [];
var bibAuthors = ""; var bibAuthors = "";
var bit1stAuthorLN = ""; var bit1stAuthorLN ="";
var url = "./content/CitationSheet3.xlsx";
var xmlHttpRequest = new XMLHttpRequest();
var load_excel_citation = function (cb) { /* set up XMLHttpRequest */
xmlHttpRequest.open("GET", url, true); var url = "./content/CitationSheet_June.xlsx";
xmlHttpRequest.responseType = "arraybuffer"; var xmlHttpRequest = new XMLHttpRequest();
xmlHttpRequest.onload = function (e) { xmlHttpRequest.open("GET", url, true);
xmlHttpRequest.responseType = "arraybuffer";
xmlHttpRequest.onload = function (e) {
var arraybuffer = xmlHttpRequest.response; var arraybuffer = xmlHttpRequest.response;
// convert data to binary string // // convert data to binary string //
...@@ -37,7 +37,7 @@ var load_excel_citation = function (cb) { ...@@ -37,7 +37,7 @@ var load_excel_citation = function (cb) {
for (i = 0; i < jsonOutput.length; i++) { for (i = 0; i < jsonOutput.length; i++) {
var authors; var authors;
if (jsonOutput[i].Authors != undefined) { if (jsonOutput[i].Authors != undefined){
authors = jsonOutput[i].Authors.replace("and ", "").trim().split(","); authors = jsonOutput[i].Authors.replace("and ", "").trim().split(",");
} }
var bibAuthors; var bibAuthors;
...@@ -54,17 +54,17 @@ var load_excel_citation = function (cb) { ...@@ -54,17 +54,17 @@ var load_excel_citation = function (cb) {
"year": "", "year": "",
"pages": "" "pages": ""
}, },
"conference": { "conference":{
"name": "", "name":"",
"place": "", "place":"",
"date": "" "date":""
}, },
"DOI": "", "DOI": "",
"publisher": "", "publisher":"",
"type": "", "type":"",
"project": "", "project":"",
"reviewed": "", "reviewed":"",
"open": "" "open":""
}, },
"links": { "links": {
...@@ -72,12 +72,12 @@ var load_excel_citation = function (cb) { ...@@ -72,12 +72,12 @@ var load_excel_citation = function (cb) {
"url": "", "url": "",
"demo": "" "demo": ""
}, },
"bibtex": "" "bibtex" : ""
} }
bibAuthors = ""; bibAuthors = "";
bit1stAuthorLN = ""; bit1stAuthorLN ="";
for (j = 0; j < authors.length; j++) { for (j = 0; j < authors.length; j++) {
var author = { var author = {
"firstName": "", "firstName": "",
...@@ -87,17 +87,17 @@ var load_excel_citation = function (cb) { ...@@ -87,17 +87,17 @@ var load_excel_citation = function (cb) {
author["firstName"] = authors[j].trim().split(".")[0]; author["firstName"] = authors[j].trim().split(".")[0];
author["lastName"] = authors[j].trim().split(".")[1]; author["lastName"] = authors[j].trim().split(".")[1];
item["item"].authors.push(author); item["item"].authors.push(author);
bibAuthors += authors[j].trim().split(".")[1] + ", " + authors[j].trim().split(".")[0] + " and "; bibAuthors+=authors[j].trim().split(".")[1] + ", "+ authors[j].trim().split(".")[0]+ " and ";
} else if (authors[j].trim().split(" ").length == 2) { } else if (authors[j].trim().split(" ").length == 2) {
author["firstName"] = authors[j].trim().split(" ")[0]; author["firstName"] = authors[j].trim().split(" ")[0];
author["lastName"] = authors[j].trim().split(" ")[1]; author["lastName"] = authors[j].trim().split(" ")[1];
item["item"].authors.push(author); item["item"].authors.push(author);
bibAuthors += authors[j].trim().split(" ")[1] + ", " + authors[j].trim().split(" ")[0] + " and "; bibAuthors+=authors[j].trim().split(" ")[1] + ", "+ authors[j].trim().split(" ")[0]+ " and ";
} else if (authors[j].trim().split(" ").length == 3) { } else if (authors[j].trim().split(" ").length == 3) {
author["firstName"] = authors[j].trim().split(" ")[0]; author["firstName"] = authors[j].trim().split(" ")[0];
author["lastName"] = authors[j].trim().split(" ")[2]; author["lastName"] = authors[j].trim().split(" ")[2];
item["item"].authors.push(author); item["item"].authors.push(author);
bibAuthors += authors[j].trim().split(" ")[2] + ", " + authors[j].trim().split(" ")[0] + " and "; bibAuthors+=authors[j].trim().split(" ")[2] + ", "+ authors[j].trim().split(" ")[0]+ " and ";
} }
} }
...@@ -108,11 +108,11 @@ var load_excel_citation = function (cb) { ...@@ -108,11 +108,11 @@ var load_excel_citation = function (cb) {
item["item"].keywords = jsonOutput[i].Keywords; item["item"].keywords = jsonOutput[i].Keywords;
} }
if (authors[0].split(" ").length == 3) { if (authors[0].split(" ").length == 3 ){
bit1stAuthorLN = authors[0].split(" ")[2]; bit1stAuthorLN = authors[0].split(" ")[2];
} else if (authors[0].split(" ").length == 2) { } else if (authors[0].split(" ").length == 2 ){
bit1stAuthorLN = authors[0].split(" ")[1]; bit1stAuthorLN = authors[0].split(" ")[1];
} else if (authors[0].split(" ").length == 1) { } else if (authors[0].split(" ").length == 1 ){
bit1stAuthorLN = authors[0].split(" ")[0]; bit1stAuthorLN = authors[0].split(" ")[0];
} }
...@@ -139,47 +139,36 @@ var load_excel_citation = function (cb) { ...@@ -139,47 +139,36 @@ var load_excel_citation = function (cb) {
var month = ""; var month = "";
if (jsonOutput[i].Date != undefined) { if (jsonOutput[i].Date != undefined){
month = jsonOutput[i].Date.split(",")[0].trim(); month = jsonOutput[i].Date.toString().split(",")[0].trim();
} }
//// BibTex ///////////////////// //// BibTex /////////////////////
item["bibtex"] = "@article{" + bit1stAuthorLN + jsonOutput[i].Year + "," + item["bibtex"] = "@article{"+ bit1stAuthorLN + jsonOutput[i].Year +","+
"title={" + jsonOutput[i].Titel + "title={"+ jsonOutput[i].Titel +
"},author={" + bibAuthors.trim().substring(0, bibAuthors.trim().lastIndexOf(" ")) + "},author={"+ bibAuthors.trim().substring(0, bibAuthors.trim().lastIndexOf(" ")) +
"},journal={" + jsonOutput[i].Journal + "},journal={"+ jsonOutput[i].Journal +
"},volume={" + jsonOutput[i].Volume + "},volume={"+ jsonOutput[i].Volume +
"},month={" + month + "},month={"+ month +
"},pages={" + jsonOutput[i].Pages + "},pages={"+ jsonOutput[i].Pages +
"},year={" + jsonOutput[i].Year + "},year={"+ jsonOutput[i].Year +
"},DOI ={" + jsonOutput[i].DOI + "},DOI ={"+ jsonOutput[i].DOI+
"},url ={" + jsonOutput[i].URL + "},url ={"+ jsonOutput[i].URL+
"}}" "}}"
jsonContent.push(item); jsonContent.push(item);
if (i == jsonOutput.length - 1) {
cb() // callback
}
}
// console.log(jsonContent);
} }
xmlHttpRequest.send(); //console.log(jsonContent);
} }
xmlHttpRequest.send();
// get paper from the Sabo result
load_excel_citation(function () {
stuff_paper = jsonContent;
var new_row = document.getElementById("cont_paper")
new_row.innerHTML = "";
var arrayLength = stuff_paper.length;
for (var i = 0; i < arrayLength; i++) {
if (i < max_paper_list && i <= arrayLength) { // str = str.substring(0, lastIndex);
addpaper(stuff_paper[i]);
}
//Do something //
} // ending of xlsx to json coversion
}) //
\ 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