//testLogic.js
//develop
//~ var cssLink = '\n';
//~ var enwFile = "http://fake:8001/stick/mount/pubListHagedorn.git/publist.enw";
//production
var cssLink = 'https://www.agrar.hu-berlin.de/de/institut/departments/daoe/ress/publistProgram/publications.css/at_download/file';//'\n';
var enwFile = "https://www.agrar.hu-berlin.de/de/institut/departments/daoe/ress/publistProgram/publist.enw/at_download/file";
var sortings=[
['["D"][0]','desc'], // sort for the year(="D") ascendingly
['["authors"].join(", ")','asc'], // sort for the authors descendingly
['["type"][0]','asc'] // sort for the authors descendingly
];
var filters=[];
var contacts = {
"Anggaaini, Eva": "https://www.agrar.hu-berlin.de/en/institut-en/departments/daoe/ress-en/mitarbeiter-en/anggraini",
"Arauz Torres, Mario A." : "https://www.agrar.hu-berlin.de/en/institut-en/departments/daoe/ress-en/mitarbeiter-en/torres/view",
"Berger, Lars" : "https://www.agrar.hu-berlin.de/en/institut-en/departments/daoe/ress-en/mitarbeiter-en/berger/",
"Bhatt, Brijesh" : "https://www.agrar.hu-berlin.de/en/institut-en/departments/daoe/ress-en/mitarbeiter-en/bhatt",
"Buschmann, Anna" : "https://www.agrar.hu-berlin.de/en/institut-en/departments/daoe/ress-en/mitarbeiter-en/buschmann",
"Chennamaneni, Ramesh" : "https://www.agrar.hu-berlin.de/en/institut-en/departments/daoe/ress-en/mitarbeiter-en/chennamaneni/view",
"Chinambaram, Bhubanachithra" : "https://www.agrar.hu-berlin.de/en/institut-en/departments/daoe/ress-en/mitarbeiter-en/chidam",
"Crewett, Wibke" : "https://www.agrar.hu-berlin.de/en/institut-en/departments/daoe/ress-en/mitarbeiter-en/wibkecrewett",
"Ehlers, Melf-Hinrich" : "http://www.york.ac.uk/environment/our-staff/melf-ehlers/",
"Farrell, Katharine N." : "https://www.resource-economics.hu-berlin.de/mitarbeiter/farrell",
"Gandhi, Ruhi" : "https://www.agrar.hu-berlin.de/en/institut-en/departments/daoe/ress-en/mitarbeiter-en/ruhi",
"Gatzweiler, Franz" : "https://www.resource-economics.hu-berlin.de/mitarbeiter/gatzweiler",
"Gottwald, Franz-Theo" : "https://www.resource-economics.hu-berlin.de/mitarbeiter/gottwald/view",
"Gouja, Majdi" : "https://www.agrar.hu-berlin.de/en/institut-en/departments/daoe/ress-en/mitarbeiter-en/Gouja/view",
"Griewald, Yuliana" : "http://www.agrar.hu-berlin.de/fakultaet/departments/daoe/ress/mitarbeiter/polishchuk",
"Grundmann, Philipp" :"https://www.resource-economics.hu-berlin.de/mitarbeiter/grundmann/view",
"Hagedorn, Konrad" : "https://www.resource-economics.hu-berlin.de/mitarbeiter/Hagedorn",
"Hagemann, Nina" : "https://www.agrar.hu-berlin.de/en/institut-en/departments/daoe/ress-en/mitarbeiter-en/hagemann/view",
"Hamidov, Ahmad":"https://www.agrar.hu-berlin.de/en/institut-en/departments/daoe/ress-en/mitarbeiter-en/hamidov",
"Hampel, Wiebke" : "http://www.iri-thesys.org/people/wiebke_hampel",
"Horam, Phungmayo" : "https://www.agrar.hu-berlin.de/en/institut-en/departments/daoe/ress-en/mitarbeiter-en/phungmayo/",
"Jakhalu, Atoho" : "https://www.agrar.hu-berlin.de/en/institut-en/departments/daoe/ress-en/mitarbeiter-en/atoho/",
"Judis, Renate" : "https://www.agrar.hu-berlin.de/en/institut-en/departments/daoe/ress-en/mitarbeiter-en/Judis",
"Kaim, Eike" : "https://www.agrar.hu-berlin.de/en/institut-en/departments/daoe/ress-en/mitarbeiter-en/kaim",
"Kasymov, Ulan" : "https://www.agrar.hu-berlin.de/en/institut-en/departments/daoe/ress-en/mitarbeiter-en/kasymov",
"Keerthi, Kiran B." : "https://www.agrar.hu-berlin.de/en/institut-en/departments/daoe/ress-en/mitarbeiter-en/keerthi",
"Keutmann, Sarah" : "https://www.agrar.hu-berlin.de/en/institut-en/departments/daoe/ress-en/mitarbeiter-en/keutmann",
"Kutschke, Andreas" : "http://www.sfimm.de/team",
"Mann, Carsten" : "https://www.agrar.hu-berlin.de/en/institut-en/departments/daoe/ress-en/mitarbeiter-en/Mann_PostDoc",
"Nguyen, Minh D." : "https://www.agrar.hu-berlin.de/en/institut-en/departments/daoe/ress-en/mitarbeiter-en/dao",
"Papasozomenou, Ourania" : "https://www.agrar.hu-berlin.de/en/institut-en/departments/daoe/ress-en/mitarbeiter-en/papasozomenou",
"Patil, Vikram" : "https://www.agrar.hu-berlin.de/en/institut-en/departments/daoe/ress-en/mitarbeiter-en/patil",
"Perez Carmona, Alexander" : "https://www.agrar.hu-berlin.de/en/institut-en/departments/daoe/ress-en/mitarbeiter-en/carmona",
"Pham, Than L." : "https://www.agrar.hu-berlin.de/en/institut-en/departments/daoe/ress-en/mitarbeiter-en/pham",
"Proestou, Maria" : "https://www.agrar.hu-berlin.de/en/institut-en/departments/daoe/ress-en/mitarbeiter-en/proestou",
"Raes, Leander" : "https://www.agrar.hu-berlin.de/fakultaet-en/departments/daoe/ress-en/mitarbeiter-en/raes",
"Roggero, Matteo":"http://www.agrar.hu-berlin.de/fakultaet/departments/daoe/envirgov/mitarbeiter/roggero",
"Schleyer, Christian": "https://www.resource-economics.hu-berlin.de/mitarbeiter/schleyer",
"Schmidt, Oscar" : "http://www.iass-potsdam.de/de/menschen/oscar-schmidt",
"Stupak, Nataliya": "https://www.agrar.hu-berlin.de/fakultaet-en/departments/daoe/ress-en/mitarbeiter-en/drstupak",
"Theesfeld, Insa" : "http://www.landw.uni-halle.de/prof/agrarpolitik/mitarbeiterinnen/insatheesfeld/",
"Thiel, Andreas": "https://www.agrar.hu-berlin.de/fakultaet/departments/daoe/envirgov/mitarbeiter/thiel_dt",
"Villamayor-Tomas, Sergio" : "https://www.resource-economics.hu-berlin.de/mitarbeiter/villamayor",
"Villamayor-Tomás, Sergio" : "https://www.resource-economics.hu-berlin.de/mitarbeiter/villamayor",
"Watanabe, Shigeo" : "https://www.agrar.hu-berlin.de/en/institut-en/departments/daoe/ress-en/mitarbeiter-en/watanabe2",
"Werthmann, Christine" : "https://www.agrar.hu-berlin.de/en/institut-en/departments/daoe/ress-en/mitarbeiter-en/werthmann",
"Yu Lu" : "https://www.agrar.hu-berlin.de/en/institut-en/departments/daoe/ress-en/mitarbeiter-en/Yu",
"Zikos, Dimitrios" : "https://www.agrar.hu-berlin.de/en/institut-en/departments/daoe/ress-en/mitarbeiter-en/zikos"
}
/** about the filter
* a single filter should be telling about what attribute of the filter objects (the entries) it
* works upon (the CRITERIA) and which is the conditions CONDITION
* CONDITIONS can be
* a) nummeric
* exact YEAR === 1234
* exact YEAR !== 1234
* b) existing profing
* attribute A is set in the entry
* c) textual
* exact TITLE === "aaaaaaaa"
* All filters are substractive for we start with all entries.
* No logic will be used for combination filters
* The order of the filters matters
*
**/
/** @summary - filter the entries based on some eval expressions.
*
* @descritpion - one or more filter (which take the form of eval statements) are provided. in the
* form of the param [args.filters].
* Filtering starts with all entries and substracts (SUBSTRACTIVE, progressive filters)
* and by each filter more and more entries are potentially eliminated.
*
* @param args.filters - Array of Strings, each string is filters in the way that it is eval()'ed
* example strings are
* 'entry["type"]==="Journal Article"' // filter for type
* 'entry.hasOwnProperty("authors")', // filter that the entries field author exists
* 'entry["authors"].length!==1', // number of authors
*
* @param args.entries - the initial set of entries on which the filtering is to be done upon. It
* is important to notice that this Array of Entries is modified and hence if we need to keep
* a record of the entries we can filter only a copy of the entries.
*
* @return - the array of entries resulted from the filtering is returned.
**/
function filterEntries(args)
{
// (0) validity checking
if(!args.hasOwnProperty("entries"))
{
return false;
}
if(!args.hasOwnProperty("filters"))
{
return false;
}
// (1) the actual filtering
var filters=args.filters;
var entries=args.entries;
for(var i=0; i < filters.length ;i++)
{
filter = filters[i];
for(var u=entries.length-1; u > -1; u--)
{
var entry = entries[u];
//console.log("Entry"+JSON.stringify(entry));
//console.log("filter: "+filter+" =>"+eval(filter));
if(!eval(filter))
{
//remove
entries.splice(u,1);
//console.log("splice"+u);
}
else
{
//console.log("keep");
}
}
}
return entries;
}
/** @summary - print correctly (that is in APA6-style rules) the name of the author.
*
* @description - in APA6 The family/sirname of an Author is printed in full, and first names are
* appreviated. This is for human being authors.
* There is also the exception that the author can be an organisation in which case the full
* organisation's name is writen.
* The Distinction between (a) human being author and (b) organisation author is done via the
* parameter authorENW and if it has a COMMA or NOT?
*
* @param authorENW - [string] in the form
* "The Name of the Organisation" or
* "Sirname, Name SecondName"
* The existance of a comma demarks a human being author from an organisation.
* There is some limitations to this, in cases in which the orga's name contains a comma.
* At present only human being authors are supported
*
* @return - the string in the correct APA6 format (WITHOUT any trailing or leading whitespace)
*
* @TODO [ ] 14.1.15 implement the handling of organisation authors
**/
function printAuthorAPA6(authorENW)
{
if(authorENW===undefined)
{
//console.log("shit");
}
try
{
var parts = authorENW.split(",",2);
}
catch(ex)
{
//console.log("shit");
}
if(parts.length<2)
{
return parts[0];
}
//abreviate first name(s)
firstnames = parts[1].trim().split(" ");
for (var i=0; i < firstnames.length; i++)
{
firstnames[i] = firstnames[i].trim()[0].toUpperCase()+".";
}
var returnvalue = parts[0].trim() + ", " + firstnames.join(" ");
//console.log("printAuthorAPA6"+authorENW+":"+returnvalue);
var contact = contacts[authorENW];
//~ console.log(authorENW);
//~ console.log(contact);
if(contact!==undefined)
{
return '' + returnvalue +'';
}
else
{
return '' + returnvalue +'';
}
}
/** @summary - print correctly the Authors in the format of APA6 rules
*
* @decription - Having stored the names in an entry like this (JSON)
* entry{"authors":["1stAuthorSirname, 1stAuthorName","2ndAuthorSirname, 2ndAuthorName",....]}
* we want to put them in the correct for of APA6
* the rules are
* case "one single only author":
* AuthorSirnam, A.
* case 2-7 authors - example for 3:
* 1stAuthorSirnam, A., 2ndAuthorSirnam, A., & 3rdAuthorSirnam, A.
* "comma separated and an additional & ambersand before last Author"
* case 8+ Authors:
* One, N., Two, N., Three, N., Four, N., Five, N., Six, N., . . . Eight, N.
*
* @return the string of the correctly printed authors in APA6 style
**/
function printAuthorsAPA6(entry)
{
var html = "";
if(!entry.hasOwnProperty("authors"))
{
return html;
}
if(entry.authors.length === 0)
{
return html;
}
else if(entry.authors.length === 1)
{
html = printAuthorAPA6(entry.authors[0]);
}
else if(entry.authors.length <= 7)
{
for(var i=0;i 7)
{
for(var i=0;i<6;i++)
{
html += printAuthorAPA6(entry.authors[i])+", ";
}
html += ". . . "+printAuthorAPA6(entry.authors[entry.authors.length-1]);
}
return ""+html+" ";
}
function printBookTitleBookSection(entry)
{
if(!entry.hasOwnProperty("B"))
{
return "";
}
else
{
var title = entry["B"].join(" ").trim();
return ""+title+" ";
}
}
/** @summary - print the doi
* */
function printConferenceInformation(entry)
{
if(!entry.hasOwnProperty("B"))
{
return "";
}
else
{
var conferenceName = entry["B"].join(" ").trim();;
var html = ""+conferenceName+"";
if(entry.hasOwnProperty("C"))
{
var conferenceLocation = entry["C"].join(" ").trim();
html+=", "+conferenceLocation+". ";
}
else
{
html+=". ";
}
return ""+html+""
}
}
/** @summary - print the doi
* */
function printDOIAPA6(entry)
{
if(!entry.hasOwnProperty("R"))
{
return "";
}
else
{
var doi = entry["R"];
return ""+doi+"";
}
}
/** @summary -
**/
function printEditorsAPA6(entry)
{
if(!entry.hasOwnProperty("editors"))
{
return "";
}
else
{
if(!entry.hasOwnProperty("authors"))
{
var authors = undefined;
}
else
{
var authors = entry.authors.slice();
}
entry.authors = entry.editors.slice();
var html = printAuthorsAPA6(entry).replace("class=\"author","class=\"editor");
entry.authors = authors;
if(entry["editors"].length===1)
{
html+="(Ed.). ";
}
else if (entry["editors"].length>1)
{
html+="(Eds.). ";
}
return html;
}
}
/** @summary -
**/
function printEditorsConferenceProceedingsAPA6(entry)
{
return printEditorsAPA6(entry).slice(0,-2)+", ";
}
/** @summary -
**/
function printEditorsBookSection(entry)
{
return printEditorsAPA6(entry).slice(0,-2)+", ";
}
/** @summary - the function to print (i.e. generate adequate http-markup) entries according to the
* args parameters provided
* @param args.entries - Arrag of Entry objects (the handle/reference provided will not be modified)
* @param args.filters - Array of Strings with eval filters
* @param args.sortings - Array of sorting informations
**/
function printEntries(args)
{
// to contain the generated html
var html="";
// (0) validate for entries
if(!args.hasOwnProperty("entries"))
{
return "";
}
else
{
// we work on a shallow copy and leave the entries originals untouched
args.entries = args.entries.slice();
}
// (1) filter the entries
if(args.hasOwnProperty("filters"))
{
filterEntries(args);
}
// (2) sort the entries
if(args.hasOwnProperty("sortings"))
{
if(args.hasOwnProperty("grouping"))
{
var groupingCriteria = args["sortings"][0][0];
var lastGroupItem = "";
}
//console.log("sortEntries");
sortEntries(args);
}
// (3) finally the printing of the entries
for(var i=0; i < args.entries.length ;i++)
{
var entry = args.entries[i];
if(lastGroupItem!== undefined)
{
console.log("INFO entry"+groupingCriteria);
if(lastGroupItem !== eval("entry"+groupingCriteria))
{
lastGroupItem = eval("entry"+groupingCriteria);
html+= "
" + lastGroupItem + "
";
}
}
html +="
" + printEntry(entry) + "
";
//html +="
" + printEntry(entry) + "
";
//html +="
" + printEntry(entry) + "
";
}
return html;
}
/** @summary - the function to print a single entry (delegates to a specific funciton for the
* respective entry type)
**/
function printEntry(entry)
{
if(window.location.hash.substr(1) === "types")
{
if(entry.hasOwnProperty("type"))
{
switch(entry.type)
{
case "Book":
return "BOOK "+printEntryBook(entry);
break;
case "Book Section":
return "BOOKSECTION "+printEntryBookSection(entry);
break;
case "Conference Proceedings":
case "Conference Paper":
return "CONFERENCE "+printEntryConference(entry);
break;
case "Edited Book":
return "EDITEDBOOK "+printEntryEditedBook(entry);
break;
case "Journal Article":
return "JOURNALARTICLE "+printEntryJournalArticle(entry);
break;
default:
return "GENERIC "+printEntryGeneric(entry);
}
}
else
{
return "GENERIC "+printEntryGeneric(entry);
}
}
else
{
if(entry.hasOwnProperty("type"))
{
switch(entry.type)
{
case "Book":
return printEntryBook(entry);
break;
case "Book Section":
return printEntryBookSection(entry);
break;
case "Conference Proceedings":
case "Conference Paper":
return printEntryConference(entry);
break;
case "Edited Book":
return printEntryEditedBook(entry);
break;
case "Journal Article":
return printEntryJournalArticle(entry);
break;
default:
return printEntryGeneric(entry);
}
}
else
{
return printEntryGeneric(entry);
}
}
return "";
}
/** @summary -
**/
function printEntryBook(entry)
{
return "" + printAuthorsAPA6(entry) + printYearAPA6(entry) +
printTitleAPA6(entry) + printPublisherInformationBook(entry) + "";
}
/** @summary -
*
**/
function printEntryBookSection(entry)
{
return "" + printAuthorsAPA6(entry) +
printYearAPA6(entry) + printTitleAPA6(entry) + "In " +
printEditorsBookSection(entry) + printBookTitleBookSection(entry) +
"(pp. "+printPagesAPA6(entry)+"). " +
printPublisherInformationBook(entry) + printDOIAPA6(entry) + "";
}
//~ %0 Conference Proceedings
//~ %A Authorfirstword, Authorsecondword
//~ %A Bditorfirstword, Bditorsecondword
//~ %D 2008
//~ %T Title
//~ %E Editorfirstword, Editorsecondword
//~ %E Bditorfirstword, Bditorsecondword
//~ %B Conference Name
//~ %C Conference Location
//~ %I Publisher
//~ %V Volume
//~ %P Pages
//~ %8 Date
//~ %! Title
//~ %1 Place Published
//~ %3 Proceedings Title
//~
//~
//~
//~ %0 Conference Paper
//~ %A Authorfirstword, Authorsecondword
//~ %A Buthorfirstword, Buthorsecondword
//~ %D 2009
//~ %T Title
//~ %E Editorfirstword, Editorsecondword
//~ %E Bditorfirstword, Bditorsecondword
//~ %B Conference Name
//~ %C Conference Location
//~ %I Publisher
//~ %V Volume
//~ %P pages
//~ %8 Date
//~ %1 Place Published
//~ %1 Place Published
//~ %I Publisher
// Conference Paper
// Coference Proceeding
//~ Author1Family, A. F., & Author2Family, A. F. (1999b). *Title of Conference Paper.* Paper presented at the Conference Name, New York.
//~ Author1Family, A. F., & Author2Family, A. F. (1999c, 13.December 2003).
//~ *Title of Conference Proceedings.* Paper presented at the Conference Name, New York.
// Author Surname, First Initial. Second Initial. (Year). Conference paper title.
// In Editor First Initial. Editor Surname (Ed.), *Proceedings Book Title* (pp. page range of paper).
// Place of Publication: Publisher.
// Armstrong, D. B., Fogarty, G. J., & Dingsdag, D. (2007). Scales measuring characteristics of small
// business information systems. In W-G. Tan (Ed.), *Proceedings of Research, Relevance and
// Rigour: Coming of age: 18th Australasian Conference on Information Systems* (pp. 163-171).
// Toowoomba, Australia: University of Southern Queensland.
//~ Author Surname, First Initial. Second Initial. (Year). Conference paper title. Paper
//~ presented at the Conference Title, Place, US state/country. Retrieved from URL
//~ Taylor, J. A. (2006). Assessment: a tool for development and engagement in the first
//~ year of university study. Paper presented at the Engaging Students: 9th Pacific Rim
//~ in Higher Education (FYHE) Conference, Griffith, Australia. Retrieved from
//~ http://www.fyhe.com.au/past_papers/2006/Papers/Taylor.pdf
/** @summary -
**/
function printEntryConference(entry)
{
// if there is a Title of the Proceedings, then it is a Proceeding
if(entry.hasOwnProperty("3"))
{
return "" + printAuthorsAPA6(entry) +
printYearAPA6(entry) + printTitleAPA6(entry) + "In " +
printEditorsConferenceProceedingsAPA6(entry) + printTitleConferenceProceedings(entry) +
"(pp. "+printPagesAPA6(entry)+"). " +
printPublisherInformationConferenceProceedings(entry) + printDOIAPA6(entry) + "";
}
else
{
return "" + printAuthorsAPA6(entry) +
printYearAPA6(entry) + printTitleAPA6(entry) + "Paper presented at the " +
printConferenceInformation(entry) + printPaperURL(entry) + "";
}
}
/** @summary -
**/
function printEntryEditedBook(entry)
{
return "" + printEditorsAPA6(entry) + printYearAPA6(entry) +
printTitleAPA6(entry) + printPublisherInformationBook(entry) + "";
}
/** @summary -
**/
function printEntryGeneric(entry)
{
return "" + printAuthorsAPA6(entry) + printYearAPA6(entry) +
printTitleAPA6(entry) + printDOIAPA6(entry) + "";
}
/** @summary -
* @example desired output:
* AnotherAuthor1Family, A. F., AnotherAuthor2Family, A. F., Miller, C., & Smith, C. (1999).
* Title of the article. *Journal Name*, *1*(2), 22-33. doi: doi:10.1371/journal.pbio.0020449.g001
**/
function printEntryJournalArticle(entry)
{
return "" +printAuthorsAPA6(entry) + printYearAPA6(entry) +
printTitleAPA6(entry) + printJournalInfoAPA6(entry) + printDOIAPA6(entry) + "";
}
/** @summary - print th jounrals information in APA6 format
* */
function printJournalInfoAPA6(entry)
{
var html="";
// journal name
if(!entry.hasOwnProperty("B"))
{
return "";
}
else
{
var name = entry["B"].join(" ").trim();
html+=" "+name+"";
// journal volume
if(entry.hasOwnProperty("V"))
{
html+=","
var volume = entry["V"].join(" ").trim();
html+=" "+volume+"";
// journal issue
if(entry.hasOwnProperty("N"))
{
var issue = entry["N"].join(" ").trim();
html+="("+issue+")";
}
}
if(entry.hasOwnProperty("P"))
{
html+=", "+printPagesAPA6(entry);
}
// the trailing punctuation
html+=".";
return ""+html+" ";
}
}
/** @summary - print in APA6 format the pages information
* */
function printPagesAPA6(entry)
{
if(!entry.hasOwnProperty("P"))
{
return "";
}
else
{
return""+entry["P"].join(" ").replace(" ","")+"";
}
}
/** @summary - print the doi
* */
function printPaperURL(entry)
{
if(!entry.hasOwnProperty("U"))
{
return "";
}
else
{
var PaperURL = entry["U"].join(" ").trim();
return "Retrieved from "+PaperURL+"";
}
}
//~ %C Place Published
//~ %I Publisher
/** @summary - print in APA6 format the pages information
* */
function printPublisherInformationBook(entry)
{
var html="";
if(entry.hasOwnProperty("C"))
{
var place = entry["C"].join(" ").trim();
html+=""+place+"";
}
if(entry.hasOwnProperty("I"))
{
var publisher = entry["I"].join(" ").trim();
if(entry.hasOwnProperty("C"))
{
html+=": ";
}
html+=""+publisher+"";
}
if(entry.hasOwnProperty("C") || entry.hasOwnProperty("I"))
{
return ""+html+"";
}
}
//~ %1 Place Published
//~ %I Publisher
/** @summary - print in APA6 format the pages information
* */
function printPublisherInformationConferenceProceedings(entry)
{
var html="";
if(entry.hasOwnProperty("1"))
{
var place = entry["1"].join(" ").trim();
html+=""+place+"";
}
if(entry.hasOwnProperty("I"))
{
var publisher = entry["I"].join(" ").trim();
if(entry.hasOwnProperty("1"))
{
html+=": ";
}
html+=""+publisher+"";
}
if(entry.hasOwnProperty("1") || entry.hasOwnProperty("I"))
{
return ""+html+"";
}
}
/** @summary - print the title in APA6 format
* @description - APA6 format puts the title as it is and ends it with a "." (point). If the title
* already has a punctuation the original title's punctuation is kept.
*
* */
function printTitleAPA6(entry)
{
if(!entry.hasOwnProperty("T"))
{
return "";
}
else
{
var title = entry["T"].join(" ").trim();
// if the title does not have a "."/"!"/"?" already, then add a "."
if(title.slice(-1) !== "?" && title.slice(-1) !== "." && title.slice(-1) !== "!")
{
title+=".";
}
return ""+title+" ";
}
}
function printTitleConferenceProceedings(entry)
{
if(!entry.hasOwnProperty("3"))
{
return "";
}
else
{
var title = entry["3"].join(" ").trim();
return ""+title+" ";
}
}
/** @summary - print the year in APA6 format
* @description - APA6 the year is print in a format like those
* (1999).
* (2009).
* or
* (n.d.). if no date is known
* for several publications of the same authors an enumaration by alphabetic characters is used
* (1999a).
* (1999b).
* TODO [ ] this feature is not yet implemented
* */
function printYearAPA6(entry)
{
var html=""
if(!entry.hasOwnProperty("D"))
{
html+= "(n.d.).";
}
else
{
html+= "("+entry["D"]+").";
}
return ""+html+" ";
}
/** @summary - sort the entries based on 2-tuples
* */
function sortEntries(args)
{
// (0) validity checking
if(!args.hasOwnProperty("entries"))
{
return false;
}
if(!args.hasOwnProperty("sortings"))
{
return false;
}
// (1) the actual sorting
var sortings=args.sortings;
var entries=args.entries;
//~ var sortings=[['["D"]','asc'], // sort for the year(="D") ascendingly
//~ ['["authors"].join(",")','desc'] // sort for the authors descendingly
//~ ];
entries.sort(function(a,b){
for(var i=0; i < sortings.length ;i++)
{
// console.log("comparison:"+JSON.stringify(sorting)+" a="+JSON.stringify(a)+" b="+JSON.stringify(b));
//console.log("comparison:"+JSON.stringify(sorting)+" a="+JSON.stringify(a)+" b="+JSON.stringify(b));
//~ console.log("comparison:"+JSON.stringify(sorting)+" aComp="+aComp+" bComp="+bComp);
var sorting = sortings[i];
try
{
var aComp = eval("a"+sorting[0]);
var bComp = eval("b"+sorting[0]);
}
catch(ex)
{
return 0;
}
if( aComp > bComp )
{
if(sorting[1].toLowerCase()==="asc")
{
return 1;
}
else if(sorting[1].toLowerCase()==="desc")
{
return -1;
}
}
else if(aComp < bComp)
{
if(sorting[1].toLowerCase()==="asc")
{
return -1;
}
else if(sorting[1].toLowerCase()==="desc")
{
return 1;
}
}
}
// returing 0 means that the entries are equal in position
return 0;
});
return entries;
}
/** @summary - Load the entries of the publication list via ajax request
* */
function getEntries()
{
req = new XMLHttpRequest();
req.open("GET",enwFile,true);
req.overrideMimeType('text/plain');
req.onreadystatechange = function ()
{
// 4.1 inside we have to check for failed request
if (req.status != 200 && req.status != 304)
{
// code for failure here
return;
}
// readyState 4 is the final one and means that the request was returned
else if (req.readyState == 4)
{
// code for success here
// print the text received
parseENW(req.responseText);
return;
}
}
// 5 this call sends of the XHR
req.send();
}
/** @summary - parses ENW (endnote export format)
* */
function parseENW(ENWdata)
{
content=ENWdata;
//~ console.log(content);
// get rid of the ass-ugly Shit-MS-Windows "carriage return shit"
content = content.replace(/\r/g,"");
// split at newlines
contentSplit = content.split("\n");
var currentEntry = undefined;
var entries=[];
for(var i=0;iPublications
';
html += ' Sorting: ';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
divHook.innerHTML=html;
window.RESSPublications=document.getElementById("RESSPublications");
getEntries();
}
if(true)
{
var divHook = document.getElementById("hook");
var basefilter = [];
if( divHook.textContent.trim() !== "" )
{
basefilter.push('entry["authors"].join(";").indexOf("'+divHook.textContent.trim()+'")!==-1');
}
makeInterface();
}
//
var publicationShown=document.getElementById("publicationShown");