wizard.js 73 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288
  1. var txtXML="";
  2. var gXmlResList=null;
  3. var gTocList=new Array();//目录信息数组
  4. var gResList=new Array();
  5. var gCurrResIndex=0;
  6. var gResDownloadList = new Array()
  7. var gCurrResListArray=new Array()
  8. var gCurrResListArray2=new Array()
  9. var gTocLanguage = new Array()
  10. var gTocLanguageItem = new Array()
  11. var gTocCurrLanguage="pali";
  12. var gTocCurrRoot = -1;
  13. var gResTypeList = new Array("wbw","translate");
  14. var gCurrQueryResType=0;
  15. var gCurrBookType="";
  16. var gDownloadListString="";
  17. function editor_wizard_next(id){
  18. document.getElementById('wizard_div').style.display="none";
  19. document.getElementById(id).style.display="flex";
  20. if(id=="wizard_div_palicannon"){
  21. wizard_palicannon_init();
  22. }
  23. /*
  24. var xmlHttp=null;
  25. if (window.XMLHttpRequest)
  26. {// code for IE7, Firefox, Opera, etc.
  27. xmlHttp=new XMLHttpRequest();
  28. }
  29. else if (window.ActiveXObject)
  30. {// code for IE6, IE5
  31. xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  32. }
  33. if (xmlHttp!=null)
  34. {
  35. var wizardDir="module/editor_wizard/"
  36. xmlHttp.open("POST", wizardDir+url, false);
  37. xmlHttp.send(data);
  38. document.getElementById('wizard_div').innerHTML = xmlHttp.responseText;
  39. }
  40. else
  41. {
  42. alert("Your browser does not support XMLHTTP.");
  43. }
  44. */
  45. }
  46. function wizard_new_finish(){
  47. var xmlText = txtXML;
  48. var newFileName = new_save(xmlText);
  49. if(newFileName){
  50. window.open("./editor.php?op=open&filename="+newFileName,"_blank");
  51. //window.location.assign("index_new.php");
  52. window.history.back();
  53. }
  54. }
  55. function new_save(strData){
  56. xmlHttp=null;
  57. if (window.XMLHttpRequest)
  58. {// code for IE7, Firefox, Opera, etc.
  59. xmlHttp=new XMLHttpRequest();
  60. var_dump("test XMLHttpRequest<br/>");
  61. }
  62. else if (window.ActiveXObject)
  63. {// code for IE6, IE5
  64. xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  65. var_dump("testing Microsoft.XMLHTTP<br/>");
  66. }
  67. if (xmlHttp!=null)
  68. {
  69. if(g_filename.length==""){
  70. var inputFileName=prompt("Project Name","new project");
  71. if (inputFileName==null || inputFileName==""){
  72. alert("Project Name Can not Empty");
  73. return;
  74. }
  75. else{
  76. g_filename=gConfigDirMydocument+inputFileName+".pcs";
  77. }
  78. }
  79. $.post("./dom_http.php",
  80. {
  81. filename:g_filename,
  82. fileid:0,
  83. xmldata:strData
  84. },
  85. function(data,status){
  86. alert("Data: " + data + "\nStatus: " + status);
  87. });
  88. }
  89. }
  90. function wizard_new_getPaliReal(inStr){
  91. var paliletter="abcdefghijklmnoprstuvyāīūṅñṭḍṇḷṃ";
  92. var output="";
  93. inStr=inStr.toLowerCase();
  94. inStr = inStr.replace(/ṁ/g,"ṃ");
  95. inStr = inStr.replace(/ŋ/g,"ṃ");
  96. for(x in inStr){
  97. if(paliletter.indexOf(inStr[x])!=-1){
  98. output+=inStr[x];
  99. }
  100. }
  101. return(output);
  102. }
  103. function wizard_fileNewPreview(){
  104. try{
  105. var strData = document.getElementById("txtNewInput").value;
  106. var strPar1=new Array()
  107. strPar0=strData.split("\n");
  108. var strPar=new Array()
  109. for(var i=0;i<strPar0.length;i++){//增加層級信息/t分隔
  110. var Line=strPar0[i].split("\t")
  111. var newLine=new Object()
  112. newLine.lvl=Line[0]
  113. newLine.txt=Line[1]
  114. strPar.push(newLine);
  115. }
  116. var strDataTran1 = document.getElementById("txtNewInputTran1").value;
  117. strDataTran1=strDataTran1.replace(/#br#/g,"&lt;br&gt;");
  118. var strParTran1=strDataTran1.split("\n");
  119. var strDataTran2 = document.getElementById("txtNewInputTran2").value;
  120. strDataTran2=strDataTran2.replace(/#br#/g,"&lt;br&gt;");
  121. var strParTran2=strDataTran2.split("\n");
  122. var strWord;
  123. var x;
  124. var iContentStart=0;
  125. var iWordCount=0;
  126. var bookId = com_guid();
  127. txtXML="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
  128. txtXML += "<set>\n"
  129. txtXML += " <head>\n"
  130. txtXML += " <type>pcdsset</type>\n"
  131. txtXML += " <mode>package</mode>\n"
  132. txtXML += " <ver>1</ver>\n"
  133. txtXML += " <toc></toc>\n"
  134. txtXML += " <style></style>\n"
  135. txtXML += " </head>\n"
  136. txtXML += " <dict></dict>\n"
  137. txtXML += " <body>\n"
  138. var txtHtml;
  139. txtHtml = "<div class='sutta'>";
  140. var tranlanguage1 = document.getElementById("tranlanguage1").value;
  141. var tranlanguage2 = document.getElementById("tranlanguage2").value;
  142. var tranAuthor1 = document.getElementById("tranauthor1").value;
  143. var tranAuthor2 = document.getElementById("tranauthor2").value;
  144. var paliAuthor = document.getElementById("paliauthor").value;
  145. if(document.getElementById("chk_title").checked){
  146. //txtXML += "<block>";
  147. //txtXML += "<info><book>"+bookId+"</book><paragraph>1</paragraph><type>heading</type><level>1</level><language>pali</language><author>author</author></info>";
  148. //txtXML += "<data><sen><a></a><text>"+strPar[0]+"</text><sen></data>";
  149. //txtXML += "</block>";
  150. txtXML += "<block>\n";
  151. txtXML += "<info><id>"+com_guid()+"</id><type>heading</type><book>"+bookId+"</book><paragraph>1</paragraph><type>heading</type><level>1</level>"
  152. txtXML += "<language>pali</language>\n";
  153. txtXML += "<author>"+paliAuthor+"</author>\n";
  154. txtXML += "</info>\n";
  155. txtXML += "<data><a></a><text>"+strPar[0].txt+"</text></data>\n";
  156. txtXML += "</block>\n";
  157. if(strDataTran1.length>0){
  158. //txtXML += "<block>";
  159. //txtXML += "<info><type>heading</type><book>"+bookId+"</book><paragraph>1</paragraph><type>heading</type><level>1</level><language>"+tranlanguage1+"</language><author>"+tranAuthor1+"</author></info>";
  160. //txtXML += "<data><sen><a></a><text>"+strParTran1[0]+"</text><sen></data>";
  161. //txtXML += "</block>";
  162. txtXML += "<block>\n";
  163. txtXML += "<info><id>"+com_guid()+"</id><type>heading</type><book>"+bookId+"</book><paragraph>1</paragraph><type>heading</type><level>1</level>"
  164. txtXML += "<language>"+tranlanguage1+"</language>\n";
  165. txtXML += "<author>"+tranAuthor1+"</author>\n";
  166. txtXML += "</info>\n";
  167. txtXML += "<data><a></a><text>"+strParTran1[0]+"</text></data>\n";
  168. txtXML += "</block>\n";
  169. }
  170. if(strDataTran2.length>0){
  171. //txtXML += "<block>";
  172. //txtXML += "<info><type>heading</type><book>"+bookId+"</book><paragraph>1</paragraph><type>heading</type><level>1</level><language>"+tranlanguage2+"</language><author>"+tranAuthor2+"</author></info>";
  173. //txtXML += "<data><sen><a></a><text>"+strParTran2[0]+"</text><sen></data>";
  174. //txtXML += "</block>";
  175. txtXML += "<block>\n";
  176. txtXML += "<info><id>"+com_guid()+"</id><type>heading</type><book>"+bookId+"</book><paragraph>1</paragraph><type>heading</type><level>1</level>"
  177. txtXML += "<language>"+tranlanguage2+"</language>\n";
  178. txtXML += "<author>"+tranAuthor2+"</author>\n";
  179. txtXML += "</info>\n";
  180. txtXML += "<data><a></a><text>"+strParTran2[0]+"</text></data>\n";
  181. txtXML += "</block>\n";
  182. }
  183. iContentStart=1;
  184. txtHtml = txtHtml + "<div class='sutta_title'>\n";
  185. txtHtml = txtHtml + "<h1>" + strPar[0].txt + "</h1>\n";
  186. if(strDataTran1.length>0){
  187. txtHtml = txtHtml + "<p class='tran_h1_"+tranlanguage1+"' >" + strParTran1[0] + "</p>\n";
  188. }
  189. if(strDataTran2.length>0){
  190. txtHtml = txtHtml + "<p class='tran_h1_"+tranlanguage2+"' >" + strParTran2[0] + "</p>\n";
  191. }
  192. txtHtml = txtHtml + "</div>\n";
  193. }
  194. var parCounter=1;
  195. for (var i=iContentStart;i<strPar.length;i++)
  196. {
  197. if(strPar[i].lvl>0){
  198. txtXML += "<block>\n";
  199. txtXML += "<info><id>"+com_guid()+"</id><type>heading</type><book>"+bookId+"</book><paragraph>"+parCounter+"</paragraph><type>heading</type><level>"+strPar[i].lvl+"</level>"
  200. txtXML += "<language>pali</language>\n";
  201. txtXML += "<author>"+paliAuthor+"</author>\n";
  202. txtXML += "</info>\n";
  203. txtXML += "<data><a></a><text>"+strPar[i].txt+"</text></data>\n";
  204. txtXML += "</block>\n";
  205. txtHtml = txtHtml + "<div class='sutta_title'>\n";
  206. txtHtml = txtHtml + "<h1>" + strPar[i].txt + "</h1>\n";
  207. if(strDataTran1.length>0){
  208. //txtXML += "<block>";
  209. //txtXML += "<info><book>"+bookId+"</book><paragraph>1</paragraph><type>heading</type><level>1</level><language>"+tranlanguage1+"</language><author>"+tranAuthor1+"</author></info>";
  210. //txtXML += "<data><sen><a></a><text>"+strParTran1[0]+"</text><sen></data>";
  211. //txtXML += "</block>";
  212. txtXML += "<block>\n";
  213. txtXML += "<info><id>"+com_guid()+"</id><type>heading</type><book>"+bookId+"</book><paragraph>"+parCounter+"</paragraph><type>heading</type><level>"+strPar[i].lvl+"</level>"
  214. txtXML += "<language>"+tranlanguage1+"</language>\n";
  215. txtXML += "<author>"+tranAuthor1+"</author>\n";
  216. txtXML += "</info>\n";
  217. txtXML += "<data><a></a><text>"+strParTran1[i]+"</text></data>\n";
  218. txtXML += "</block>\n";
  219. txtHtml = txtHtml + "<p class='tran_h1_"+tranlanguage1+"' >" + strParTran1[i] + "</p>\n";
  220. }
  221. if(strDataTran2.length>0){
  222. //txtXML += "<block>";
  223. //txtXML += "<info><book>"+bookId+"</book><paragraph>1</paragraph><type>heading</type><level>1</level><language>"+tranlanguage2+"</language><author>"+tranAuthor2+"</author></info>";
  224. //txtXML += "<data><sen><a></a><text>"+strParTran2[0]+"</text><sen></data>";
  225. //txtXML += "</block>";
  226. txtXML += "<block>\n";
  227. txtXML += "<info><id>"+com_guid()+"</id><type>heading</type><book>"+bookId+"</book><paragraph>"+parCounter+"</paragraph><type>heading</type><level>"+strPar[i].lvl+"</level>"
  228. txtXML += "<language>"+tranlanguage2+"</language>\n";
  229. txtXML += "<author>"+tranAuthor2+"</author>\n";
  230. txtXML += "</info>\n";
  231. txtXML += "<data><a></a><text>"+strParTran2[i]+"</text></data>\n";
  232. txtXML += "</block>\n";
  233. txtHtml = txtHtml + "<p class='tran_h1_"+tranlanguage2+"' >" + strParTran2[i] + "</p>\n";
  234. }
  235. txtHtml = txtHtml + "</div>\n";
  236. }
  237. else{
  238. txtHtml = txtHtml + "<div class='sutta_paragraph' >\n";
  239. txtHtml = txtHtml + "<div class='pali_par_mobile'>\n";
  240. txtXML += "<block>\n";
  241. txtXML += "<info><id>"+com_guid()+"</id><book>"+bookId+"</book><paragraph>"+parCounter+"</paragraph><type>wbw</type><language>pali</language><author>author</author></info>";
  242. txtXML += "<data>\n";
  243. strWord = strPar[i].txt.split(" ");
  244. for (var k=0;k<strWord.length;k++){
  245. sPaliWord = strWord[k];
  246. sOrgWord = "?";
  247. sMeanWord = "?";
  248. sCaseWord = "?";
  249. sIdWord = k;
  250. sWordId = iWordCount;/*自动的单词计数器*/
  251. txtXML += "<word><pali>"+sPaliWord+"</pali><real>"+wizard_new_getPaliReal(sPaliWord)+"</real><id>"+sWordId+"</id><mean>?</mean><org>?</org><om>?</om><case>?</case></word>\n";
  252. if(sPaliWord=="#br#"){
  253. txtHtml = txtHtml + "<div class=\"enter\"></div>\n";
  254. }
  255. else{
  256. /*输出Pali单词部分*/
  257. /*长度为1的为标点符号*/
  258. //if(sPaliWord.length<=1)
  259. //{
  260. // txtHtml = txtHtml + "<div id=\"wb"+sWordId+"\" class='word_punc'> ";
  261. // txtHtml = txtHtml + "<p class='pali' name='wPali'> <span name=\"spali\">";
  262. // txtHtml = txtHtml + sPaliWord;
  263. // txtHtml = txtHtml + "</span></p>\n";
  264. //}
  265. //else
  266. {
  267. txtHtml = txtHtml + "<div id=\"wb"+sWordId+"\" class='word'> ";
  268. txtHtml = txtHtml + "<p class='pali' name='wPali'>";
  269. txtHtml = txtHtml +"<a name='w"+sWordId+"' title=\""+sMeanWord+"\" >";
  270. txtHtml = txtHtml + "<span name=\"spali\">"+sPaliWord+"</span>";
  271. txtHtml = txtHtml + "</a></p>\n";
  272. }
  273. /*输出Detail块部分*/
  274. /*设置detail 块可见性。非巴利词不可见*/
  275. txtHtml = txtHtml + "<div id='detail"+sWordId+"' class='bg"+(iWordCount%2)+"'>";
  276. txtHtml = txtHtml + "<span >?</span>"
  277. txtHtml = txtHtml + "</div>";/*detail块结束*/
  278. txtHtml = txtHtml + "</div>\n";/*单词块结束*/
  279. }
  280. iWordCount = iWordCount + 1;
  281. }
  282. txtXML += "</data></block>\n";
  283. txtHtml = txtHtml + "</div>";/*end of pali par*/
  284. txtHtml = txtHtml + "<div class='clr'></div> ";
  285. /*翻译块开始*/
  286. txtHtml = txtHtml + "<div class='tran_par_mobile'>";
  287. if(strDataTran1.length>0){
  288. if(i<strParTran1.length){
  289. var strTranEn = strParTran1[i];
  290. txtHtml = txtHtml + "<p class=tran_par_"+tranlanguage1+">" + strParTran1[i] + "</p>";
  291. txtXML += "<block>\n";
  292. txtXML += "<info><id>"+com_guid()+"</id><book>"+bookId+"</book><paragraph>"+parCounter+"</paragraph><type>translate</type>"
  293. txtXML += "<language>"+tranlanguage1+"</language>\n";
  294. txtXML += "<author>"+document.getElementById("tranauthor1").value+"</author>\n";
  295. txtXML += "</info>\n";
  296. txtXML += "<data><sen><a></a><text>"+strParTran1[i]+"</text></sen></data>\n";
  297. txtXML += "</block>\n";
  298. }
  299. }
  300. if(strDataTran2.length>0){
  301. if(i<strParTran2.length){
  302. var strTranEn = strParTran2[i];
  303. txtHtml = txtHtml + "<p class=tran_par_"+tranlanguage2+">" + strParTran2[i] + "</p>";
  304. txtXML += "<block>\n";
  305. txtXML += "<info><id>"+com_guid()+"</id><book>"+bookId+"</book><paragraph>"+parCounter+"</paragraph><type>translate</type>"
  306. txtXML += "<language>"+tranlanguage2+"</language>\n";
  307. txtXML += "<author>"+document.getElementById("tranauthor2").value+"</author>\n";
  308. txtXML += "</info>\n";
  309. txtXML += "<data><sen><a></a><text>"+strParTran2[i]+"</text></sen></data>\n";
  310. txtXML += "</block>\n";
  311. }
  312. }
  313. txtHtml = txtHtml + "</div>\n";
  314. /*end of translate block*/
  315. txtHtml = txtHtml + "</div>";
  316. /*end of paragraph*/
  317. parCounter++;
  318. }
  319. }
  320. txtHtml = txtHtml + "</div>";
  321. txtXML += " </body>\n"
  322. txtXML += "</set>\n"
  323. document.getElementById("wizard_sutta_preview").innerHTML = txtHtml;
  324. }
  325. catch(e){
  326. alert(e);
  327. }
  328. }
  329. function wizard_show_input(itemId,liTab){
  330. document.getElementById("new_input_pali").style.display="none";
  331. document.getElementById("new_input_Tran1").style.display="none";
  332. document.getElementById("new_input_Tran2").style.display="none";
  333. document.getElementById("NewFilePali").className = "common-tab_li";
  334. document.getElementById("NewFileTran1").className = "common-tab_li";
  335. document.getElementById("NewFileTran2").className = "common-tab_li";
  336. document.getElementById(itemId).style.display="block";
  337. document.getElementById(liTab).className = "common-tab_li_act";
  338. }
  339. function wizard_palicannon_init(){
  340. ntf_init();
  341. document.getElementById("id_wizard_palicannon_index_c2").style.display="none";
  342. document.getElementById("id_wizard_palicannon_index_c3").style.display="none";
  343. document.getElementById("id_wizard_palicannon_index_c4").style.display="none";
  344. document.getElementById("id_wizard_palicannon_index_book").style.display="none";
  345. document.getElementById('wizard_palicannon_par_select_text_body').innerHTML="";
  346. wizard_palicannon_index_render_c1("");
  347. }
  348. function wizard_palicannon_index_render_c1(strSelected){
  349. gCurrBookType=strSelected;
  350. var objC1 = document.getElementById("id_wizard_palicannon_index_c1");
  351. objC1.innerHTML="";
  352. var currStr="";
  353. var list= new Array();
  354. for(index in local_palicannon_index){
  355. pc_pushNewToList(list,local_palicannon_index[index].c1);
  356. }
  357. for(index in list){
  358. if(list[index]==strSelected){
  359. var cssItem="pali_book_item selected";
  360. }
  361. else{
  362. var cssItem="pali_book_item";
  363. }
  364. objC1.innerHTML += "<li class=\""+cssItem+"\" onclick=\"wizard_palicannon_index_changed_c1('"+list[index]+"')\">"+list[index]+"</li>"
  365. }
  366. }
  367. function wizard_palicannon_index_changed_c1(indexSelected){
  368. document.getElementById("id_wizard_palicannon_index_c2").style.display="none";
  369. document.getElementById("id_wizard_palicannon_index_c3").style.display="none";
  370. document.getElementById("id_wizard_palicannon_index_c4").style.display="none";
  371. document.getElementById("id_wizard_palicannon_index_book").style.display="none";
  372. wizard_palicannon_heading_div_cls(1);
  373. wizard_palicannon_palitext_div_cls();
  374. wizard_palicannon_index_render_c1(indexSelected);
  375. wizard_palicannon_index_render_c2(indexSelected,"");
  376. }
  377. function wizard_palicannon_index_render_c2(strParent,strSelected){
  378. var objC2 = document.getElementById("id_wizard_palicannon_index_c2");
  379. strC1=strParent;
  380. objC2.innerHTML="";
  381. var currStr="";
  382. var list= new Array();
  383. for(index in local_palicannon_index){
  384. if(local_palicannon_index[index].c1==strC1){
  385. pc_pushNewToList(list,local_palicannon_index[index].c2);
  386. }
  387. }
  388. for(index in list){
  389. if(list[index]==strSelected){
  390. var cssItem="pali_book_item selected";
  391. }
  392. else{
  393. var cssItem="pali_book_item";
  394. }
  395. objC2.innerHTML += "<div class=\""+cssItem+"\" onclick=\"wizard_palicannon_index_changed_c2('"+strC1+"','"+list[index]+"')\">"+list[index]+"</div>";
  396. }
  397. objC2.style.display="block";
  398. }
  399. function wizard_palicannon_index_changed_c2(strParent,value){
  400. document.getElementById("id_wizard_palicannon_index_c3").style.display="none";
  401. document.getElementById("id_wizard_palicannon_index_c4").style.display="none";
  402. document.getElementById("id_wizard_palicannon_index_book").style.display="none";
  403. wizard_palicannon_heading_div_cls(1);
  404. wizard_palicannon_palitext_div_cls();
  405. //渲染自己 增加选择状态显示
  406. wizard_palicannon_index_render_c2(strParent,value);
  407. //渲染c3
  408. wizard_palicannon_index_render_c3(value,"");
  409. }
  410. function wizard_palicannon_index_render_c3(strParent,strSelected){
  411. var objC3 = document.getElementById("id_wizard_palicannon_index_c3");
  412. strC2=strParent;
  413. objC3.innerHTML="";
  414. var currStr="";
  415. var list= new Array();
  416. for(index in local_palicannon_index){
  417. if(local_palicannon_index[index].c1==strC1 && local_palicannon_index[index].c2==strC2){
  418. if(local_palicannon_index[index].c3!=""){
  419. pc_pushNewToList(list,local_palicannon_index[index].c3);
  420. }
  421. }
  422. }
  423. if(list.length==0){
  424. wizard_palicannon_index_render_book(2,strParent,"");
  425. }
  426. else{
  427. for(index in list){
  428. if(list[index]==strSelected){
  429. var cssItem="pali_book_item selected";
  430. }
  431. else{
  432. var cssItem="pali_book_item";
  433. }
  434. objC3.innerHTML += "<div class=\""+cssItem+"\" onclick=\"wizard_palicannon_index_changed_c3('"+strC2+"','"+list[index]+"')\">"+list[index]+"</div>";
  435. }
  436. objC3.style.display="block";
  437. }
  438. }
  439. function wizard_palicannon_index_changed_c3(strParent,value){
  440. document.getElementById("id_wizard_palicannon_index_c4").style.display="none";
  441. document.getElementById("id_wizard_palicannon_index_book").style.display="none";
  442. wizard_palicannon_heading_div_cls(1);
  443. wizard_palicannon_palitext_div_cls();
  444. //渲染自己 增加选择状态显示
  445. wizard_palicannon_index_render_c3(strParent,value);
  446. var objC4 = document.getElementById("id_wizard_palicannon_index_c4");
  447. strC3=value;
  448. objC4.innerHTML="";
  449. var currStr="";
  450. var list= new Array();
  451. for(index in local_palicannon_index){
  452. if(local_palicannon_index[index].c1==strC1 && local_palicannon_index[index].c2==strC2 && local_palicannon_index[index].c3==strC3){
  453. if(local_palicannon_index[index].c4!=""){
  454. pc_pushNewToList(list,local_palicannon_index[index].c4);
  455. }
  456. }
  457. }
  458. if(list.length==0){
  459. wizard_palicannon_index_render_book(3,value,"");
  460. }
  461. else{
  462. for(index in list){
  463. objC4.innerHTML += "<div class=\"pali_book_item\" onclick=\"wizard_palicannon_index_changed_book('"+list[index]+"')\">"+list[index]+"</div>";
  464. }
  465. }
  466. }
  467. //渲染书章节目录
  468. function wizard_palicannon_index_render_book(parentLevel,strParent,strSelected){
  469. var bookTitle= new Array();
  470. var bookId= new Array();
  471. switch(parentLevel){
  472. case 2:
  473. strC2=strParent;
  474. for(index in local_palicannon_index){
  475. if(local_palicannon_index[index].c1==strC1 && local_palicannon_index[index].c2==strC2){
  476. pc_pushNewToList(bookTitle,local_palicannon_index[index].title);
  477. pc_pushNewToList(bookId,local_palicannon_index[index].id);
  478. }
  479. }
  480. break;
  481. case 3:
  482. strC3=strParent;
  483. for(index in local_palicannon_index){
  484. if(local_palicannon_index[index].c1==strC1 && local_palicannon_index[index].c2==strC2 && local_palicannon_index[index].c3==strC3){
  485. pc_pushNewToList(bookTitle,local_palicannon_index[index].title);
  486. pc_pushNewToList(bookId,local_palicannon_index[index].id);
  487. }
  488. }
  489. break;
  490. case 4:
  491. break;
  492. }
  493. var objBook = document.getElementById("id_wizard_palicannon_index_book");
  494. objBook.innerHTML="";
  495. for(index in bookTitle){
  496. if(bookTitle[index]==strSelected){
  497. var cssItem="pali_book_item selected";
  498. }
  499. else{
  500. var cssItem="pali_book_item";
  501. }
  502. objBook.innerHTML += "<div class=\""+cssItem+"\" onclick=\"wizard_palicannon_index_changed_book("+parentLevel+",'"+strParent+"','"+bookTitle[index]+"','"+bookId[index]+"')\">"+bookTitle[index]+"</div>";
  503. }
  504. document.getElementById("id_wizard_palicannon_index_book").style.display="block";
  505. }
  506. //点击书,显示目录,书籍信息,巴利原文
  507. function wizard_palicannon_index_changed_book(parentLevel,strParent,strBookTitle,strBookId){
  508. gCurrBookTitle=strBookTitle;
  509. gCurrBookId=strBookId;
  510. wizard_palicannon_heading_div_cls(1);
  511. wizard_palicannon_index_render_book(parentLevel,strParent,strBookTitle)
  512. wizard_palicannon_show_filelist(strBookId);
  513. explorer_show_res_list(gCurrBookId,-1);
  514. }
  515. var arrResData=null;
  516. function explorer_res_add_to_list(){
  517. var iCounter=0;
  518. for(i in arrResData){
  519. if(arrResData[i].enable){
  520. pc_res_add_to_download_list(i);
  521. iCounter++;
  522. }
  523. }
  524. ntf_show("添加"+iCounter+"资源到列表");
  525. wizard_save_download_list();
  526. }
  527. function set_res_enable(obj,resIndex){
  528. arrResData[resIndex].enable=obj.checked;
  529. }
  530. //显示资源列表
  531. function explorer_show_res_list(book,para){
  532. $.get("get_res_json.php",
  533. {
  534. book:book,
  535. paragraph:para
  536. },
  537. function(data,status){
  538. try{
  539. arrResData=JSON.parse(data);
  540. }
  541. catch(error){
  542. ntf_show(error+"<br>"+data);
  543. }
  544. var html="";
  545. html += "<input type='checkbox' checked />All";
  546. html += "<ul>";
  547. var resCount=0;
  548. for(var i=0;i<arrResData.length;i++){
  549. arrResData[i].enable=false;
  550. html += "<li>";
  551. if(arrResData[i].type=="share"){
  552. var edit_link="../studio/project.php?op=open&doc_id="+arrResData[i].id;
  553. html += "[share]<a href='"+edit_link+"' target='_blank'>"+arrResData[i].title+"</a>-"+arrResData[i].author;
  554. }
  555. else if(arrResData[i].type=="mydoc"){
  556. var edit_link="../studio/project.php?op=open&doc_id="+arrResData[i].id;
  557. html += "[mydoc]<a href='"+edit_link+"' target='_blank'>"+arrResData[i].title+"</a>-"+arrResData[i].author;
  558. }
  559. else{
  560. arrResData[i].enable=true;
  561. var read_link="../reader/?view=para&book="+arrResData[i].book+"&channal="+arrResData[i].album_id+"&para="+arrResData[i].paragraph;
  562. var check="<input type='checkbox' id='res_check_"+resCount+"' checked onclick=\"set_res_enable(this,"+i+")\" />";
  563. html+=check+"["+arrResData[i].type+"]<a href='"+read_link+"' target='_blank'>"+arrResData[i].title+"</a>-"+arrResData[i].author;
  564. resCount++;
  565. }
  566. html += "</li>";
  567. }
  568. html += "<input type='hidden' id='res_count' value='"+resCount+"' />";
  569. html += "</ul>";
  570. $("#para_res_list").html(html);
  571. });
  572. }
  573. function wizard_palicannon_heading_click(pearent,index){
  574. var currLevel = getNodeText(gXmlParIndex[index],"level");
  575. currLevel++;
  576. wizard_palicannon_heading_div_cls(currLevel);
  577. wizard_palicanon_heading_change(pearent,index);
  578. wizard_palicanon_heading_change(index,-1);
  579. book_res_win_close();//关闭资源小窗口
  580. document.getElementById('wizard_palicannon_par_select_toc').innerHTML=wizard_palicannon_renderBookToc(index);
  581. explorer_show_res_list(gCurrBookId,getNodeText(gXmlParIndex[index],"par"));
  582. }
  583. function wizard_palicannon_heading_div_cls(from){
  584. for(var iPar=from;iPar<=8;iPar++){
  585. document.getElementById("id_wizard_palicannon_book_h"+iPar).innerHTML="";
  586. }
  587. }
  588. function wizard_palicannon_palitext_div_cls(){
  589. document.getElementById("wizard_palicannon_par_select_toc").innerHTML="";
  590. document.getElementById("wizard_palicannon_par_select_text_body").innerHTML="";
  591. document.getElementById("wizard_palicannon_par_select_text_head").style.display="none";
  592. }
  593. //目录改变
  594. function wizard_palicanon_heading_change(base=-1,select=-1){
  595. var output="";
  596. var maxLevel=100;
  597. var endOfPar = wizard_palicanon_get_par_end_index(base);
  598. if(base==-1){
  599. endOfPar = gXmlParIndex.length-1
  600. wizard_palicannon_heading_div_cls(1);
  601. }
  602. else{
  603. var baseLevel = getNodeText(gXmlParIndex[base],"level");
  604. wizard_palicannon_heading_div_cls(baseLevel+1);
  605. }
  606. for(var iPar=base+1;iPar<=endOfPar;iPar++){
  607. parHeadingLevel=getNodeText(gXmlParIndex[iPar],"level");
  608. if(parHeadingLevel>0 && parHeadingLevel<maxLevel){
  609. maxLevel = parHeadingLevel;
  610. }
  611. }
  612. for(var iPar=base+1;iPar<=endOfPar;iPar++){
  613. parHeadingLevel=getNodeText(gXmlParIndex[iPar],"level");
  614. if(parHeadingLevel==maxLevel){
  615. title = getNodeText(gXmlParIndex[iPar],"title");
  616. newTitle=wizard_ger_toc_title(iPar,gTocCurrLanguage);
  617. if(newTitle!=null){
  618. title=newTitle;
  619. }
  620. var cssSelected="";
  621. if(iPar==select){
  622. cssSelected="selected";
  623. }
  624. output += "<div class=\"pali_book_item "+cssSelected+"\" onclick=\"wizard_palicannon_heading_click("+base+","+iPar+")\">"+title+"</div>";
  625. parNum=getNodeText(gXmlParIndex[iPar],"par");
  626. }
  627. }
  628. obj=document.getElementById("id_wizard_palicannon_book_h"+maxLevel);
  629. if(obj){
  630. obj.innerHTML=output;
  631. }
  632. //updata res infomation div
  633. //当改变当前标题时 更新资源列表
  634. wizard_palicannon_updata_res_info(base);
  635. //当改变当前标题时 隐藏不需要显示的巴利文本
  636. wizard_palicanon_updata_pali_text(base);
  637. }
  638. //当改变当前标题时 更新资源列表
  639. function wizard_palicannon_updata_res_info(base=-1){
  640. if(base==-1){
  641. var strTitle = "《"+gCurrBookTitle+"》";
  642. var iParNo = -1;
  643. }
  644. else{
  645. var strTitle = gTocList[base].title;
  646. var iParNo = gTocList[base].parNum;
  647. }
  648. document.getElementById("wizard_palicannon_par_select_text_head_bookname").innerHTML=strTitle;
  649. $("#wizard_palicannon_par_select_text_head_res").html(wizard_palicannon_render_res_list_onepart(base,1));
  650. }
  651. //当改变当前标题时 隐藏不需要显示的巴利文本
  652. function wizard_palicanon_updata_pali_text(base=-1){
  653. if(base==-1){
  654. for(i in gTocList){
  655. parObj=document.getElementById("wizard_pali_par_"+gTocList[i].parNum);
  656. if(parObj){
  657. parObj.style.display="block";
  658. }
  659. }
  660. }
  661. else{
  662. iBegin=base;
  663. iEnd=wizard_palicanon_get_par_end_index(iBegin);
  664. for(var i=0;i<iBegin;i++){
  665. document.getElementById("wizard_pali_par_"+gTocList[i].parNum).style.display="none";
  666. }
  667. for(var i=iBegin;i<=iEnd;i++){
  668. document.getElementById("wizard_pali_par_"+gTocList[i].parNum).style.display="block";
  669. }
  670. if(iEnd<gTocList.length-1){
  671. for(var i=iEnd+1;i<gTocList.length;i++){
  672. document.getElementById("wizard_pali_par_"+gTocList[i].parNum).style.display="none";
  673. }
  674. }
  675. }
  676. }
  677. //当段落没有勾选时变成灰色
  678. function wizard_palicannon_updata_pali_par_text_enable(parNum,enable){
  679. if(document.getElementById("wizard_pali_par_"+parNum)){
  680. if(enable){
  681. document.getElementById("wizard_pali_par_text_"+parNum).style.color="#000";
  682. }
  683. else{
  684. document.getElementById("wizard_pali_par_text_"+parNum).style.color="#d6d6d6";
  685. }
  686. }
  687. }
  688. //从服务器获取书的目录
  689. var wizard_palicannon_xmlhttp;
  690. function wizard_palicannon_show_filelist(strBook){
  691. if (window.XMLHttpRequest)
  692. {// code for IE7+, Firefox, Chrome, Opera, Safari
  693. wizard_palicannon_xmlhttp=new XMLHttpRequest();
  694. }
  695. else
  696. {// code for IE6, IE5
  697. wizard_palicannon_xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  698. }
  699. gCurrSelectedBook=strBook;
  700. var d=new Date();
  701. wizard_palicannon_xmlhttp.onreadystatechange=wizard_palicannon_serverResponse;
  702. wizard_palicannon_xmlhttp.open("GET","./pc_get_book_index.php?t="+d.getTime()+"&book="+strBook,true);
  703. wizard_palicannon_xmlhttp.send();
  704. }
  705. function wizard_palicannon_serverResponse(){
  706. if (wizard_palicannon_xmlhttp.readyState==4)// 4 = "loaded"
  707. {
  708. if (wizard_palicannon_xmlhttp.status==200)
  709. {// 200 = "OK"
  710. var parList="";
  711. var xmlText = wizard_palicannon_xmlhttp.responseText;
  712. if (window.DOMParser)
  713. {
  714. parser=new DOMParser();
  715. xmlBookIndex=parser.parseFromString(xmlText,"text/xml");
  716. }
  717. else // Internet Explorer
  718. {
  719. xmlBookIndex=new ActiveXObject("Microsoft.XMLDOM");
  720. xmlBookIndex.async="false";
  721. xmlBookIndex.loadXML(xmlText);
  722. }
  723. if (xmlBookIndex == null){
  724. alert("error:can not load book index.");
  725. return;
  726. }
  727. //get book TOC array
  728. gXmlParIndex = xmlBookIndex.getElementsByTagName("paragraph");
  729. gTocList=new Array();
  730. for(var iPar=0;iPar<gXmlParIndex.length;iPar++){
  731. tocItem=new Object();
  732. tocItem.book=getNodeText(gXmlParIndex[iPar],"book");
  733. tocItem.parNum=getNodeText(gXmlParIndex[iPar],"par");
  734. tocItem.level=getNodeText(gXmlParIndex[iPar],"level");
  735. tocItem.type=getNodeText(gXmlParIndex[iPar],"class");
  736. tocItem.title=getNodeText(gXmlParIndex[iPar],"title");
  737. tocItem.author=getNodeText(gXmlParIndex[iPar],"author");
  738. tocItem.language=getNodeText(gXmlParIndex[iPar],"language");
  739. tocItem.edition=getNodeText(gXmlParIndex[iPar],"edition");
  740. tocItem.subver=getNodeText(gXmlParIndex[iPar],"subver");
  741. tocItem.enable=true;
  742. tocItem.visible=true;
  743. gTocList.push(tocItem);
  744. }
  745. //目录数组创建结束
  746. book_res_win_close();//关闭资源小窗口
  747. gResList=new Array();
  748. document.getElementById('wizard_palicannon_par_select_toc').innerHTML=wizard_palicannon_renderBookToc();
  749. //获取巴利原文
  750. wizard_palicannon_pali_text_query(gCurrSelectedBook);
  751. wizard_get_toc_from_res();
  752. wizard_palicanon_heading_change();
  753. }
  754. else
  755. {
  756. document.getElementById('id_wizard_palicannon_index_filelist')="Problem retrieving data:" + xmlhttp.statusText;
  757. }
  758. }
  759. }
  760. /*
  761. //添加模板资源到资源列表
  762. function wizard_palicannon_add_res_wbw_templet(){
  763. for(var iPar=0;iPar<gXmlParIndex.length;iPar++){
  764. parHeadingLevel=getNodeText(gXmlParIndex[iPar],"level");
  765. parNum=getNodeText(gXmlParIndex[iPar],"par");
  766. if(parHeadingLevel>0){
  767. var newItem=new Object();
  768. newItem.type="wbw";
  769. newItem.book=getNodeText(gXmlParIndex[iPar],"book");
  770. newItem.parNum=getNodeText(gXmlParIndex[iPar],"par");
  771. newItem.parEnd=wizard_palicannon_get_par_end(newItem.parNum);
  772. newItem.parCurrLoading=newItem.parNum;
  773. newItem.author="templet";
  774. newItem.editor="templet";
  775. newItem.revision="";
  776. newItem.language="com";
  777. newItem.edition="1";
  778. newItem.subver="0";
  779. newItem.title=getNodeText(gXmlParIndex[iPar],"title");
  780. gResList.push(newItem);
  781. }
  782. }
  783. }
  784. //添加模板资源到资源列表
  785. function wizard_palicannon_add_res_toc_templet(){
  786. for(var iPar=0;iPar<gXmlParIndex.length;iPar++){
  787. parHeadingLevel=getNodeText(gXmlParIndex[iPar],"level");
  788. parNum=getNodeText(gXmlParIndex[iPar],"par");
  789. if(parHeadingLevel>0){
  790. var newItem=new Object();
  791. newItem.type="heading";
  792. newItem.book=getNodeText(gXmlParIndex[iPar],"book");
  793. newItem.parNum=getNodeText(gXmlParIndex[iPar],"par");
  794. newItem.parEnd=wizard_palicannon_get_par_end(newItem.parNum);
  795. newItem.parCurrLoading=newItem.parNum;
  796. newItem.author="templet";
  797. newItem.editor="templet";
  798. newItem.revision="";
  799. newItem.language="pali";
  800. newItem.edition="1";
  801. newItem.subver="0";
  802. newItem.title=getNodeText(gXmlParIndex[iPar],"title");
  803. gResList.push(newItem);
  804. }
  805. }
  806. }
  807. */
  808. function wizard_palicannon_nav_level_change(obj){
  809. var iLevle=obj.value;
  810. iLevle++;
  811. wizard_palicannon_nav_level_show(iLevle-1);
  812. }
  813. //渲染书的目录
  814. function wizard_palicannon_renderBookToc(root=-1){
  815. gTocCurrRoot = root;
  816. var output="";
  817. var tocBegin=-1;
  818. var tocEnd=-1;
  819. var beginLevel=1;
  820. if(root==-1){
  821. tocBegin=0;
  822. tocEnd=gTocList.length-1;
  823. }
  824. else{
  825. tocBegin=root;
  826. tocEnd = wizard_palicanon_get_par_end_index(tocBegin);
  827. beginLevel=gTocList[tocBegin].level;
  828. }
  829. //目录上面的层级显示选项
  830. output += "<select onchange=\"wizard_palicannon_nav_level_change(this)\">";
  831. for(var iSelect=beginLevel;iSelect<8;iSelect++){
  832. output += "<option value=\""+iSelect+"\">"+gLocal.gui.level+iSelect+"</option>";
  833. }
  834. output += "<option selected value=\""+8+"\">"+gLocal.gui.level+8+"</option>";
  835. output += "</select>";
  836. //目录上面的语言显示选项
  837. output += "<select onchange=\"wizard_palicannon_nav_language_change(this)\">";
  838. for(var iLanguage=0;iLanguage<gTocLanguage.length;iLanguage++){
  839. if(gTocLanguage[iLanguage]==gTocCurrLanguage){
  840. var isSelect="selected";
  841. }
  842. else{
  843. var isSelect="";
  844. }
  845. output += "<option "+isSelect+" value=\""+gTocLanguage[iLanguage]+"\">"+gTocLanguage[iLanguage]+"</option>";
  846. }
  847. output += "</select>";
  848. //开始生成目录代码
  849. output += "<ul>";
  850. for(var iPar=tocBegin;iPar<=tocEnd;iPar++){
  851. parTitle=gTocList[iPar].title;
  852. parHeadingLevel=gTocList[iPar].level;
  853. parNum=gTocList[iPar].parNum;
  854. if(parTitle==""){
  855. parTitle=parNum;
  856. }
  857. if(parHeadingLevel>=0){
  858. output += "<li class=\"palicannon_nav_level_" + parHeadingLevel + "\" id=\"id_pc_nav_par_"+iPar+"\">";
  859. if(parHeadingLevel>0){
  860. output += "<span id=\"id_pc_nav_ex_"+iPar+"\" class=\"tree_expand_"+parHeadingLevel+"\" onclick=\"tree_co("+iPar+")\">▼</span>"
  861. output += "<span id=\"id_pc_nav_co_"+iPar+"\" class=\"tree_collapse_"+parHeadingLevel+"\" onclick=\"tree_expand("+iPar+")\">▶</span>";
  862. }
  863. //勾选段落有效性 Index
  864. output += "<input id='toc_par_enable_"+iPar+"' onclick='wizard_toc_par_enable(this,"+iPar+")' type=\"checkbox\" checked/>";
  865. if(parHeadingLevel>0){
  866. newTitle=wizard_ger_toc_title(iPar,gTocCurrLanguage);
  867. if(newTitle!=null){
  868. parTitle=newTitle;
  869. }
  870. }
  871. tocLink = "<a href=\"#pali_text_par_"+parNum+"\" class=\"palicannon_nav_item\">" + parTitle +"</a>";
  872. if(parHeadingLevel>0){
  873. output += "<span class=\"tooltip_menu\">"+tocLink+"<span class=\"tooltiptext tooltip_menu-bottom\"><a onclick=\"palicannon_par_toc_reset_root("+iPar+")\">进入</a><a onclick=\"palicannon_par_res_show_window("+iPar+")\">详情</a></span></span> ";
  874. }
  875. else{
  876. output +=tocLink;
  877. }
  878. output += "</li>";
  879. }
  880. }
  881. output += "</ul>";
  882. return output;
  883. }
  884. //目录语言选择
  885. function pc_res_toc_language_change(obj){
  886. }
  887. function add_res_to_doc(resType,parNum){
  888. var iStartPar=0
  889. var iStartLevel=0
  890. for(var iPar=0;iPar<gXmlParIndex.length;iPar++){
  891. currParNum=getNodeText(gXmlParIndex[iPar],"par");
  892. if(currParNum==parNum){
  893. iStartPar=iPar;
  894. iStartLevel=getNodeText(gXmlParIndex[iPar],"level");
  895. break;
  896. }
  897. }
  898. for(var iPar=iStartPar+1;iPar<gXmlParIndex.length;iPar++){
  899. parLevel=getNodeText(gXmlParIndex[iPar],"level");
  900. if(parLevel>0){
  901. if(parLevel <= iStartLevel){
  902. iEndPar=getNodeText(gXmlParIndex[iPar],"par")
  903. palicannon_loadStream(gCurrSelectedBook,parNum,iEndPar)
  904. return;
  905. }
  906. }
  907. }
  908. }
  909. function tree_co(pid){
  910. currLevel=getNodeText(gXmlParIndex[pid],"level");
  911. document.getElementById("id_pc_nav_ex_"+pid).style.display="none"
  912. document.getElementById("id_pc_nav_co_"+pid).style.display="inline"
  913. for(var iPar=pid+1;iPar<gXmlParIndex.length;iPar++){
  914. parHeadingLevel=getNodeText(gXmlParIndex[iPar],"level");
  915. if(parHeadingLevel>0){
  916. if(parHeadingLevel > currLevel){
  917. document.getElementById("id_pc_nav_par_"+iPar).style.display="none"
  918. }
  919. else{
  920. return;
  921. }
  922. }
  923. else{
  924. document.getElementById("id_pc_nav_par_"+iPar).style.display="none"
  925. }
  926. }
  927. }
  928. function tree_expand(pid){
  929. currLevel=getNodeText(gXmlParIndex[pid],"level");
  930. document.getElementById("id_pc_nav_ex_"+pid).style.display="inline"
  931. document.getElementById("id_pc_nav_co_"+pid).style.display="none"
  932. for(var iPar=pid+1;iPar<gXmlParIndex.length;iPar++){
  933. parHeadingLevel=getNodeText(gXmlParIndex[iPar],"level");
  934. if(parHeadingLevel>0){
  935. if(parHeadingLevel > currLevel){
  936. document.getElementById("id_pc_nav_par_"+iPar).style.display="block"
  937. }
  938. else{
  939. return;
  940. }
  941. }
  942. else{
  943. document.getElementById("id_pc_nav_par_"+iPar).style.display="block"
  944. }
  945. }
  946. }
  947. //获取pali原文
  948. var wizard_palicannon_pali_text_xmlhttp;
  949. function wizard_palicannon_pali_text_query(bookId){
  950. if (window.XMLHttpRequest)
  951. {// code for IE7+, Firefox, Chrome, Opera, Safari
  952. wizard_palicannon_pali_text_xmlhttp=new XMLHttpRequest();
  953. }
  954. else
  955. {// code for IE6, IE5
  956. wizard_palicannon_pali_text_xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  957. }
  958. var d=new Date();
  959. wizard_palicannon_pali_text_xmlhttp.onreadystatechange=wizard_palicannon_pali_text_serverResponse;
  960. wizard_palicannon_pali_text_xmlhttp.open("GET","./pc_get_pali_text.php?book="+bookId,true);
  961. wizard_palicannon_pali_text_xmlhttp.send();
  962. }
  963. //获取巴利原文
  964. function wizard_palicannon_pali_text_serverResponse(){
  965. if (wizard_palicannon_pali_text_xmlhttp.readyState==4)// 4 = "loaded"
  966. {
  967. if (wizard_palicannon_pali_text_xmlhttp.status==200)
  968. {// 200 = "OK"
  969. var xmlText = wizard_palicannon_pali_text_xmlhttp.responseText;
  970. $("#wizard_palicannon_par_select_text_body").html(xmlText);
  971. $("#wizard_palicannon_par_select_text_head").show();
  972. $("a[name]").each(function(){
  973. let name = $(this).attr("name");
  974. if(name.slice(0,1)=="M"){
  975. $(this).css("background-color","rgb(255 255 0 / 42%)");
  976. $(this).css("position","absolute");
  977. $(this).css("right","0");
  978. $(this).html(name);
  979. }
  980. });
  981. }
  982. else
  983. {
  984. document.getElementById('wizard_palicannon_par_select_text_body').innerHTML="Problem retrieving data:" + wizard_palicannon_pali_text_xmlhttp.statusText;
  985. }
  986. }
  987. }
  988. /*
  989. //get res list from database
  990. function wizard_palicannon_get_res_list(){
  991. gCurrQueryResType=0;
  992. wizard_palicannon_res_list_query(gResTypeList[gCurrQueryResType],gCurrSelectedBook);
  993. }
  994. //从服务器获取资源列表
  995. var wizard_palicannon_res_xmlhttp;
  996. function wizard_palicannon_res_list_query(resType,bookId){
  997. if (window.XMLHttpRequest)
  998. {// code for IE7+, Firefox, Chrome, Opera, Safari
  999. wizard_palicannon_res_xmlhttp=new XMLHttpRequest();
  1000. }
  1001. else
  1002. {// code for IE6, IE5
  1003. wizard_palicannon_res_xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  1004. }
  1005. var d=new Date();
  1006. var parList=wizard_palicannon_get_par_list();
  1007. wizard_palicannon_res_xmlhttp.onreadystatechange=wizard_palicannon_res_serverResponse;
  1008. wizard_palicannon_res_xmlhttp.open("GET","pc_get_res_list.php?t="+d.getTime()+"&book="+bookId+"&res_type="+resType+"&par_list="+parList,true);
  1009. wizard_palicannon_res_xmlhttp.send();
  1010. }
  1011. //收到资源列表
  1012. function wizard_palicannon_res_serverResponse(){
  1013. if (wizard_palicannon_res_xmlhttp.readyState==4)// 4 = "loaded"
  1014. {
  1015. if (wizard_palicannon_res_xmlhttp.status==200)
  1016. {// 200 = "OK"
  1017. var parList="";
  1018. var xmlText = wizard_palicannon_res_xmlhttp.responseText;
  1019. if (window.DOMParser)
  1020. {
  1021. parser=new DOMParser();
  1022. xmlBookRes=parser.parseFromString(xmlText,"text/xml");
  1023. }
  1024. else // Internet Explorer
  1025. {
  1026. xmlBookRes=new ActiveXObject("Microsoft.XMLDOM");
  1027. xmlBookRes.async="false";
  1028. xmlBookRes.loadXML(xmlText);
  1029. }
  1030. if (xmlBookRes == null){
  1031. alert("error:can not load book res.");
  1032. return;
  1033. }
  1034. gXmlResList = xmlBookRes.getElementsByTagName("res");
  1035. add_new_res_list(gXmlResList);
  1036. //如果还有等待加载的资源 继续加载
  1037. if(gCurrQueryResType<gResTypeList.length-1){
  1038. gCurrQueryResType++;
  1039. wizard_palicannon_res_list_query(gResTypeList[gCurrQueryResType],gCurrSelectedBook);
  1040. }
  1041. else{
  1042. //如果没有了 显示资源列表
  1043. //wizard_palicannon_render_res_list();
  1044. wizard_get_toc_from_res();
  1045. document.getElementById('wizard_palicannon_par_select_toc').innerHTML=wizard_palicannon_renderBookToc(gTocCurrRoot);
  1046. }
  1047. }
  1048. else
  1049. {
  1050. document.getElementById('id_wizard_palicannon_index_filelist')="Problem retrieving data:" + xmlhttp.statusText;
  1051. }
  1052. }
  1053. }
  1054. */
  1055. //添加新的资源 到 内存数组
  1056. function add_new_res_list(xNewList){
  1057. for(var iItem=0;iItem<xNewList.length;iItem++){
  1058. var newItem=new Object();
  1059. newItem.type=getNodeText(xNewList[iItem],"type");
  1060. newItem.book=getNodeText(xNewList[iItem],"book");
  1061. newItem.parNum=getNodeText(xNewList[iItem],"par");
  1062. newItem.parEnd=wizard_palicannon_get_par_end(newItem.parNum);
  1063. newItem.parCurrLoading=newItem.parNum;
  1064. newItem.author=getNodeText(xNewList[iItem],"author");
  1065. newItem.editor=getNodeText(xNewList[iItem],"editor");
  1066. newItem.revision=getNodeText(xNewList[iItem],"revision");
  1067. newItem.language=getNodeText(xNewList[iItem],"language");
  1068. newItem.edition=getNodeText(xNewList[iItem],"edition");
  1069. newItem.subver=getNodeText(xNewList[iItem],"subver");
  1070. newItem.text=getNodeText(xNewList[iItem],"text");
  1071. newItem.title=getNodeText(xNewList[iItem],"text");
  1072. gResList.push(newItem);
  1073. }
  1074. }
  1075. function wizard_palicannon_get_par_list(){
  1076. var output="";
  1077. for(var iPar=0;iPar<gXmlParIndex.length;iPar++){
  1078. parTitle=getNodeText(gXmlParIndex[iPar],"title");
  1079. parHeadingLevel=getNodeText(gXmlParIndex[iPar],"level");
  1080. parNum=getNodeText(gXmlParIndex[iPar],"par");
  1081. if(parHeadingLevel>0){
  1082. output+=parNum+","
  1083. }
  1084. }
  1085. return(output.slice(0,-1))
  1086. }
  1087. //获取段落终止点
  1088. //输入:索引
  1089. //输出:索引
  1090. function wizard_palicanon_get_par_end_index(beginIndex){
  1091. var iStartPar=0
  1092. var iStartLevel=0
  1093. if(beginIndex==-1){
  1094. return(gTocList.length-1);
  1095. }
  1096. if(gTocList[beginIndex].level==0){
  1097. return(beginIndex);
  1098. }
  1099. for(var iPar=beginIndex+1;iPar<gTocList.length;iPar++){
  1100. parLevel=gTocList[iPar].level;
  1101. if(parLevel>0){
  1102. if(parLevel <= gTocList[beginIndex].level){
  1103. return(iPar-1);
  1104. }
  1105. }
  1106. }
  1107. //没找到 返回数组最后一个索引号
  1108. return(gTocList.length-1);
  1109. }
  1110. function wizard_palicannon_get_par_end(beginParNum){
  1111. var iStartPar=0
  1112. var iStartLevel=0
  1113. for(var iPar=0;iPar<gTocList.length;iPar++){
  1114. currParNum=gTocList[iPar].parNum;
  1115. if(currParNum==beginParNum){
  1116. iStartPar=iPar;
  1117. break;
  1118. }
  1119. }
  1120. var iEnd = wizard_palicanon_get_par_end_index(iStartPar);
  1121. /*
  1122. for(var iPar=iStartPar+1;iPar<gXmlParIndex.length;iPar++){
  1123. parLevel=getNodeText(gXmlParIndex[iPar],"level");
  1124. if(parLevel>0){
  1125. if(parLevel <= iStartLevel){
  1126. //iEndPar=getNodeText(gXmlParIndex[iPar],"par")
  1127. return(iPar-1);
  1128. }
  1129. }
  1130. }
  1131. return(gXmlParIndex.length-1);
  1132. */
  1133. return(gTocList[iEnd].parNum);
  1134. }
  1135. function book_res_edit_now(resWin){
  1136. var resNum = book_res_add_to_list(resWin);
  1137. if(resNum>0){
  1138. open_editor_load_stream();
  1139. }
  1140. }
  1141. //加入到下载列表
  1142. //resWin=1 主列表 resWin=2 浮动列表
  1143. function book_res_add_to_list(resWin){
  1144. var iCounter=0;
  1145. switch(resWin){
  1146. case 1:
  1147. currList=gCurrResListArray;
  1148. break;
  1149. case 2: //for float windows
  1150. currList=gCurrResListArray2;
  1151. break;
  1152. default:
  1153. return;
  1154. }
  1155. if(currList){
  1156. for(i in currList){
  1157. if(currList[i].enable){
  1158. pc_res_add_to_download_list(currList[i].res);
  1159. iCounter++;
  1160. }
  1161. }
  1162. }
  1163. return(iCounter);
  1164. }
  1165. function pali_canon_edit_now(thisform)
  1166. {
  1167. var download_res_data=new Array();
  1168. for(i in arrResData){
  1169. if(arrResData[i].enable){
  1170. var resDownloadItem=new Object();
  1171. resDownloadItem.album_id=arrResData[i].album_id;
  1172. resDownloadItem.type=arrResData[i].type;
  1173. resDownloadItem.book=arrResData[i].book;
  1174. resDownloadItem.parNum=arrResData[i].paragraph;
  1175. resDownloadItem.author=arrResData[i].author;
  1176. resDownloadItem.editor=arrResData[i].editor;
  1177. resDownloadItem.language=arrResData[i].language;
  1178. resDownloadItem.edition=arrResData[i].edition;
  1179. resDownloadItem.version=arrResData[i].version;
  1180. resDownloadItem.title=arrResData[i].title;
  1181. var strParList="";
  1182. var firstIndex=-1;
  1183. var firstLevel=-1;
  1184. var endIndex=-1
  1185. //计算段落区间
  1186. for(var iPar=0;iPar<gTocList.length;iPar++){
  1187. if(resDownloadItem.parNum==gTocList[iPar].parNum){
  1188. firstIndex=iPar;
  1189. firstLevel=gTocList[iPar].level;
  1190. break;
  1191. }
  1192. }
  1193. for(var iPar=firstIndex+1;iPar<gTocList.length;iPar++){
  1194. var newLevel=gTocList[iPar].level;
  1195. if(newLevel>0 && newLevel<=firstLevel){
  1196. endIndex=iPar-1;
  1197. break;
  1198. }
  1199. }
  1200. if(firstIndex==-1){
  1201. return;
  1202. }
  1203. if(endIndex==-1){
  1204. endIndex=gTocList.length-1;
  1205. }
  1206. //查找被选择的段落
  1207. for(var iPar=firstIndex;iPar<=endIndex;iPar++){
  1208. if(gTocList[iPar].enable){
  1209. strParList+=gTocList[iPar].parNum;
  1210. if(iPar<endIndex){
  1211. strParList += ",";
  1212. }
  1213. }
  1214. }
  1215. resDownloadItem.parlist=strParList;
  1216. download_res_data.push(resDownloadItem);
  1217. }
  1218. }
  1219. if(download_res_data.length>0){
  1220. $("#project_new_res_data").val(JSON.stringify(download_res_data));
  1221. return true;
  1222. }
  1223. else{
  1224. return false;
  1225. }
  1226. }
  1227. //勾选资源项目
  1228. //resWin=1 主列表 resWin=2 浮动列表
  1229. function setResEnable(obj,index,resWin){
  1230. switch(resWin){
  1231. case 1:
  1232. gCurrResListArray[index].enable=obj.checked;
  1233. break;
  1234. case 2: //for float windows
  1235. gCurrResListArray2[index].enable=obj.checked;
  1236. break;
  1237. default:
  1238. return;
  1239. }
  1240. }
  1241. //渲染资源内容
  1242. //resWin=1 主列表 resWin=2 浮动列表
  1243. function wizard_palicannon_render_res_list_onepart(parIndex,resWin){
  1244. if(parIndex>=0){
  1245. var parNo=gTocList[parIndex].parNum;
  1246. var paraEndIndex=wizard_palicanon_get_par_end_index(parIndex);
  1247. var parNumber=gTocList[paraEndIndex].parNum-gTocList[parIndex].parNum+1;
  1248. }
  1249. else{
  1250. var parNo=-1;
  1251. var parNumber=0;
  1252. }
  1253. switch(resWin){
  1254. case 1:
  1255. gCurrResListArray=new Array();
  1256. break;
  1257. case 2: //for float windows
  1258. gCurrResListArray2=new Array();
  1259. break;
  1260. default:
  1261. return;
  1262. }
  1263. var iResCounter=0;
  1264. var output="<div class=\"resouse_info\">";
  1265. output += "</div>";
  1266. output += "<div class=\"chapter_info\">"+gLocal.gui.statistical_data+"<br/>";
  1267. output += "<span style=\"width: 12em;\">"+gLocal.gui.totally+parNumber+gLocal.gui.para+"</span><br/>";
  1268. output += "<span style=\"width: 12em;\">"+gLocal.gui.wordnum+"</span><span id=\"pc_res_par_word_num\"></span><br/>";
  1269. output += "<span style=\"width: 12em;\">"+gLocal.gui.vocabulary+"</span><span id=\"pc_res_par_vocabulary\"></span><br/>";
  1270. output += "<span style=\"width: 12em;\">"+gLocal.gui.word_length+":</span><span id=\"pc_res_par_word_length\"></span><br/>";
  1271. output += "<span style=\"width: 12em;\">"+gLocal.gui.repeat+"</span><span id=\"pc_res_par_quotiety\"></span><br/>";
  1272. output += "</div>";
  1273. output += "<div class=\"chapter_info\" style='margin-right:0'>"+gLocal.gui.workload+"<br/>";
  1274. output += "<span style=\"width: 12em;\">"+gLocal.gui.tran_workload+"</span><span id=\"pc_res_par_tran_workload\"></span><br/>";
  1275. output += "<span style=\"width: 12em;\">"+gLocal.gui.wbw+":</span><span id=\"pc_res_par_wbw_workload\"></span><br/>";
  1276. output += "<span style=\"width: 12em;\">"+gLocal.gui.total_workload+":</span><span id=\"pc_res_par_total_workload\"></span><br/>";
  1277. output += "<span style=\"width: 12em;\">"+gLocal.gui.product+":</span><span id=\"pc_res_par_product\"></span><br/>";
  1278. output += "<span style=\"width: 12em;\">"+gLocal.gui.difficulty+":</span><span id=\"pc_res_par_difficulty\"></span>";
  1279. output += "</div>";
  1280. if(parIndex>=0){
  1281. wizard_palicannon_res_word_num_query(gTocList[parIndex].book,gTocList[parIndex].parNum,gTocList[wizard_palicanon_get_par_end_index(parIndex)].parNum);
  1282. }
  1283. else{
  1284. wizard_palicannon_res_word_num_query(gTocList[0].book,0,-1);
  1285. }
  1286. return(output);
  1287. }
  1288. //添加新的资源到下载列表
  1289. function pc_res_add_to_download_list(resIndex)
  1290. {
  1291. set_pali_loader_visible(true);
  1292. var resDownloadItem=new Object();
  1293. resDownloadItem.album_id=arrResData[resIndex].album_id;
  1294. resDownloadItem.resIndex=resIndex;
  1295. resDownloadItem.res=arrResData[resIndex].type;
  1296. resDownloadItem.type=arrResData[resIndex].type;
  1297. resDownloadItem.book=arrResData[resIndex].book;
  1298. resDownloadItem.parNum=arrResData[resIndex].paragraph;
  1299. resDownloadItem.parEnd = 0;
  1300. resDownloadItem.author=arrResData[resIndex].author;
  1301. resDownloadItem.editor=arrResData[resIndex].editor;
  1302. resDownloadItem.revision=1;
  1303. resDownloadItem.language=arrResData[resIndex].language;
  1304. resDownloadItem.edition=arrResData[resIndex].edition;
  1305. resDownloadItem.subver=1;
  1306. resDownloadItem.title=arrResData[resIndex].title;
  1307. var strParList="";
  1308. var firstIndex=-1;
  1309. var firstLevel=-1;
  1310. var endIndex=-1
  1311. //计算段落区间
  1312. for(var iPar=0;iPar<gTocList.length;iPar++){
  1313. if(resDownloadItem.parNum==gTocList[iPar].parNum){
  1314. firstIndex=iPar;
  1315. firstLevel=gTocList[iPar].level;
  1316. break;
  1317. }
  1318. }
  1319. for(var iPar=firstIndex+1;iPar<gTocList.length;iPar++){
  1320. var newLevel=gTocList[iPar].level;
  1321. if(newLevel>0 && newLevel<=firstLevel){
  1322. endIndex=iPar-1;
  1323. break;
  1324. }
  1325. }
  1326. if(firstIndex==-1){
  1327. return;
  1328. }
  1329. if(endIndex==-1){
  1330. endIndex=gTocList.length-1;
  1331. }
  1332. //查找被选择的段落
  1333. for(var iPar=firstIndex;iPar<=endIndex;iPar++){
  1334. if(gTocList[iPar].enable){
  1335. strParList+=gTocList[iPar].parNum;
  1336. if(iPar<endIndex){
  1337. strParList += ",";
  1338. }
  1339. }
  1340. }
  1341. resDownloadItem.parlist=strParList;
  1342. //查询是否有重复
  1343. var isInList=false;
  1344. for(i in gResDownloadList){
  1345. if(gResDownloadList[i].parNum==resDownloadItem.parNum && gResDownloadList[i].album_id==resDownloadItem.album_id ){
  1346. isInList = true;
  1347. break;
  1348. }
  1349. }
  1350. //无重复 加载
  1351. if(!isInList){
  1352. gResDownloadList.push(resDownloadItem);
  1353. pc_res_updata_download_list();
  1354. }
  1355. }
  1356. function remove_pc_res_download_list_cookie(){
  1357. gDownloadListString="";
  1358. setCookie("loadlist","","1");
  1359. }
  1360. function add_pc_res_download_list_to_cookie(){
  1361. var cookieString = "{\"loadlist\": [";
  1362. for(i in gResDownloadList){
  1363. cookieString += "{";
  1364. cookieString += "\"resIndex\":\""+gResDownloadList[i].resIndex+"\" ,";
  1365. cookieString += "\"res\":\""+gResDownloadList[i].res+"\" ,";
  1366. cookieString += "\"book\":\""+gResDownloadList[i].book+"\" ,";
  1367. cookieString += "\"parNum\":\""+gResDownloadList[i].parNum+"\" ,";
  1368. cookieString += "\"parEnd\":\""+gResDownloadList[i].parEnd+"\" ,";
  1369. cookieString += "\"author\":\""+gResDownloadList[i].author+"\" ,";
  1370. cookieString += "\"editor\":\""+gResDownloadList[i].editor+"\" ,";
  1371. cookieString += "\"revision\":\""+gResDownloadList[i].revision+"\" ,";
  1372. cookieString += "\"language\":\""+gResDownloadList[i].language+"\" ,";
  1373. cookieString += "\"edition\":\""+gResDownloadList[i].edition+"\" ,";
  1374. cookieString += "\"subver\":\""+gResDownloadList[i].subver+"\" ,";
  1375. cookieString += "\"parlist\":\""+gResDownloadList[i].parlist+"\" ,";
  1376. cookieString += "\"title\":\""+gResDownloadList[i].title+"\"";
  1377. cookieString += "}";
  1378. if(i<gResDownloadList.length-1){
  1379. cookieString += ",";
  1380. }
  1381. }
  1382. cookieString += "]}";
  1383. gDownloadListString=cookieString;
  1384. setCookie("loadlist",cookieString,"1");
  1385. }
  1386. function get_pc_res_download_list_from_cookie(){
  1387. var resListString=getCookie("loadlist");
  1388. objCookieLoadList = JSON.parse(resListString);
  1389. ntf_show(resListString);
  1390. gResDownloadList = new Array();
  1391. for(i in objCookieLoadList.loadlist){
  1392. gResDownloadList.push(objCookieLoadList.loadlist[i]);
  1393. }
  1394. pc_res_updata_download_list();
  1395. }
  1396. function get_pc_res_download_list_from_string(strDownload){
  1397. objCookieLoadList = JSON.parse(strDownload);
  1398. //debugOutput(resListString);
  1399. gResDownloadList = new Array();
  1400. for(i in objCookieLoadList.loadlist){
  1401. gResDownloadList.push(objCookieLoadList.loadlist[i]);
  1402. }
  1403. pc_res_updata_download_list();
  1404. }
  1405. //显示资源预览
  1406. function pc_res_preview(resIndex){
  1407. res=gResList[resIndex].type;
  1408. book=gResList[resIndex].book;
  1409. thisParNum=gResList[resIndex].parNum;
  1410. thisParEnd = gResList[resIndex].parEnd;
  1411. author=gResList[resIndex].author;
  1412. editor=gResList[resIndex].editor;
  1413. revision=gResList[resIndex].revision;
  1414. language=gResList[resIndex].language;
  1415. edition=gResList[resIndex].edition;
  1416. subver=gResList[resIndex].subver;
  1417. var link="./pc_get_res_preview.php?res_type="+res+"&book="+book+"&begin="+thisParNum+"&end="+thisParEnd+"&author="+author+"&editor="+editor+"&revision="+revision+"&language="+language+"&edition="+edition+"&subver="+subver;
  1418. return(link);
  1419. }
  1420. //删除加载列表中的一项
  1421. function pc_resListRemove(indexDelete){
  1422. gResDownloadList.splice(indexDelete,1);
  1423. pc_res_updata_download_list();
  1424. wizard_save_download_list();
  1425. }
  1426. //清空购物车
  1427. function pc_empty_download_list(){
  1428. gResDownloadList=new Array();
  1429. pc_res_updata_download_list();
  1430. wizard_save_download_list();
  1431. }
  1432. function pc_resListMove(moveFrom,moveTo){
  1433. if(moveTo<0){
  1434. moveTo=0;
  1435. }
  1436. if(moveFrom==moveTo){
  1437. return;
  1438. }
  1439. var temp=gResDownloadList[moveTo];
  1440. gResDownloadList[moveTo]=gResDownloadList[moveFrom];
  1441. for(i=moveFrom-1;i>moveTo;i--){
  1442. gResDownloadList[i+1]=gResDownloadList[i];
  1443. }
  1444. gResDownloadList[moveTo+1]=temp;
  1445. pc_res_updata_download_list();
  1446. wizard_save_download_list();
  1447. }
  1448. function getBookTitleById(bookId){
  1449. for(index in local_palicannon_index){
  1450. if(local_palicannon_index[index].id==bookId){
  1451. return(local_palicannon_index[index].title)
  1452. }
  1453. }
  1454. return("");
  1455. }
  1456. function pc_res_updata_download_list(){
  1457. var resListString=""
  1458. for(var iRes=0;iRes<gResDownloadList.length;iRes++){
  1459. var type=gResDownloadList[iRes].type;
  1460. var book=gResDownloadList[iRes].book;
  1461. var parNum=gResDownloadList[iRes].parNum;
  1462. var parEnd=gResDownloadList[iRes].parEnd;
  1463. var author=gResDownloadList[iRes].author;
  1464. var editor=gResDownloadList[iRes].editor;
  1465. var revision=gResDownloadList[iRes].revision;
  1466. var language=gResDownloadList[iRes].language;
  1467. var edition=gResDownloadList[iRes].edition;
  1468. var subver=gResDownloadList[iRes].subver;
  1469. var title=gResDownloadList[iRes].title;
  1470. var paraList=gResDownloadList[iRes].parlist;
  1471. var parCount=paraList.split().length;
  1472. resListString += "<div class=\"res_item\">"
  1473. resListString += " <table>"
  1474. resListString += " <tr>"
  1475. resListString += " <td class=\"tool_bar\">"
  1476. resListString += " <p class=\"res_button\" onclick=\"pc_resListMove("+iRes+","+(iRes-1)+")\">▲</p>"
  1477. resListString += " <p class=\"res_type\" >W</p>"
  1478. resListString += " <p class=\"res_button\" onclick=\"pc_resListRemove("+iRes+")\">"
  1479. resListString += " <svg id=\"icon_Edit_Dialog_on\" style=\"display:block;\" class=\"icon\">"
  1480. resListString += " <use xmlns:xlink=\"http://www.w3.org/1999/xlink\" xlink:href=\"svg/icon.svg#ic_remove_shopping_cart\"></use>"
  1481. resListString += " </svg>"
  1482. resListString += " </p>"
  1483. resListString += " </td>"
  1484. resListString += " <td class=\"res_info\" >"
  1485. resListString += " <div class=\"res_info_1\"><span class=\"book_name\">"+gCurrBookType+"-《"+getBookTitleById("p"+book)+"》</span><br/>";
  1486. resListString += " <span class=\"chapter\">"+title+"|</span><span class=\"author\">"+gLocal.gui.translate1+author+"</span></div>"
  1487. resListString += " <div class=\"res_info_2\">|"+"<span>"+local_media_type[type]+"</span>|"+gLocal.gui.language+language+"|"+gLocal.gui.totally+parCount+gLocal.gui.para+"|"+gLocal.gui.edit1+editor+"|"+gLocal.gui.revision+revision+"|"+gLocal.gui.edition+edition+"|</div>"
  1488. resListString += " </td>"
  1489. resListString += " </tr>"
  1490. resListString += " </table>"
  1491. resListString += "<canvas class=\"res_load_progress_canvas\" id=\"book_res_load_progress_canvas_"+iRes+"\" width='300' height='5'></canvas>"
  1492. resListString += "</div>"
  1493. }
  1494. document.getElementById("pc_res_list_div").innerHTML=resListString;
  1495. add_pc_res_download_list_to_cookie();
  1496. if(gResDownloadList && gResDownloadList.length>0){
  1497. if(obj=document.getElementById("id_open_editor_load_stream")){obj.disabled=false;}
  1498. if(obj=document.getElementById("id_append_stream")){obj.disabled=false;}
  1499. if(obj=document.getElementById("pc_empty_download_list")){obj.disabled=false;}
  1500. if(obj=document.getElementById("id_cancel_stream")){obj.disabled=false;}
  1501. }
  1502. else{
  1503. if(obj=document.getElementById("id_open_editor_load_stream")){obj.disabled=true;}
  1504. if(obj=document.getElementById("id_append_stream")){obj.disabled=true;}
  1505. if(obj=document.getElementById("pc_empty_download_list")){obj.disabled=true;}
  1506. if(obj=document.getElementById("id_cancel_stream")){obj.disabled=true;}
  1507. }
  1508. }
  1509. function wizard_palicannon_nav_level_show(showLevel){
  1510. getStyleClass('palicannon_nav_level_0').style.display="none";
  1511. getStyleClass('palicannon_nav_level_1').style.display="none";
  1512. getStyleClass('palicannon_nav_level_2').style.display="none";
  1513. getStyleClass('palicannon_nav_level_3').style.display="none";
  1514. getStyleClass('palicannon_nav_level_4').style.display="none";
  1515. getStyleClass('palicannon_nav_level_5').style.display="none";
  1516. getStyleClass('palicannon_nav_level_6').style.display="none";
  1517. getStyleClass('palicannon_nav_level_7').style.display="none";
  1518. getStyleClass('palicannon_nav_level_8').style.display="none";
  1519. switch(showLevel){
  1520. case 0:
  1521. getStyleClass('palicannon_nav_level_0').style.display="block";
  1522. //getStyleClass('tree_expand_0').style.display="inline";
  1523. //getStyleClass('tree_collapse_0').style.display="none";
  1524. case 8:
  1525. getStyleClass('palicannon_nav_level_8').style.display="block";
  1526. getStyleClass('tree_expand_8').style.display="inline";
  1527. getStyleClass('tree_collapse_8').style.display="none";
  1528. case 7:
  1529. getStyleClass('palicannon_nav_level_7').style.display="block";
  1530. getStyleClass('tree_expand_7').style.display="inline";
  1531. getStyleClass('tree_collapse_7').style.display="none";
  1532. case 6:
  1533. getStyleClass('palicannon_nav_level_6').style.display="block";
  1534. getStyleClass('tree_expand_6').style.display="inline";
  1535. getStyleClass('tree_collapse_6').style.display="none";
  1536. case 5:
  1537. getStyleClass('palicannon_nav_level_5').style.display="block";
  1538. getStyleClass('tree_expand_5').style.display="none";
  1539. getStyleClass('tree_collapse_5').style.display="inline";
  1540. case 4:
  1541. getStyleClass('palicannon_nav_level_4').style.display="block";
  1542. getStyleClass('tree_expand_4').style.display="inline";
  1543. getStyleClass('tree_collapse_4').style.display="none";
  1544. case 3:
  1545. getStyleClass('palicannon_nav_level_3').style.display="block";
  1546. getStyleClass('tree_expand_3').style.display="inline";
  1547. getStyleClass('tree_collapse_3').style.display="none";
  1548. case 2:
  1549. getStyleClass('palicannon_nav_level_2').style.display="block";
  1550. getStyleClass('tree_expand_2').style.display="inline";
  1551. getStyleClass('tree_collapse_2').style.display="none";
  1552. case 1:
  1553. getStyleClass('palicannon_nav_level_1').style.display="block";
  1554. getStyleClass('tree_expand_1').style.display="inline";
  1555. getStyleClass('tree_collapse_1').style.display="none";
  1556. }
  1557. switch(showLevel){
  1558. case 8:
  1559. getStyleClass('tree_expand_8').style.display="none";
  1560. getStyleClass('tree_collapse_8').style.display="inline";
  1561. break;
  1562. case 7:
  1563. getStyleClass('tree_expand_7').style.display="none";
  1564. getStyleClass('tree_collapse_7').style.display="inline";
  1565. break;
  1566. case 6:
  1567. getStyleClass('tree_expand_6').style.display="none";
  1568. getStyleClass('tree_collapse_6').style.display="inline";
  1569. break;
  1570. case 5:
  1571. getStyleClass('tree_expand_5').style.display="none";
  1572. getStyleClass('tree_collapse_5').style.display="inline";
  1573. break;
  1574. case 4:
  1575. getStyleClass('tree_expand_4').style.display="none";
  1576. getStyleClass('tree_collapse_4').style.display="inline";
  1577. break;
  1578. case 3:
  1579. getStyleClass('tree_expand_3').style.display="none";
  1580. getStyleClass('tree_collapse_3').style.display="inline";
  1581. break;
  1582. case 2:
  1583. getStyleClass('tree_expand_2').style.display="none";
  1584. getStyleClass('tree_collapse_2').style.display="inline";
  1585. break;
  1586. case 1:
  1587. getStyleClass('tree_expand_1').style.display="none";
  1588. getStyleClass('tree_collapse_1').style.display="inline";
  1589. break;
  1590. }
  1591. }
  1592. //
  1593. /*
  1594. * 在服务器端保存下载列表
  1595. * public
  1596. * @param
  1597. */
  1598. function wizard_save_download_list(){
  1599. var strDownload = JSON.stringify(gResDownloadList);
  1600. $.post("./user_file.php",
  1601. {
  1602. op:"save",
  1603. filename:"dl.json",
  1604. data:strDownload
  1605. },
  1606. function(data,status){
  1607. ntf_show("Data: " + data + "\nStatus: " + status);
  1608. });
  1609. }
  1610. //载入编辑列表
  1611. function open_editor_load_stream(){
  1612. window.open("project.php?op=create","_blank");
  1613. }
  1614. /*
  1615. * load paragraph from database
  1616. * public
  1617. * @param book(string) book GUID
  1618. * @param parBegin(int)
  1619. * @param parEnd(int)
  1620. */
  1621. function pc_loadStream(resIndex){
  1622. //document.getElementById("wizard_div_palicannon").style.display="none";
  1623. gCurrResIndex=resIndex;
  1624. gCurrBook=gResDownloadList[resIndex].book;
  1625. gCurrType=gResDownloadList[resIndex].type;
  1626. //找到第一個應該加載的段落
  1627. gCurrParBegin=gResDownloadList[resIndex].parNum;
  1628. gCurrParEnd=gResDownloadList[resIndex].parEnd;
  1629. gCurrParList=gResDownloadList[resIndex].parlist;
  1630. gCurrParBegin = find_first_enable_par(gCurrParBegin,gCurrParList);
  1631. gResDownloadList[resIndex].parCurrLoading=gCurrParBegin;
  1632. gCurrLoadPar=gCurrParBegin;
  1633. gLoadSteamCanceled=false;
  1634. //清空单词节点数组
  1635. gXmlAllWordInWBW = new Array();
  1636. var d=new Date();
  1637. loadSteamBeginTime=d.getTime();
  1638. //关闭单词修改窗口
  1639. closeModifyWindow();
  1640. //insertTocToXmlBookHead(parBegin,parEnd);
  1641. pc_load_book_par();
  1642. }
  1643. function pc_cancelSteam(){
  1644. gLoadSteamCanceled = true;
  1645. }
  1646. var pc_xmlLoadBookhttp;
  1647. function pc_load_book_par(){
  1648. if (window.XMLHttpRequest)
  1649. {// code for IE7+, Firefox, Chrome, Opera, Safari
  1650. pc_xmlLoadBookhttp=new XMLHttpRequest();
  1651. }
  1652. else
  1653. {// code for IE6, IE5
  1654. pc_xmlLoadBookhttp=new ActiveXObject("Microsoft.XMLHTTP");
  1655. }
  1656. var d=new Date();
  1657. res=gResDownloadList[gCurrResIndex].res;
  1658. book=gResDownloadList[gCurrResIndex].book;
  1659. thisParNum=gResDownloadList[gCurrResIndex].parNum;
  1660. thisParEnd = gResDownloadList[gCurrResIndex].parEnd;
  1661. gResDownloadList[gCurrResIndex].parCurrLoading=gCurrLoadPar;
  1662. author=gResDownloadList[gCurrResIndex].author;
  1663. editor=gResDownloadList[gCurrResIndex].editor;
  1664. revision=gResDownloadList[gCurrResIndex].revision;
  1665. language=gResDownloadList[gCurrResIndex].language;
  1666. edition=gResDownloadList[gCurrResIndex].edition;
  1667. subver=gResDownloadList[gCurrResIndex].subver;
  1668. var link="pc_get_book_res.php?t="+d.getTime()+"&res_type="+res+"&book="+book+"&paragraph="+gCurrLoadPar+"&author="+author+"&editor="+editor+"&revision="+revision+"&language="+language+"&edition="+edition+"&subver="+subver;
  1669. pc_xmlLoadBookhttp.onreadystatechange=pc_load_book_serverResponse;
  1670. pc_xmlLoadBookhttp.open("GET",link,true);
  1671. pc_xmlLoadBookhttp.send();
  1672. }
  1673. function pc_load_book_serverResponse(){
  1674. if (pc_xmlLoadBookhttp.readyState==4)// 4 = "loaded"
  1675. {
  1676. if (pc_xmlLoadBookhttp.status==200)
  1677. {// 200 = "OK"
  1678. var xmlText = pc_xmlLoadBookhttp.responseText;
  1679. if (window.DOMParser)
  1680. {
  1681. parser=new DOMParser();
  1682. xmlBookPar=parser.parseFromString(xmlText,"text/xml");
  1683. }
  1684. else // Internet Explorer
  1685. {
  1686. xmlBookPar=new ActiveXObject("Microsoft.XMLDOM");
  1687. xmlBookPar.async="false";
  1688. xmlBookPar.loadXML(xmlText);
  1689. }
  1690. if (xmlBookPar == null){
  1691. alert("error:can not load book index.");
  1692. return;
  1693. }
  1694. xmlParBlocks = xmlBookPar.getElementsByTagName("block");
  1695. for(iXml=0;iXml<xmlParBlocks.length;iXml++){
  1696. insertBlockToXmlBookData(xmlParBlocks[iXml])
  1697. insertBlockToHtml(xmlParBlocks[iXml])
  1698. }
  1699. if(gLoadSteamCanceled){
  1700. var_dump("load cancel");
  1701. refreshResource();
  1702. updataToc()
  1703. }
  1704. else{
  1705. var d=new Date();
  1706. loadSteamCurrTime=d.getTime()
  1707. passTime=(loadSteamCurrTime-loadSteamBeginTime)/1000;
  1708. gCurrLoadPar++;
  1709. gCurrLoadPar--;
  1710. /*
  1711. var trueLoadPar=-1;
  1712. for(var iSelectPar=gCurrLoadPar+1;iSelectPar<=gCurrParEnd;iSelectPar++){
  1713. var parVisible=document.getElementById("par_enable_"+iSelectPar).checked;
  1714. if(parVisible){
  1715. trueLoadPar=iSelectPar;
  1716. break;
  1717. }
  1718. }
  1719. */
  1720. //gCurrLoadPar=trueLoadPar;
  1721. gCurrLoadPar = find_first_enable_par(gCurrLoadPar+1,gCurrParList);
  1722. if(gCurrLoadPar<=gCurrParEnd && gCurrLoadPar!=-1){
  1723. pc_load_book_par(gCurrSelectedBook,gCurrLoadPar,"vri");
  1724. progress=(gCurrLoadPar-gCurrParBegin)/(gCurrParEnd-gCurrParBegin)
  1725. var c=document.getElementById("book_res_load_progress_canvas_"+gCurrResIndex);
  1726. var cxt=c.getContext("2d");
  1727. cxt.fillStyle="#6baaff";
  1728. cxt.fillRect(0,0,300*progress,5);
  1729. remainTime=(passTime/progress)-passTime;
  1730. strProgress=(progress*100).toFixed(1)+"%"
  1731. document.getElementById('id_book_res_load_progress').innerHTML=strProgress+"<br />pass:"+passTime.toFixed(1)+"s remain: "+remainTime.toFixed(1)+"s";
  1732. }
  1733. else{
  1734. progress=(gCurrLoadPar-gCurrParBegin)/(gCurrParEnd-gCurrParBegin)
  1735. var c=document.getElementById("book_res_load_progress_canvas_"+gCurrResIndex);
  1736. var cxt=c.getContext("2d");
  1737. cxt.fillStyle="#6baaff";
  1738. cxt.fillRect(0,0,300*progress,5);
  1739. remainTime=(passTime/progress)-passTime;
  1740. strProgress=(progress*100).toFixed(1)+"%"
  1741. document.getElementById('id_book_res_load_progress').innerHTML="Load Finished<br />耗时:"+passTime.toFixed(1)+" s";
  1742. document.getElementById('id_book_res_load_progress').innerHTML += "one res load finished";
  1743. refreshResource();
  1744. updataToc();
  1745. if(gCurrResIndex==(gResDownloadList.length-1)){
  1746. //全部资源加载完
  1747. var_dump("doc load finished");
  1748. }
  1749. else{
  1750. //一个资源加载完毕 加载另一个资源
  1751. pc_loadStream(gCurrResIndex+1);
  1752. }
  1753. }
  1754. }
  1755. }
  1756. else
  1757. {
  1758. //document.getElementById('id_palicannon_index_filelist')="Problem retrieving data:" + xmlhttp.statusText;
  1759. }
  1760. }
  1761. }
  1762. function set_pali_loader_visible(visible){
  1763. if(visible){
  1764. document.getElementById('pc_res_loader').style.display="block"
  1765. editor_show_right_tool_bar(true);
  1766. }
  1767. else{
  1768. document.getElementById('pc_res_loader').style.display="none"
  1769. editor_show_right_tool_bar(false);
  1770. }
  1771. }
  1772. //目录段落勾选动作
  1773. function wizard_toc_par_enable(obj,iParIndex){
  1774. gTocList[iParIndex].enable=obj.checked
  1775. document.getElementById("par_enable_"+gTocList[iParIndex].parNum).checked=obj.checked;
  1776. wizard_palicannon_updata_pali_par_text_enable(gTocList[iParIndex].parNum,obj.checked);
  1777. if(gTocList[iParIndex].level>0){
  1778. endIndex=wizard_palicanon_get_par_end_index(iParIndex)
  1779. for(var iPar=iParIndex+1;iPar<=endIndex;iPar++){
  1780. gTocList[iPar].enable=obj.checked
  1781. document.getElementById("toc_par_enable_"+iPar).checked=obj.checked;
  1782. document.getElementById("par_enable_"+gTocList[iPar].parNum).checked=obj.checked;
  1783. wizard_palicannon_updata_pali_par_text_enable(gTocList[iPar].parNum,obj.checked);
  1784. }
  1785. }
  1786. }
  1787. //文章段落勾选动作
  1788. function par_enable_change(iParNum,obj){
  1789. var parIndex=-1;
  1790. for(var iPar=0;iPar<gTocList.length;iPar++){
  1791. if(iParNum==gTocList[iPar].parNum){
  1792. parIndex=iPar;
  1793. break;
  1794. }
  1795. }
  1796. if(parIndex>=0){
  1797. gTocList[parIndex].enable=obj.checked;
  1798. document.getElementById("toc_par_enable_"+parIndex).checked=obj.checked;
  1799. }
  1800. wizard_palicannon_updata_pali_par_text_enable(iParNum,obj.checked);
  1801. }
  1802. //找到当前第一个可用的段落
  1803. //找到:返回段落号
  1804. //没找到:-1
  1805. function find_first_enable_par(iBeginParNum,strParList){
  1806. var arrayParList=strParList.split(",");
  1807. for(iPar in arrayParList){
  1808. curr = arrayParList[iPar];
  1809. curr++;
  1810. curr--;
  1811. if(curr>=iBeginParNum){
  1812. output = arrayParList[iPar];
  1813. output++;
  1814. output--;
  1815. return(output);
  1816. break;
  1817. }
  1818. }
  1819. return(-1);
  1820. }
  1821. //显示浮动的段落资源窗口
  1822. function palicannon_par_res_show_window(parIndex){
  1823. eWin=document.getElementById("palicannon_par_res_list");
  1824. output="";
  1825. output += "<div id=\"palicannon_par_res_list_title\">";
  1826. output += "<button onclick='book_res_edit_now(2)'>";
  1827. output += "立即编辑</button>";
  1828. output += "<button onclick='book_res_add_to_list(2)'>加入到编辑列表</button><button onclick='book_res_win_close()'>关闭</button>"
  1829. output += "</div>"
  1830. output += "<div id=\"palicannon_par_res_list_body\">";
  1831. output += wizard_palicannon_render_res_list_onepart(parIndex,2);
  1832. output += "</div>";
  1833. eWin.innerHTML = output;
  1834. eWin.style.display="block";
  1835. objParent = document.getElementById("id_pc_nav_par_"+parIndex);
  1836. objInsert = null;
  1837. objParent.insertBefore(eWin,objInsert);
  1838. }
  1839. function book_res_win_close(){
  1840. eWin=document.getElementById("palicannon_par_res_list");
  1841. objParent=document.getElementById("palicannon_par_res_list_shell");
  1842. objInsert=null;
  1843. objParent.insertBefore(eWin,objInsert);
  1844. }
  1845. function wizard_get_toc_from_res(){
  1846. gTocLanguage = new Array()
  1847. gTocLanguageItem = new Array()
  1848. gTocCurrLanguage="pali";
  1849. for(var iPar=0;iPar<gTocList.length;iPar++){
  1850. parTitle=gTocList[iPar].title;
  1851. parHeadingLevel=gTocList[iPar].level;
  1852. parNum=gTocList[iPar].parNum;
  1853. var newObj=Object();
  1854. newObj.par=parNum;
  1855. newObj.language="pali";
  1856. newObj.title=parTitle;
  1857. wizard_push_new_to_toc_language_list("pali");
  1858. var newArray = Array();
  1859. newArray.push(newObj);
  1860. gTocLanguageItem.push(newArray);
  1861. }
  1862. for(x in gResList){
  1863. if(gResList[x].type=="translate"){
  1864. var newObj=Object();
  1865. newObj.par=gResList[x].parNum;
  1866. newObj.language=gResList[x].language;
  1867. newObj.title=gResList[x].title;
  1868. wizard_push_new_to_toc_language_list(newObj.language);
  1869. gTocLanguageItem[newObj.par-1].push(newObj);
  1870. }
  1871. }
  1872. }
  1873. function wizard_push_new_to_toc_language_list(newLanguage){
  1874. for(x in gTocLanguage){
  1875. if(gTocLanguage[x]==newLanguage){
  1876. return;
  1877. }
  1878. }
  1879. gTocLanguage.push(newLanguage)
  1880. }
  1881. function wizard_ger_toc_title(parIndex,language){
  1882. for(var x in gTocLanguageItem[parIndex]){
  1883. if(gTocLanguageItem[parIndex][x].language==language){
  1884. return(gTocLanguageItem[parIndex][x].title);
  1885. }
  1886. }
  1887. return(null);
  1888. }
  1889. function wizard_palicannon_nav_language_change(obj){
  1890. gTocCurrLanguage=obj.value;
  1891. $("#wizard_palicannon_par_select_toc").html(wizard_palicannon_renderBookToc(gTocCurrRoot));
  1892. }
  1893. //重新设定目录的根层级
  1894. function palicannon_par_toc_reset_root(newRoot){
  1895. document.getElementById('wizard_palicannon_par_select_toc').innerHTML=wizard_palicannon_renderBookToc(newRoot);
  1896. var parentArray = new Array();
  1897. currPar=newRoot;
  1898. do{
  1899. iParent=palicannon_par_get_parent(currPar);
  1900. var objParent = new Object();
  1901. objParent.parent=iParent;
  1902. objParent.curr=currPar;
  1903. parentArray.push(objParent);
  1904. //wizard_palicanon_heading_change(iParent,currPar);
  1905. currPar=iParent;
  1906. }
  1907. while(iParent>-1)
  1908. for(var i=parentArray.length-1;i>=0;i--){
  1909. wizard_palicanon_heading_change(parentArray[i].parent,parentArray[i].curr);
  1910. }
  1911. //当改变当前标题时 更新资源列表
  1912. wizard_palicannon_updata_res_info(newRoot);
  1913. //当改变当前标题时 隐藏不需要显示的巴利文本
  1914. wizard_palicanon_updata_pali_text(newRoot);
  1915. }
  1916. function palicannon_par_get_parent(index){
  1917. var currLevel=gTocList[index].level;
  1918. for(var iPar=currLevel;iPar>=0;iPar--){
  1919. if(gTocList[iPar].level>0 && gTocList[iPar].level<currLevel){
  1920. return(iPar)
  1921. }
  1922. }
  1923. return(-1);
  1924. }
  1925. //从服务器获取段落单词数
  1926. var wizard_palicannon_res_word_num_xmlhttp;
  1927. function wizard_palicannon_res_word_num_query(bookId,begin,end){
  1928. if (window.XMLHttpRequest)
  1929. {// code for IE7+, Firefox, Chrome, Opera, Safari
  1930. wizard_palicannon_res_word_num_xmlhttp=new XMLHttpRequest();
  1931. }
  1932. else
  1933. {// code for IE6, IE5
  1934. wizard_palicannon_res_word_num_xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  1935. }
  1936. var d=new Date();
  1937. wizard_palicannon_res_word_num_xmlhttp.onreadystatechange=wizard_palicannon_res_word_num_serverResponse;
  1938. wizard_palicannon_res_word_num_xmlhttp.open("GET","pc_get_word_num.php?t="+d.getTime()+"&book="+bookId+"&begin="+begin+"&end="+end,true);
  1939. wizard_palicannon_res_word_num_xmlhttp.send();
  1940. }
  1941. function get_time_by_min(min){
  1942. if(Math.round(min)==0){
  1943. workload_time="";
  1944. }
  1945. else if(min<60){
  1946. var workload_time=min;
  1947. workload_time=Math.round(workload_time)+gLocal.gui.min;
  1948. }
  1949. else if(min>=60 && min<2400){//60min-40h
  1950. var workload_time=min/60;
  1951. left_lime=(workload_time-Math.round(workload_time))*60;
  1952. workload_time=Math.round(workload_time)+gLocal.gui.h;
  1953. }
  1954. else if(min/60/8<261 && min>=2400){//40h-261天
  1955. var workload_time=min/60/40;
  1956. left_lime=(workload_time-Math.floor(workload_time))*60*40;
  1957. workload_time=Math.floor(workload_time)+gLocal.gui.week
  1958. if(left_lime>=60){
  1959. workload_time+=get_time_by_min(left_lime);
  1960. }
  1961. }
  1962. else if(min/60/8>=261){//一年以上
  1963. var workload_time=min/60/8/261;
  1964. left_lime=(workload_time-Math.floor(workload_time))*60*8*261;
  1965. workload_time=Math.floor(workload_time)+gLocal.gui.year
  1966. if(left_lime>=60){
  1967. workload_time+=get_time_by_min(left_lime);
  1968. }
  1969. }
  1970. return(workload_time);
  1971. }
  1972. function get_shortnum_by_num(num){
  1973. var new_num=""
  1974. if(num<900){
  1975. new_num=Math.round(num);
  1976. }
  1977. else if(num>=900 && num<10000){
  1978. num=num/1000
  1979. new_num=Math.round(num*100)/100+gLocal.gui.num_k
  1980. }
  1981. else if(num>=10000 && num<100000){
  1982. num=num/1000
  1983. new_num=Math.round(num*10)/10+gLocal.gui.num_k
  1984. }
  1985. else if(num>=100000 && num<900000){
  1986. num=num/1000
  1987. new_num=Math.round(num)+gLocal.gui.num_k
  1988. }
  1989. else{
  1990. num=num/1000000
  1991. new_num=Math.round(num*100)/100+gLocal.gui.num_m
  1992. }
  1993. return(new_num);
  1994. }
  1995. //收到资源列表
  1996. function wizard_palicannon_res_word_num_serverResponse(){
  1997. if (wizard_palicannon_res_word_num_xmlhttp.readyState==4)// 4 = "loaded"
  1998. {
  1999. if (wizard_palicannon_res_word_num_xmlhttp.status==200)
  2000. {// 200 = "OK"
  2001. var xmlText = wizard_palicannon_res_word_num_xmlhttp.responseText;
  2002. var wordInfo=xmlText.split(",");
  2003. document.getElementById('pc_res_par_word_num').innerHTML=get_shortnum_by_num(wordInfo[0])+gLocal.gui.words+" "+get_shortnum_by_num(wordInfo[2])+gLocal.gui.letters;//總詞數
  2004. document.getElementById('pc_res_par_vocabulary').innerHTML=get_shortnum_by_num(wordInfo[1])+gLocal.gui.words+" "+get_shortnum_by_num(wordInfo[3])+gLocal.gui.letters;//詞匯量
  2005. document.getElementById('pc_res_par_word_length').innerHTML=Math.round(wordInfo[2]/wordInfo[0]*100)/100+"-"+Math.round(wordInfo[3]/wordInfo[1]*100)/100//平均词长,取2位小數
  2006. document.getElementById('pc_res_par_quotiety').innerHTML=Math.round(wordInfo[2]/wordInfo[3]*100)/100+"-"+Math.round(wordInfo[0]/wordInfo[1]*100)/100;//重複率,取2位小數
  2007. document.getElementById('pc_res_par_tran_workload').innerHTML=get_time_by_min(wordInfo[2]/22.95);//翻译工作量
  2008. document.getElementById('pc_res_par_wbw_workload').innerHTML=get_time_by_min(wordInfo[3]/5.61);//逐词解析工作量
  2009. document.getElementById('pc_res_par_total_workload').innerHTML=get_time_by_min(wordInfo[3]/5.61+wordInfo[2]/22.95);//工作总量
  2010. document.getElementById('pc_res_par_product').innerHTML=get_shortnum_by_num(wordInfo[2]*0.37);//译文预期字数
  2011. var difficulty_lv=Math.round(wordInfo[3]/5.61/wordInfo[0]*100)/10
  2012. document.getElementById('pc_res_par_difficulty').innerHTML=difficulty_lv;//整体复杂度
  2013. document.getElementById('star_lv').innerHTML=get_star_by_lv(difficulty_lv,10,5);//整体复杂度
  2014. }
  2015. else
  2016. {
  2017. //document.getElementById('id_pc_')="Problem retrieving data:" + xmlhttp.statusText;
  2018. }
  2019. }
  2020. }
  2021. function get_star_by_lv(lv,max_lv,max_star){
  2022. var lv=lv*max_star/max_lv;
  2023. var lv_base=Math.floor(lv);
  2024. var lv_end=lv-lv_base;
  2025. var star_str=""
  2026. for(i=0;i<lv_base;i++){
  2027. star_str += "<svg class=\"icon\"><use xlink:href=\"svg/icon.svg#ic_star\"></use></svg>"
  2028. }
  2029. if(lv_end<0.5){
  2030. star_str += "<svg class=\"icon\"><use xlink:href=\"svg/icon.svg#ic_star_border\"></use></svg>"
  2031. }
  2032. else{
  2033. star_str += "<svg class=\"icon\"><use xlink:href=\"svg/icon.svg#ic_star_half\"></use></svg>"
  2034. }
  2035. return(star_str)
  2036. }