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"].trim();
return ""+title+" ";
}
}
function printConferenceInformation(entry)
{
if(!entry.hasOwnProperty("B"))
{
return "";
}
else
{
var conferenceName = entry["B"];
var html = ""+conferenceName+"";
if(entry.hasOwnProperty("C"))
{
var conferenceLocation = entry["C"];
html+=", "+conferenceLocation+". ";
}
else
{
html+=". ";
}
return ""+html+""
}
}
function printDOIAPA6(entry)
{
if(!entry.hasOwnProperty("R"))
{
return "";
}
else
{
var doi = entry["R"];
return ""+doi+"";
}
}
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;
}
}
function printEditorsConferenceProceedingsAPA6(entry)
{
return printEditorsAPA6(entry).slice(0,-2)+", ";
}
function printEditorsBookSection(entry)
{
return printEditorsAPA6(entry).slice(0,-2)+", ";
}
function printEntries(args)
{
var html="";
if(!args.hasOwnProperty("entries"))
{
return "";
}
else
{
args.entries = args.entries.slice();
}
if(args.hasOwnProperty("filters"))
{
filterEntries(args);
}
if(args.hasOwnProperty("sortings"))
{
if(args.hasOwnProperty("grouping"))
{
var groupingCriteria = args["sortings"][0][0];
var lastGroupItem = "";
}
sortEntries(args);
}
for(var i=0; i < args.entries.length ;i++)
{
var entry = args.entries[i];
if(lastGroupItem!== undefined)
{
if(lastGroupItem !== eval("entry"+groupingCriteria))
{
lastGroupItem = eval("entry"+groupingCriteria);
html+= "" + lastGroupItem + "
";
}
}
html +="" + printEntry(entry) + "
";
}
return html;
}
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 "";
}
function printEntryBook(entry)
{
return "" + printAuthorsAPA6(entry) + printYearAPA6(entry) +
printTitleAPA6(entry) + printPublisherInformationBook(entry) + "";
}
function printEntryBookSection(entry)
{
return "" + printAuthorsAPA6(entry) +
printYearAPA6(entry) + printTitleAPA6(entry) + "In " +
printEditorsBookSection(entry) + printBookTitleBookSection(entry) +
"(pp. "+printPagesAPA6(entry)+"). " +
printPublisherInformationBook(entry) + printDOIAPA6(entry) + "";
}
function printEntryConference(entry)
{
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) + "";
}
}
function printEntryEditedBook(entry)
{
return "" + printEditorsAPA6(entry) + printYearAPA6(entry) +
printTitleAPA6(entry) + printPublisherInformationBook(entry) + "";
}
function printEntryGeneric(entry)
{
return "" + printAuthorsAPA6(entry) + printYearAPA6(entry) +
printTitleAPA6(entry) + printDOIAPA6(entry) + "";
}
function printEntryJournalArticle(entry)
{
return "" +printAuthorsAPA6(entry) + printYearAPA6(entry) +
printTitleAPA6(entry) + printJournalInfoAPA6(entry) + printDOIAPA6(entry) + "";
}
function printJournalInfoAPA6(entry)
{
var html="";
if(!entry.hasOwnProperty("B"))
{
return "";
}
else
{
var name = entry["B"].trim();
html+=" "+name+"";
if(entry.hasOwnProperty("V"))
{
html+=","
var volume = entry["V"].trim();
html+=" "+volume+"";
if(entry.hasOwnProperty("N"))
{
var issue = entry["N"].trim();
html+="("+issue+")";
}
}
if(entry.hasOwnProperty("P"))
{
html+=", "+printPagesAPA6(entry);
}
html+=".";
return ""+html+" ";
}
}
function printPagesAPA6(entry)
{
if(!entry.hasOwnProperty("P"))
{
return "";
}
else
{
return""+entry["P"].replace(" ","")+"";
}
}
function printPaperURL(entry)
{
if(!entry.hasOwnProperty("U"))
{
return "";
}
else
{
var PaperURL = entry["U"];
return "Retrieved from "+PaperURL+"";
}
}
function printPublisherInformationBook(entry)
{
var html="";
if(entry.hasOwnProperty("C"))
{
var place = entry["C"].trim();
html+=""+place+"";
}
if(entry.hasOwnProperty("I"))
{
var publisher = entry["I"].trim();
if(entry.hasOwnProperty("C"))
{
html+=": ";
}
html+=""+publisher+"";
}
if(entry.hasOwnProperty("C") || entry.hasOwnProperty("I"))
{
return ""+html+"";
}
}
function printPublisherInformationConferenceProceedings(entry)
{
var html="";
if(entry.hasOwnProperty("1"))
{
var place = entry["1"].trim();
html+=""+place+"";
}
if(entry.hasOwnProperty("I"))
{
var publisher = entry["I"].trim();
if(entry.hasOwnProperty("1"))
{
html+=": ";
}
html+=""+publisher+"";
}
if(entry.hasOwnProperty("1") || entry.hasOwnProperty("I"))
{
return ""+html+"";
}
}
function printTitleAPA6(entry)
{
if(!entry.hasOwnProperty("T"))
{
return "";
}
else
{
var title = entry["T"].trim();
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"].trim();
return ""+title+" ";
}
}
function printYearAPA6(entry)
{
var html=""
if(!entry.hasOwnProperty("D"))
{
html+= "(n.d.).";
}
else
{
html+= "("+entry["D"]+").";
}
return ""+html+" ";
}
function sortEntries(args)
{
if(!args.hasOwnProperty("entries"))
{
return false;
}
if(!args.hasOwnProperty("sortings"))
{
return false;
}
var sortings=args.sortings;
var entries=args.entries;
entries.sort(function(a,b){
for(var i=0; i < sortings.length ;i++)
{
var sorting = sortings[i];
var aComp = eval("a"+sorting[0]);
var bComp = eval("b"+sorting[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;
}
}
}
return 0;
});
return entries;
}
for(var i=0;i