//showpages function showpages(scrollto=-1) { settabactive("TAB_pages"); htmlpresenter_pages(datastoragepages); if(scrollto==-1) { scrolltobegin("HIDDEN_currentvalue_pages"); } else { let objgoto=document.getElementById("gotoid"); objgoto.value=Number(scrollto); let objhitcount=document.getElementById("hitcount"); let objcurrentvalue=document.getElementById("HIDDEN_currentvalue_pages"); scrolltohit(objgoto,objhitcount,objcurrentvalue) } init_DOMevents(); } function gotopageID(scrollto=-1, gotovalue=-1) { settabactive("TAB_pages"); htmlpresenter_pages(datastoragepages); var newvalue=getvalueinpagesarrayfromtwoindex(ix_pageID,scrollto,ix_pagelistindex); newvalue=Number(newvalue); let objcurrentvalue=document.getElementById("HIDDEN_currentvalue_pages"); objcurrentvalue.value=Number(newvalue); let objgoto=document.getElementById("gotoid"); objgotooldvalue=objgoto.value; objgoto.value=Number(newvalue); let objhitcount=document.getElementById("hitcount"); objhitcount.value=datastoragepages.length; let gotobutton=document.getElementById("hiddengotobutton"); gotobutton.click(); objgoto.value=objgotooldvalue; } function htmlsearchsummary_pages(arrlength) //TODO update også i articles { /*//NB noofhits(total)/noofpageswithhits/noofarticles can be used as a search ratio indicator, the lower the number the less unique the higher, the more unique (IMPORTANT?) ex.1 140 / 74 / 14 = 0,13 26,48 ex 2. 4 / 3 / 2 = 0,66 2,66 ex.3 150 / 56 / 25 = 0,11 66,96 */ var searchstr=getstoredsearchstring(); var noofarticles=countarticlesinarray(datastoragepages);// -see js_data_prepare //writesearchquerytotalsinglehits(g_sumofhitsinarticles); var str1="You searched for: '" + searchstr + "'. Number of hits:" + " "+g_sumofhitsinarticles+" on " + arrlength + " pages in " + noofarticles + " articles." + ""; return str1; } function htmlpresenter_pages(resarray) { var tmpres; var text; var extratext; var obj1=document.getElementById("SEARCHFORM_htmlsummarydiv"); obj1.innerHTML = htmlsearchsummary_pages(resarray.length); //var obj1a=document.getElementById("htmlnavigatepanel"); var obj1a=document.getElementById(navigatepanelpos); obj1a.innerHTML =htmlnavigatepanel_pages_articles(resarray.length); text=''; text+="
"; var obj2=document.getElementById("OUTPUT_div"); obj2.innerHTML = text; var table = document.getElementById("htmlpresenter_pages"); var row; var rowid; for (let i = 0; i < resarray.length; i++) { rowid=i+1; row = table.insertRow(i); row.id=rowid; row.class='resultline'; tmpres=returnhtmlresultline_pages(resarray[i],i); row.innerHTML=tmpres; } extratext=repeatinput("


