jQuery(document).ready(function() {if(jQuery(".zp-Zotpress-Bib").length>0) {jQuery(".zp-Zotpress-Bib").each(function(index,instance) {var $instance=jQuery(instance);var zp_params={};zp_params.zpItemkey=!1;if(jQuery(".ZP_ITEM_KEY",$instance).text().trim().length>0)zp_params.zpItemkey=jQuery(".ZP_ITEM_KEY",$instance).text();zp_params.zpCollectionId=!1;if(jQuery(".ZP_COLLECTION_ID",$instance).text().trim().length>0)zp_params.zpCollectionId=jQuery(".ZP_COLLECTION_ID",$instance).text();zp_params.zpTagId=!1;if(jQuery(".ZP_TAG_ID",$instance).text().trim().length>0)zp_params.zpTagId=jQuery(".ZP_TAG_ID",$instance).text();zp_params.zpAuthor=!1;if(jQuery(".ZP_AUTHOR",$instance).text().trim().length>0)zp_params.zpAuthor=jQuery(".ZP_AUTHOR",$instance).text();zp_params.zpYear=!1;if(jQuery(".ZP_YEAR",$instance).text().trim().length>0)zp_params.zpYear=jQuery(".ZP_YEAR",$instance).text();zp_params.zpStyle=!1;if(jQuery(".ZP_STYLE",$instance).text().trim().length>0)zp_params.zpStyle=jQuery(".ZP_STYLE",$instance).text();zp_params.zpLimit=!1;if(jQuery(".ZP_LIMIT",$instance).text().trim().length>0)zp_params.zpLimit=jQuery(".ZP_LIMIT",$instance).text();zp_params.zpTitle=!1;if(jQuery(".ZP_TITLE",$instance).text().trim().length>0)zp_params.zpTitle=jQuery(".ZP_TITLE",$instance).text();zp_params.zpShowImages=!1;if(jQuery(".ZP_SHOWIMAGE",$instance).text().trim().length>0)zp_params.zpShowImages=jQuery(".ZP_SHOWIMAGE",$instance).text().trim();zp_params.zpShowTags=!1;if(jQuery(".ZP_SHOWTAGS",$instance).text().trim().length>0)zp_params.zpShowTags=!0;zp_params.zpDownloadable=!1;if(jQuery(".ZP_DOWNLOADABLE",$instance).text().trim().length>0)zp_params.zpDownloadable=!0;zp_params.zpInclusive=!1;if(jQuery(".ZP_INCLUSIVE",$instance).text().trim().length>0)zp_params.zpInclusive=!0;zp_params.zpShowNotes=!1;if(jQuery(".ZP_NOTES",$instance).text().trim().length>0)zp_params.zpShowNotes=!0;zp_params.zpShowAbstracts=!1;if(jQuery(".ZP_ABSTRACT",$instance).text().trim().length>0)zp_params.zpShowAbstracts=!0;zp_params.zpCiteable=!1;if(jQuery(".ZP_CITEABLE",$instance).text().trim().length>0)zp_params.zpCiteable=!0;zp_params.zpTarget=!1;if(jQuery(".ZP_TARGET",$instance).text().trim().length>0)zp_params.zpTarget=!0;zp_params.zpURLWrap=!1;if(jQuery(".ZP_URLWRAP",$instance).text().trim().length>0)zp_params.zpURLWrap=jQuery(".ZP_URLWRAP",$instance).text();zp_params.zpHighlight=!1;if(jQuery(".ZP_HIGHLIGHT",$instance).text().trim().length>0)zp_params.zpHighlight=jQuery(".ZP_HIGHLIGHT",$instance).text();zp_params.zpForceNumsCount=1;if(zp_params.zpCollectionId&&zp_params.zpCollectionId.indexOf(',')!=-1) {var tempCollections=zp_params.zpCollectionId.split(',');jQuery.each(tempCollections,function(i,collection) {zp_params.zpCollectionId=collection;zp_get_items(0,0,$instance,zp_params,!1)})} else{if(zp_params.zpTagId&&zp_params.zpInclusive==!0&&zp_params.zpTagId.indexOf(",")!=-1) {var tempTags=zp_params.zpTagId.split(",");jQuery.each(tempTags,function(i,tag) {zp_params.zpTagId=tag;zp_get_items(0,0,$instance,zp_params,!1)})} else{if(zp_params.zpAuthor&&zp_params.zpAuthor.indexOf(",")!=-1) {var tempAuthors=zp_params.zpAuthor.split(",");if(zp_params.zpInclusive==!0) {jQuery.each(tempAuthors,function(i,author) {zp_params.zpAuthor=author;zp_get_items(0,0,$instance,zp_params,!1)})} else{zp_get_items(0,0,$instance,zp_params,!1)}} else{if(zp_params.zpYear&&zp_params.zpYear.indexOf(",")!=-1) {var tempYears=zp_params.zpYear.split(",");jQuery.each(tempYears,function(i,year) {zp_params.zpYear=year;zp_get_items(0,0,$instance,zp_params,!1)})} else{zp_get_items(0,0,$instance,zp_params,!1)}}}}})} function zp_get_items(request_start,request_last,$instance,params,update) {if(typeof(request_start)==="undefined"||request_start=="false"||request_start=="") request_start=0;if(typeof(request_last)==="undefined"||request_last=="false"||request_last=="") request_last=0;jQuery.ajax({url:zpShortcodeAJAX.ajaxurl,ifModified:!0,data:{'action':'zpRetrieveViaShortcode','instance_id':$instance.attr("id"),'api_user_id':jQuery(".ZP_API_USER_ID",$instance).text(),'item_type':jQuery(".ZP_ITEM_TYPE",$instance).text(),'item_key':params.zpItemkey,'collection_id':params.zpCollectionId,'tag_id':params.zpTagId,'author':params.zpAuthor,'year':params.zpYear,'style':params.zpStyle,'limit':params.zpLimit,'title':params.zpTitle,'showimage':params.zpShowImages,'showtags':params.zpShowTags,'downloadable':params.zpDownloadable,'inclusive':params.zpInclusive,'shownotes':params.zpShowNotes,'showabstracts':params.zpShowAbstracts,'citeable':params.zpCiteable,'target':params.zpTarget,'urlwrap':params.zpURLWrap,'highlight':params.zpHighlight,'sortby':jQuery(".ZP_SORTBY",$instance).text(),'order':jQuery(".ZP_ORDER",$instance).text(),'update':update,'request_start':request_start,'request_last':request_last,'zpShortcode_nonce':zpShortcodeAJAX.zpShortcode_nonce},xhrFields:{withCredentials:!0},success:function(data) {var zp_items=jQuery.parseJSON(data);if(zp_items.status=='empty') {var zp_msg='There was a Zotpress error: ';if(zp_items.data==0) {zp_items.data='No items found.';zp_msg=zp_items.data} else{zp_msg+=zp_items.data} console.log(zp_msg);var hideErrMsg='';if(jQuery("#"+zp_items.instance+" .zp-List .zp-Entry").length>0) hideErrMsg=' class="hide"';jQuery("#"+zp_items.instance+" .zp-List").removeClass('loading').append(''+zp_msg+'

')} else{jQuery("#"+zp_items.instance+" .zp-SEO-Content").remove();if(typeof zp_items!='undefined'&&zp_items!=null&&zp_items!=0&&zp_items.data.length>0) {var tempItems="";if(params.zpShowNotes==!0)var tempNotes="";if(update===!1) {jQuery("#"+zp_items.instance+" .zp-List").addClass("used_cache")} else if(update===!0) {if(!jQuery("#"+zp_items.instance+" .zp-List").hasClass("updating")&&jQuery("#"+zp_items.instance+" .zp-Citation-Notes").length>0) jQuery("#"+zp_items.instance+" .zp-Citation-Notes").remove();if(!jQuery("#"+zp_items.instance+" .zp-List").hasClass("updating")) jQuery("#"+zp_items.instance+" .zp-List").addClass("updating");params.zpForceNumsCount=1} jQuery.each(zp_items.data,function(index,item) {var tempItem="";var $item_ref=jQuery("#"+zp_items.instance+" .zp-List #zp-ID-"+jQuery(".ZP_POSTID",$instance).text()+"-"+jQuery(".ZP_API_USER_ID",$instance).text()+"-"+item.key);if($item_ref.length>0&&update===!1&&!jQuery("#"+zp_items.instance+" .zp-List").hasClass("used_cache")) return!1;var tempItemType="none";if(item.data.hasOwnProperty('itemType')) tempItemType=item.data.itemType;var tempItemYear="0000";var tempItemDate="0000";if(item.meta.hasOwnProperty('parsedDate')) {tempItemYear=item.meta.parsedDate.substring(0,4);tempItemDate=item.meta.parsedDate} var tempAuthor=item.data.title;if(item.meta.hasOwnProperty('creatorSummary')) tempAuthor=item.meta.creatorSummary.replace(/ /g,"-");tempItem+="
0&&item.hasOwnProperty('image')) {tempItem+=" zp-HasImage'>\n";tempItem+="
\n";if(params.zpURLWrap=="image"&&item.data.url!="") {tempItem+="\n";if(params.zpURLWrap=="image"&&item.data.url!="")tempItem+="";tempItem+="
\n"} else{tempItem+="'>\n"} if(jQuery("#"+zp_items.instance+" .ZP_FORCENUM").text().length>0&&jQuery("#"+zp_items.instance+" .ZP_FORCENUM").text()=='1') {if(!/csl-left-margin/i.test(item.bib)) {item.bib=item.bib.replace('
','
'+params.zpForceNumsCount+". ");params.zpForceNumsCount++}} tempItem+=item.bib;if(params.zpShowAbstracts==!0&&(item.data.hasOwnProperty('abstractNote')&&item.data.abstractNote.length>0)) tempItem+="

Abstract: "+item.data.abstractNote+"

\n";if(params.zpShowTags==!0&&(item.data.hasOwnProperty('tags')&&item.data.tags.length>0)) {tempItem+="

Tags: ";jQuery.each(item.data.tags,function(tindex,tag) {tempItem+=""+tag.tag+"";if(tindex!=(item.data.tags.length-1))tempItem+=", "});tempItem+="

\n"} tempItem+="
\n";if(params.zpShowNotes==!0&&item.hasOwnProperty('notes')) tempNotes+=item.notes;if($item_ref.length>0&&update===!0) $item_ref.replaceWith(jQuery(tempItem));else tempItems+=tempItem});if(update===!1) jQuery("#"+zp_items.instance+" .zp-List").append(tempItems);if(params.zpShowNotes==!0&&tempNotes.length>0) {tempNotes="
\n

Notes

\n
    \n"+tempNotes;tempNotes=tempNotes+"
\n
\n\n";jQuery("#"+zp_items.instance).append(tempNotes)} if(jQuery("#"+zp_items.instance+" .zp-List .csl-left-margin").length>0&&(jQuery(".ZP_STYLE",$instance).text().trim().length>0&&jQuery(".ZP_STYLE",$instance).text().trim()!='american-antiquity')) {params.zpForceNumsCount=1;jQuery("#"+zp_items.instance+" .zp-List .csl-left-margin").each(function(index,item) {var item_content=jQuery(item).text();item_content=item_content.replace(item_content.match(/\d+/)[0],params.zpForceNumsCount);jQuery(item).text(item_content);params.zpForceNumsCount++})} zp_bib_reformat($instance,zp_items,params);if(zp_items.meta.request_next!=!1&&zp_items.meta.request_next!="false") {zp_get_items(zp_items.meta.request_next,zp_items.meta.request_last,$instance,params,update)} else{jQuery("#"+zp_items.instance+" .zp-List").removeClass("loading");if(!jQuery("#"+zp_items.instance+" .zp-List").hasClass("updating")) {zp_get_items(0,0,$instance,params,!0)} else{zp_bib_reformat($instance,zp_items,params)}}} else{if(update===!0) {jQuery("#"+$instance.attr("id")+" .zp-List").removeClass("loading");if(jQuery("#"+$instance.attr("id")+" .zp-List .zp-Entry").length==0) jQuery("#"+$instance.attr("id")+" .zp-List").append("

There are no citations to display.

\n")}}}},error:function(errorThrown) {console.log("Zotpress via WP AJAX Error: ",errorThrown)}})} function zp_bib_reformat($instance,zp_items,zp_params) {var sortby=jQuery(".ZP_SORTBY",$instance).text();var orderby=jQuery(".ZP_ORDER",$instance).text();var sortOrder="data-zp-author-date";if(sortby=="date") sortOrder="data-zp-date-author";typicalSort(zp_items,sortby,sortOrder,orderby);if(zp_params.zpTitle!==!1) {var titleSortedEntries={};jQuery("#"+zp_items.instance+" .zp-List div.zp-Entry").each(function(i,entry) {var titleSortType=jQuery(entry).data('zp-'+zp_params.zpTitle);if(titleSortedEntries.hasOwnProperty(titleSortType)===!1) titleSortedEntries[titleSortType]=[];titleSortedEntries[titleSortType].push(jQuery(entry).attr('id'))});var titleSortedEntriesOrder=Object.getOwnPropertyNames(titleSortedEntries);if(zp_params.zpTitle=="itemtype") {var orderedTypes=['book','bookSection','journalArticle','conferencePaper','thesis','report','encyclopediaArticle','newspaperArticle','magazineArticle','presentation','interview'];orderedTypes.slice(0).forEach(function(orderedType,i) {if(titleSortedEntriesOrder.indexOf(orderedType)==-1) orderedTypes.splice(orderedTypes.indexOf(orderedType),1)});titleSortedEntriesOrder=orderedTypes} else{if(orderby=="asc") titleSortedEntriesOrder.sort(function(a,b){return a-b});else titleSortedEntriesOrder.sort(function(a,b){return b-a})} titleSortedEntriesOrder.forEach(function(orderedType,i) {var tempTitle=orderedType;if(zp_params.zpTitle=="itemtype") {if(tempTitle.match(/[A-Z]/)!==null) {var tempPos=tempTitle.match(/[A-Z]/).index;tempTitle=tempTitle.substr(0,tempPos)+' '+tempTitle.substr(tempPos)} tempTitle=tempTitle.charAt(0).toUpperCase()+tempTitle.slice(1)} if(tempTitle=="0000") tempTitle="No date";if(zp_params.zpTitle=="year") {if(jQuery("#"+$instance.attr("id")+" .zp-List h3[rel='"+orderedType+"']").length==0) jQuery("#"+$instance.attr("id")+" .zp-List").append("

"+tempTitle+"

\n")} else if(jQuery("#"+$instance.attr("id")+" .zp-List h3[rel='"+orderedType+"']").length==0) {jQuery("#"+$instance.attr("id")+" .zp-List").append("

"+tempTitle+"

\n")} if(zp_params.zpTitle=="year"&&orderby=="asc") titleSortedEntries[orderedType].reverse();else if(zp_params.zpTitle=="itemtype"&&sortby=="date") titleSortedEntries[orderedType].reverse();titleSortedEntries[orderedType].forEach(function(entryID,i) {jQuery("#"+$instance.attr("id")+" #"+entryID).insertAfter(jQuery("#"+$instance.attr("id")+" .zp-List h3[rel='"+orderedType+"']"))})})}} function typicalSort(zp_items,sortby,sortOrder,orderby) {if(['author','date'].indexOf(sortby)!==-1&&jQuery('#'+zp_items.instance+' .zp-List .csl-left-margin').length==0) {jQuery('#'+zp_items.instance+' .zp-List div.zp-Entry').sort(function(a,b) {var an=a.getAttribute(sortOrder).toLowerCase(),bn=b.getAttribute(sortOrder).toLowerCase();if(an>bn) if(orderby=='asc') return 1;else return-1;else if(an