",100); obj2.innerHTML = obj2.innerHTML +extratext; } function showall(pageid) //Todo { /* get text from arr using page id get all remaining textsnippets and output them with one line break between insert as innerhtml in span tag with id = pageid */ } function addtosearchquerytotalsinglehits(currenttotal,addvalue) { var baseno=currenttotal; var anumber=addvalue; var res=0; if(isNaN(baseno)==true) { baseno=0; } else { res=baseno+Number(anumber); } return res; } function writesearchquerytotalsinglehits(sumtotal) { var obj=document.getElementById('searchquerytotalsinglehits'); if(obj) { obj.innerHTML=sumtotal; } return sumtotal; } function returnhtmlresultline_pages(linearr,index) { var hitcount=index+1; var htmlres=""; var pageID=linearr[ix_pageID]; //line 1 htmlres+=""; var title=linearr[ix_articletitle]; var marginleftvalue=calcmarginleftindex(index+1); htmlres+=""; htmlres+=""; htmlres+=""; //line 2 htmlres+=""; var Authors=linearr[ix_authors]; var author_last_name=returnAuthorLastname(Authors); linearr['author_last_name']=author_last_name; htmlres+=""; htmlres+=""; //line 3 htmlres+=""; var text=linearr[ix_text]; var noofsearchhitsonpage=linearr[ix_noofsearchhitsonpage]; //remove? ["+noofsearchhitsonpage+"] searchquerytotalsinglehits+=linearr[ix_noofsearchhitsonpage]; var searchstring=linearr[ix_searchstring]; var hitsintext=counthitsinstringsimple(searchstring,text); linearr['hitsintext']=hitsintext; var volumeno=linearr[ix_volumeno]; var publication_year=linearr[ix_publication_year]; var pageno_in_volume=linearr[ix_pageno_in_volume]; htmlres+=""; htmlres+="" //line 4 htmlres+=""; var newtext=linearr[ix_newtext]; var htmllink; var hitid; var hitlink=''; if(noofsearchhitsonpage>1) { hitid=linearr[ix_pageID]; /* hitlink=' + '; */ hitlink=' + '; } else { hitlink="
"; } var htmlnewtext=pdfviewerlink(newtext,volumeno,pageno_in_volume,searchstring); htmlres+=""; htmlres+="" //line 5 var ArticleID=linearr[ix_articleID]; var articlehit=linearr[ix_articlelistindex]; //var articlelink=makearticlelink("Article",articlehit); //TODO: articlehit fungerer ikke længere! var articlelink=makearticlelinknew("Article",articlehit,ArticleID); var tmp; htmlres+=""; htmlres+=""; htmlres+="" //line 5.5 DEV var pagetextinformation=returnpageinformation(linearr); htmlres+=""; htmlres+=""; htmlres+="" //line 6 htmlres+=""; htmlres+=""; htmlres+=""; htmlres+="
"+pageID+""+hitcount+"" + title + "
" + Authors + "
["+hitsintext+"] Acta Archaeologica, Volume " + volumeno; htmlres+=", "+publication_year+ ", p."+ pageno_in_volume + "
" + htmlnewtext + "
" + hitlink + "
" + "Page in " + articlelink; //debug start: TODO remove //htmlres+="ArticleID="+ArticleID; //htmlres+=" ix_articleID="+ix_articleID; //htmlres+=" articlehit="+articlehit; //htmlres+=" ix_articlelistindex="+ix_articlelistindex; //htmlres+="
text length="+text.length; //debug end: TODO remove htmlres+="
" + "
" + "" + "

"; htmlres+="
 "+pagetextinformation+""+ "

" + "

" + "

"; htmlres+=""; return htmlres; } function returnAuthorLastname(Authors) { var comma=','; var spacechar=' '; var aut_array; var name_array; var primary_name; var primary_lastname; if(Authors.includes(comma)==true) { aut_array=Authors.split(comma); primary_name=aut_array[0]; } else { primary_name=Authors; } if(primary_name.includes(spacechar)==true) { name_array=primary_name.split(spacechar); primary_lastname=name_array[name_array.length-1]; } else { primary_lastname=primary_name; } return primary_lastname; } function returnpageinformation(linearr) { var text=linearr[ix_text]; var textlength=text.length; var wordarray=text.split(' '); var wordcount=wordarray.length; //hertil kan tilføjes - om siden har illustrationer, data, er en indexside eller indeholder en bibliografi strout="Character count:" + textlength + " - word count:" + wordcount; return strout; } function calculateLix(text) { const sentences = text.split(/[.!?]/).filter(sentence => sentence.trim().length > 0); const sentenceCount = sentences.length; const words = text.split(/\s+/).filter(word => word.trim().length > 0); const wordCount = words.length; const longWordsCount = words.filter(word => word.length >= 6).length; // Calculate LIX score const lixScore = (wordCount / sentenceCount) + ((longWordsCount * 100) / wordCount); return lixScore.toFixed(2); // Return score rounded to 2 decimal places } // Example usage const sampleText = "This is a simple example. It calculates the LIX readability score. Long words are included."; console.log("LIX Score:", calculateLix(sampleText)); /*EOF*/