wizard.js 72 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276
  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="../pcdl/reader.php?book="+arrResData[i].book+"&album="+arrResData[i].album_id+"&paragraph="+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. function wizard_palicannon_pali_text_serverResponse(){
  964. if (wizard_palicannon_pali_text_xmlhttp.readyState==4)// 4 = "loaded"
  965. {
  966. if (wizard_palicannon_pali_text_xmlhttp.status==200)
  967. {// 200 = "OK"
  968. var xmlText = wizard_palicannon_pali_text_xmlhttp.responseText;
  969. $("#wizard_palicannon_par_select_text_body").html(xmlText);
  970. $("#wizard_palicannon_par_select_text_head").show();
  971. }
  972. else
  973. {
  974. document.getElementById('wizard_palicannon_par_select_text_body').innerHTML="Problem retrieving data:" + wizard_palicannon_pali_text_xmlhttp.statusText;
  975. }
  976. }
  977. }
  978. /*
  979. //get res list from database
  980. function wizard_palicannon_get_res_list(){
  981. gCurrQueryResType=0;
  982. wizard_palicannon_res_list_query(gResTypeList[gCurrQueryResType],gCurrSelectedBook);
  983. }
  984. //从服务器获取资源列表
  985. var wizard_palicannon_res_xmlhttp;
  986. function wizard_palicannon_res_list_query(resType,bookId){
  987. if (window.XMLHttpRequest)
  988. {// code for IE7+, Firefox, Chrome, Opera, Safari
  989. wizard_palicannon_res_xmlhttp=new XMLHttpRequest();
  990. }
  991. else
  992. {// code for IE6, IE5
  993. wizard_palicannon_res_xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  994. }
  995. var d=new Date();
  996. var parList=wizard_palicannon_get_par_list();
  997. wizard_palicannon_res_xmlhttp.onreadystatechange=wizard_palicannon_res_serverResponse;
  998. wizard_palicannon_res_xmlhttp.open("GET","pc_get_res_list.php?t="+d.getTime()+"&book="+bookId+"&res_type="+resType+"&par_list="+parList,true);
  999. wizard_palicannon_res_xmlhttp.send();
  1000. }
  1001. //收到资源列表
  1002. function wizard_palicannon_res_serverResponse(){
  1003. if (wizard_palicannon_res_xmlhttp.readyState==4)// 4 = "loaded"
  1004. {
  1005. if (wizard_palicannon_res_xmlhttp.status==200)
  1006. {// 200 = "OK"
  1007. var parList="";
  1008. var xmlText = wizard_palicannon_res_xmlhttp.responseText;
  1009. if (window.DOMParser)
  1010. {
  1011. parser=new DOMParser();
  1012. xmlBookRes=parser.parseFromString(xmlText,"text/xml");
  1013. }
  1014. else // Internet Explorer
  1015. {
  1016. xmlBookRes=new ActiveXObject("Microsoft.XMLDOM");
  1017. xmlBookRes.async="false";
  1018. xmlBookRes.loadXML(xmlText);
  1019. }
  1020. if (xmlBookRes == null){
  1021. alert("error:can not load book res.");
  1022. return;
  1023. }
  1024. gXmlResList = xmlBookRes.getElementsByTagName("res");
  1025. add_new_res_list(gXmlResList);
  1026. //如果还有等待加载的资源 继续加载
  1027. if(gCurrQueryResType<gResTypeList.length-1){
  1028. gCurrQueryResType++;
  1029. wizard_palicannon_res_list_query(gResTypeList[gCurrQueryResType],gCurrSelectedBook);
  1030. }
  1031. else{
  1032. //如果没有了 显示资源列表
  1033. //wizard_palicannon_render_res_list();
  1034. wizard_get_toc_from_res();
  1035. document.getElementById('wizard_palicannon_par_select_toc').innerHTML=wizard_palicannon_renderBookToc(gTocCurrRoot);
  1036. }
  1037. }
  1038. else
  1039. {
  1040. document.getElementById('id_wizard_palicannon_index_filelist')="Problem retrieving data:" + xmlhttp.statusText;
  1041. }
  1042. }
  1043. }
  1044. */
  1045. //添加新的资源 到 内存数组
  1046. function add_new_res_list(xNewList){
  1047. for(var iItem=0;iItem<xNewList.length;iItem++){
  1048. var newItem=new Object();
  1049. newItem.type=getNodeText(xNewList[iItem],"type");
  1050. newItem.book=getNodeText(xNewList[iItem],"book");
  1051. newItem.parNum=getNodeText(xNewList[iItem],"par");
  1052. newItem.parEnd=wizard_palicannon_get_par_end(newItem.parNum);
  1053. newItem.parCurrLoading=newItem.parNum;
  1054. newItem.author=getNodeText(xNewList[iItem],"author");
  1055. newItem.editor=getNodeText(xNewList[iItem],"editor");
  1056. newItem.revision=getNodeText(xNewList[iItem],"revision");
  1057. newItem.language=getNodeText(xNewList[iItem],"language");
  1058. newItem.edition=getNodeText(xNewList[iItem],"edition");
  1059. newItem.subver=getNodeText(xNewList[iItem],"subver");
  1060. newItem.text=getNodeText(xNewList[iItem],"text");
  1061. newItem.title=getNodeText(xNewList[iItem],"text");
  1062. gResList.push(newItem);
  1063. }
  1064. }
  1065. function wizard_palicannon_get_par_list(){
  1066. var output="";
  1067. for(var iPar=0;iPar<gXmlParIndex.length;iPar++){
  1068. parTitle=getNodeText(gXmlParIndex[iPar],"title");
  1069. parHeadingLevel=getNodeText(gXmlParIndex[iPar],"level");
  1070. parNum=getNodeText(gXmlParIndex[iPar],"par");
  1071. if(parHeadingLevel>0){
  1072. output+=parNum+","
  1073. }
  1074. }
  1075. return(output.slice(0,-1))
  1076. }
  1077. //获取段落终止点
  1078. //输入:索引
  1079. //输出:索引
  1080. function wizard_palicanon_get_par_end_index(beginIndex){
  1081. var iStartPar=0
  1082. var iStartLevel=0
  1083. if(beginIndex==-1){
  1084. return(gTocList.length-1);
  1085. }
  1086. if(gTocList[beginIndex].level==0){
  1087. return(beginIndex);
  1088. }
  1089. for(var iPar=beginIndex+1;iPar<gTocList.length;iPar++){
  1090. parLevel=gTocList[iPar].level;
  1091. if(parLevel>0){
  1092. if(parLevel <= gTocList[beginIndex].level){
  1093. return(iPar-1);
  1094. }
  1095. }
  1096. }
  1097. //没找到 返回数组最后一个索引号
  1098. return(gTocList.length-1);
  1099. }
  1100. function wizard_palicannon_get_par_end(beginParNum){
  1101. var iStartPar=0
  1102. var iStartLevel=0
  1103. for(var iPar=0;iPar<gTocList.length;iPar++){
  1104. currParNum=gTocList[iPar].parNum;
  1105. if(currParNum==beginParNum){
  1106. iStartPar=iPar;
  1107. break;
  1108. }
  1109. }
  1110. var iEnd = wizard_palicanon_get_par_end_index(iStartPar);
  1111. /*
  1112. for(var iPar=iStartPar+1;iPar<gXmlParIndex.length;iPar++){
  1113. parLevel=getNodeText(gXmlParIndex[iPar],"level");
  1114. if(parLevel>0){
  1115. if(parLevel <= iStartLevel){
  1116. //iEndPar=getNodeText(gXmlParIndex[iPar],"par")
  1117. return(iPar-1);
  1118. }
  1119. }
  1120. }
  1121. return(gXmlParIndex.length-1);
  1122. */
  1123. return(gTocList[iEnd].parNum);
  1124. }
  1125. function book_res_edit_now(resWin){
  1126. var resNum = book_res_add_to_list(resWin);
  1127. if(resNum>0){
  1128. open_editor_load_stream();
  1129. }
  1130. }
  1131. //加入到下载列表
  1132. //resWin=1 主列表 resWin=2 浮动列表
  1133. function book_res_add_to_list(resWin){
  1134. var iCounter=0;
  1135. switch(resWin){
  1136. case 1:
  1137. currList=gCurrResListArray;
  1138. break;
  1139. case 2: //for float windows
  1140. currList=gCurrResListArray2;
  1141. break;
  1142. default:
  1143. return;
  1144. }
  1145. if(currList){
  1146. for(i in currList){
  1147. if(currList[i].enable){
  1148. pc_res_add_to_download_list(currList[i].res);
  1149. iCounter++;
  1150. }
  1151. }
  1152. }
  1153. return(iCounter);
  1154. }
  1155. function pali_canon_edit_now(thisform)
  1156. {
  1157. var download_res_data=new Array();
  1158. for(i in arrResData){
  1159. if(arrResData[i].enable){
  1160. var resDownloadItem=new Object();
  1161. resDownloadItem.album_id=arrResData[i].album_id;
  1162. resDownloadItem.type=arrResData[i].type;
  1163. resDownloadItem.book=arrResData[i].book;
  1164. resDownloadItem.parNum=arrResData[i].paragraph;
  1165. resDownloadItem.author=arrResData[i].author;
  1166. resDownloadItem.editor=arrResData[i].editor;
  1167. resDownloadItem.language=arrResData[i].language;
  1168. resDownloadItem.edition=arrResData[i].edition;
  1169. resDownloadItem.version=arrResData[i].version;
  1170. resDownloadItem.title=arrResData[i].title;
  1171. var strParList="";
  1172. var firstIndex=-1;
  1173. var firstLevel=-1;
  1174. var endIndex=-1
  1175. //计算段落区间
  1176. for(var iPar=0;iPar<gTocList.length;iPar++){
  1177. if(resDownloadItem.parNum==gTocList[iPar].parNum){
  1178. firstIndex=iPar;
  1179. firstLevel=gTocList[iPar].level;
  1180. break;
  1181. }
  1182. }
  1183. for(var iPar=firstIndex+1;iPar<gTocList.length;iPar++){
  1184. var newLevel=gTocList[iPar].level;
  1185. if(newLevel>0 && newLevel<=firstLevel){
  1186. endIndex=iPar-1;
  1187. break;
  1188. }
  1189. }
  1190. if(firstIndex==-1){
  1191. return;
  1192. }
  1193. if(endIndex==-1){
  1194. endIndex=gTocList.length-1;
  1195. }
  1196. //查找被选择的段落
  1197. for(var iPar=firstIndex;iPar<=endIndex;iPar++){
  1198. if(gTocList[iPar].enable){
  1199. strParList+=gTocList[iPar].parNum;
  1200. if(iPar<endIndex){
  1201. strParList += ",";
  1202. }
  1203. }
  1204. }
  1205. resDownloadItem.parlist=strParList;
  1206. download_res_data.push(resDownloadItem);
  1207. }
  1208. }
  1209. if(download_res_data.length>0){
  1210. $("#project_new_res_data").val(JSON.stringify(download_res_data));
  1211. return true;
  1212. }
  1213. else{
  1214. return false;
  1215. }
  1216. }
  1217. //勾选资源项目
  1218. //resWin=1 主列表 resWin=2 浮动列表
  1219. function setResEnable(obj,index,resWin){
  1220. switch(resWin){
  1221. case 1:
  1222. gCurrResListArray[index].enable=obj.checked;
  1223. break;
  1224. case 2: //for float windows
  1225. gCurrResListArray2[index].enable=obj.checked;
  1226. break;
  1227. default:
  1228. return;
  1229. }
  1230. }
  1231. //渲染资源内容
  1232. //resWin=1 主列表 resWin=2 浮动列表
  1233. function wizard_palicannon_render_res_list_onepart(parIndex,resWin){
  1234. if(parIndex>=0){
  1235. var parNo=gTocList[parIndex].parNum;
  1236. var paraEndIndex=wizard_palicanon_get_par_end_index(parIndex);
  1237. var parNumber=gTocList[paraEndIndex].parNum-gTocList[parIndex].parNum+1;
  1238. }
  1239. else{
  1240. var parNo=-1;
  1241. var parNumber=0;
  1242. }
  1243. switch(resWin){
  1244. case 1:
  1245. gCurrResListArray=new Array();
  1246. break;
  1247. case 2: //for float windows
  1248. gCurrResListArray2=new Array();
  1249. break;
  1250. default:
  1251. return;
  1252. }
  1253. var iResCounter=0;
  1254. var output="<div class=\"resouse_info\">";
  1255. output += "</div>";
  1256. output += "<div class=\"chapter_info\">"+gLocal.gui.statistical_data+"<br/>";
  1257. output += "<span style=\"width: 12em;\">"+gLocal.gui.totally+parNumber+gLocal.gui.para+"</span><br/>";
  1258. output += "<span style=\"width: 12em;\">"+gLocal.gui.wordnum+"</span><span id=\"pc_res_par_word_num\"></span><br/>";
  1259. output += "<span style=\"width: 12em;\">"+gLocal.gui.vocabulary+"</span><span id=\"pc_res_par_vocabulary\"></span><br/>";
  1260. output += "<span style=\"width: 12em;\">"+gLocal.gui.word_length+":</span><span id=\"pc_res_par_word_length\"></span><br/>";
  1261. output += "<span style=\"width: 12em;\">"+gLocal.gui.repeat+"</span><span id=\"pc_res_par_quotiety\"></span><br/>";
  1262. output += "</div>";
  1263. output += "<div class=\"chapter_info\" style='margin-right:0'>"+gLocal.gui.workload+"<br/>";
  1264. output += "<span style=\"width: 12em;\">"+gLocal.gui.tran_workload+"</span><span id=\"pc_res_par_tran_workload\"></span><br/>";
  1265. output += "<span style=\"width: 12em;\">"+gLocal.gui.wbw+":</span><span id=\"pc_res_par_wbw_workload\"></span><br/>";
  1266. output += "<span style=\"width: 12em;\">"+gLocal.gui.total_workload+":</span><span id=\"pc_res_par_total_workload\"></span><br/>";
  1267. output += "<span style=\"width: 12em;\">"+gLocal.gui.product+":</span><span id=\"pc_res_par_product\"></span><br/>";
  1268. output += "<span style=\"width: 12em;\">"+gLocal.gui.difficulty+":</span><span id=\"pc_res_par_difficulty\"></span>";
  1269. output += "</div>";
  1270. if(parIndex>=0){
  1271. wizard_palicannon_res_word_num_query(gTocList[parIndex].book,gTocList[parIndex].parNum,gTocList[wizard_palicanon_get_par_end_index(parIndex)].parNum);
  1272. }
  1273. else{
  1274. wizard_palicannon_res_word_num_query(gTocList[0].book,0,-1);
  1275. }
  1276. return(output);
  1277. }
  1278. //添加新的资源到下载列表
  1279. function pc_res_add_to_download_list(resIndex)
  1280. {
  1281. set_pali_loader_visible(true);
  1282. var resDownloadItem=new Object();
  1283. resDownloadItem.album_id=arrResData[resIndex].album_id;
  1284. resDownloadItem.resIndex=resIndex;
  1285. resDownloadItem.res=arrResData[resIndex].type;
  1286. resDownloadItem.type=arrResData[resIndex].type;
  1287. resDownloadItem.book=arrResData[resIndex].book;
  1288. resDownloadItem.parNum=arrResData[resIndex].paragraph;
  1289. resDownloadItem.parEnd = 0;
  1290. resDownloadItem.author=arrResData[resIndex].author;
  1291. resDownloadItem.editor=arrResData[resIndex].editor;
  1292. resDownloadItem.revision=1;
  1293. resDownloadItem.language=arrResData[resIndex].language;
  1294. resDownloadItem.edition=arrResData[resIndex].edition;
  1295. resDownloadItem.subver=1;
  1296. resDownloadItem.title=arrResData[resIndex].title;
  1297. var strParList="";
  1298. var firstIndex=-1;
  1299. var firstLevel=-1;
  1300. var endIndex=-1
  1301. //计算段落区间
  1302. for(var iPar=0;iPar<gTocList.length;iPar++){
  1303. if(resDownloadItem.parNum==gTocList[iPar].parNum){
  1304. firstIndex=iPar;
  1305. firstLevel=gTocList[iPar].level;
  1306. break;
  1307. }
  1308. }
  1309. for(var iPar=firstIndex+1;iPar<gTocList.length;iPar++){
  1310. var newLevel=gTocList[iPar].level;
  1311. if(newLevel>0 && newLevel<=firstLevel){
  1312. endIndex=iPar-1;
  1313. break;
  1314. }
  1315. }
  1316. if(firstIndex==-1){
  1317. return;
  1318. }
  1319. if(endIndex==-1){
  1320. endIndex=gTocList.length-1;
  1321. }
  1322. //查找被选择的段落
  1323. for(var iPar=firstIndex;iPar<=endIndex;iPar++){
  1324. if(gTocList[iPar].enable){
  1325. strParList+=gTocList[iPar].parNum;
  1326. if(iPar<endIndex){
  1327. strParList += ",";
  1328. }
  1329. }
  1330. }
  1331. resDownloadItem.parlist=strParList;
  1332. //查询是否有重复
  1333. var isInList=false;
  1334. for(i in gResDownloadList){
  1335. if(gResDownloadList[i].parNum==resDownloadItem.parNum && gResDownloadList[i].album_id==resDownloadItem.album_id ){
  1336. isInList = true;
  1337. break;
  1338. }
  1339. }
  1340. //无重复 加载
  1341. if(!isInList){
  1342. gResDownloadList.push(resDownloadItem);
  1343. pc_res_updata_download_list();
  1344. }
  1345. }
  1346. function remove_pc_res_download_list_cookie(){
  1347. gDownloadListString="";
  1348. setCookie("loadlist","","1");
  1349. }
  1350. function add_pc_res_download_list_to_cookie(){
  1351. var cookieString = "{\"loadlist\": [";
  1352. for(i in gResDownloadList){
  1353. cookieString += "{";
  1354. cookieString += "\"resIndex\":\""+gResDownloadList[i].resIndex+"\" ,";
  1355. cookieString += "\"res\":\""+gResDownloadList[i].res+"\" ,";
  1356. cookieString += "\"book\":\""+gResDownloadList[i].book+"\" ,";
  1357. cookieString += "\"parNum\":\""+gResDownloadList[i].parNum+"\" ,";
  1358. cookieString += "\"parEnd\":\""+gResDownloadList[i].parEnd+"\" ,";
  1359. cookieString += "\"author\":\""+gResDownloadList[i].author+"\" ,";
  1360. cookieString += "\"editor\":\""+gResDownloadList[i].editor+"\" ,";
  1361. cookieString += "\"revision\":\""+gResDownloadList[i].revision+"\" ,";
  1362. cookieString += "\"language\":\""+gResDownloadList[i].language+"\" ,";
  1363. cookieString += "\"edition\":\""+gResDownloadList[i].edition+"\" ,";
  1364. cookieString += "\"subver\":\""+gResDownloadList[i].subver+"\" ,";
  1365. cookieString += "\"parlist\":\""+gResDownloadList[i].parlist+"\" ,";
  1366. cookieString += "\"title\":\""+gResDownloadList[i].title+"\"";
  1367. cookieString += "}";
  1368. if(i<gResDownloadList.length-1){
  1369. cookieString += ",";
  1370. }
  1371. }
  1372. cookieString += "]}";
  1373. gDownloadListString=cookieString;
  1374. setCookie("loadlist",cookieString,"1");
  1375. }
  1376. function get_pc_res_download_list_from_cookie(){
  1377. var resListString=getCookie("loadlist");
  1378. objCookieLoadList = JSON.parse(resListString);
  1379. ntf_show(resListString);
  1380. gResDownloadList = new Array();
  1381. for(i in objCookieLoadList.loadlist){
  1382. gResDownloadList.push(objCookieLoadList.loadlist[i]);
  1383. }
  1384. pc_res_updata_download_list();
  1385. }
  1386. function get_pc_res_download_list_from_string(strDownload){
  1387. objCookieLoadList = JSON.parse(strDownload);
  1388. //debugOutput(resListString);
  1389. gResDownloadList = new Array();
  1390. for(i in objCookieLoadList.loadlist){
  1391. gResDownloadList.push(objCookieLoadList.loadlist[i]);
  1392. }
  1393. pc_res_updata_download_list();
  1394. }
  1395. //显示资源预览
  1396. function pc_res_preview(resIndex){
  1397. res=gResList[resIndex].type;
  1398. book=gResList[resIndex].book;
  1399. thisParNum=gResList[resIndex].parNum;
  1400. thisParEnd = gResList[resIndex].parEnd;
  1401. author=gResList[resIndex].author;
  1402. editor=gResList[resIndex].editor;
  1403. revision=gResList[resIndex].revision;
  1404. language=gResList[resIndex].language;
  1405. edition=gResList[resIndex].edition;
  1406. subver=gResList[resIndex].subver;
  1407. 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;
  1408. return(link);
  1409. }
  1410. //删除加载列表中的一项
  1411. function pc_resListRemove(indexDelete){
  1412. gResDownloadList.splice(indexDelete,1);
  1413. pc_res_updata_download_list();
  1414. wizard_save_download_list();
  1415. }
  1416. //清空购物车
  1417. function pc_empty_download_list(){
  1418. gResDownloadList=new Array();
  1419. pc_res_updata_download_list();
  1420. wizard_save_download_list();
  1421. }
  1422. function pc_resListMove(moveFrom,moveTo){
  1423. if(moveTo<0){
  1424. moveTo=0;
  1425. }
  1426. if(moveFrom==moveTo){
  1427. return;
  1428. }
  1429. var temp=gResDownloadList[moveTo];
  1430. gResDownloadList[moveTo]=gResDownloadList[moveFrom];
  1431. for(i=moveFrom-1;i>moveTo;i--){
  1432. gResDownloadList[i+1]=gResDownloadList[i];
  1433. }
  1434. gResDownloadList[moveTo+1]=temp;
  1435. pc_res_updata_download_list();
  1436. wizard_save_download_list();
  1437. }
  1438. function getBookTitleById(bookId){
  1439. for(index in local_palicannon_index){
  1440. if(local_palicannon_index[index].id==bookId){
  1441. return(local_palicannon_index[index].title)
  1442. }
  1443. }
  1444. return("");
  1445. }
  1446. function pc_res_updata_download_list(){
  1447. var resListString=""
  1448. for(var iRes=0;iRes<gResDownloadList.length;iRes++){
  1449. var type=gResDownloadList[iRes].type;
  1450. var book=gResDownloadList[iRes].book;
  1451. var parNum=gResDownloadList[iRes].parNum;
  1452. var parEnd=gResDownloadList[iRes].parEnd;
  1453. var author=gResDownloadList[iRes].author;
  1454. var editor=gResDownloadList[iRes].editor;
  1455. var revision=gResDownloadList[iRes].revision;
  1456. var language=gResDownloadList[iRes].language;
  1457. var edition=gResDownloadList[iRes].edition;
  1458. var subver=gResDownloadList[iRes].subver;
  1459. var title=gResDownloadList[iRes].title;
  1460. var paraList=gResDownloadList[iRes].parlist;
  1461. var parCount=paraList.split().length;
  1462. resListString += "<div class=\"res_item\">"
  1463. resListString += " <table>"
  1464. resListString += " <tr>"
  1465. resListString += " <td class=\"tool_bar\">"
  1466. resListString += " <p class=\"res_button\" onclick=\"pc_resListMove("+iRes+","+(iRes-1)+")\">▲</p>"
  1467. resListString += " <p class=\"res_type\" >W</p>"
  1468. resListString += " <p class=\"res_button\" onclick=\"pc_resListRemove("+iRes+")\">"
  1469. resListString += " <svg id=\"icon_Edit_Dialog_on\" style=\"display:block;\" class=\"icon\">"
  1470. resListString += " <use xmlns:xlink=\"http://www.w3.org/1999/xlink\" xlink:href=\"svg/icon.svg#ic_remove_shopping_cart\"></use>"
  1471. resListString += " </svg>"
  1472. resListString += " </p>"
  1473. resListString += " </td>"
  1474. resListString += " <td class=\"res_info\" >"
  1475. resListString += " <div class=\"res_info_1\"><span class=\"book_name\">"+gCurrBookType+"-《"+getBookTitleById("p"+book)+"》</span><br/>";
  1476. resListString += " <span class=\"chapter\">"+title+"|</span><span class=\"author\">"+gLocal.gui.translate1+author+"</span></div>"
  1477. 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>"
  1478. resListString += " </td>"
  1479. resListString += " </tr>"
  1480. resListString += " </table>"
  1481. resListString += "<canvas class=\"res_load_progress_canvas\" id=\"book_res_load_progress_canvas_"+iRes+"\" width='300' height='5'></canvas>"
  1482. resListString += "</div>"
  1483. }
  1484. document.getElementById("pc_res_list_div").innerHTML=resListString;
  1485. add_pc_res_download_list_to_cookie();
  1486. if(gResDownloadList && gResDownloadList.length>0){
  1487. if(obj=document.getElementById("id_open_editor_load_stream")){obj.disabled=false;}
  1488. if(obj=document.getElementById("id_append_stream")){obj.disabled=false;}
  1489. if(obj=document.getElementById("pc_empty_download_list")){obj.disabled=false;}
  1490. if(obj=document.getElementById("id_cancel_stream")){obj.disabled=false;}
  1491. }
  1492. else{
  1493. if(obj=document.getElementById("id_open_editor_load_stream")){obj.disabled=true;}
  1494. if(obj=document.getElementById("id_append_stream")){obj.disabled=true;}
  1495. if(obj=document.getElementById("pc_empty_download_list")){obj.disabled=true;}
  1496. if(obj=document.getElementById("id_cancel_stream")){obj.disabled=true;}
  1497. }
  1498. }
  1499. function wizard_palicannon_nav_level_show(showLevel){
  1500. getStyleClass('palicannon_nav_level_0').style.display="none";
  1501. getStyleClass('palicannon_nav_level_1').style.display="none";
  1502. getStyleClass('palicannon_nav_level_2').style.display="none";
  1503. getStyleClass('palicannon_nav_level_3').style.display="none";
  1504. getStyleClass('palicannon_nav_level_4').style.display="none";
  1505. getStyleClass('palicannon_nav_level_5').style.display="none";
  1506. getStyleClass('palicannon_nav_level_6').style.display="none";
  1507. getStyleClass('palicannon_nav_level_7').style.display="none";
  1508. getStyleClass('palicannon_nav_level_8').style.display="none";
  1509. switch(showLevel){
  1510. case 0:
  1511. getStyleClass('palicannon_nav_level_0').style.display="block";
  1512. //getStyleClass('tree_expand_0').style.display="inline";
  1513. //getStyleClass('tree_collapse_0').style.display="none";
  1514. case 8:
  1515. getStyleClass('palicannon_nav_level_8').style.display="block";
  1516. getStyleClass('tree_expand_8').style.display="inline";
  1517. getStyleClass('tree_collapse_8').style.display="none";
  1518. case 7:
  1519. getStyleClass('palicannon_nav_level_7').style.display="block";
  1520. getStyleClass('tree_expand_7').style.display="inline";
  1521. getStyleClass('tree_collapse_7').style.display="none";
  1522. case 6:
  1523. getStyleClass('palicannon_nav_level_6').style.display="block";
  1524. getStyleClass('tree_expand_6').style.display="inline";
  1525. getStyleClass('tree_collapse_6').style.display="none";
  1526. case 5:
  1527. getStyleClass('palicannon_nav_level_5').style.display="block";
  1528. getStyleClass('tree_expand_5').style.display="none";
  1529. getStyleClass('tree_collapse_5').style.display="inline";
  1530. case 4:
  1531. getStyleClass('palicannon_nav_level_4').style.display="block";
  1532. getStyleClass('tree_expand_4').style.display="inline";
  1533. getStyleClass('tree_collapse_4').style.display="none";
  1534. case 3:
  1535. getStyleClass('palicannon_nav_level_3').style.display="block";
  1536. getStyleClass('tree_expand_3').style.display="inline";
  1537. getStyleClass('tree_collapse_3').style.display="none";
  1538. case 2:
  1539. getStyleClass('palicannon_nav_level_2').style.display="block";
  1540. getStyleClass('tree_expand_2').style.display="inline";
  1541. getStyleClass('tree_collapse_2').style.display="none";
  1542. case 1:
  1543. getStyleClass('palicannon_nav_level_1').style.display="block";
  1544. getStyleClass('tree_expand_1').style.display="inline";
  1545. getStyleClass('tree_collapse_1').style.display="none";
  1546. }
  1547. switch(showLevel){
  1548. case 8:
  1549. getStyleClass('tree_expand_8').style.display="none";
  1550. getStyleClass('tree_collapse_8').style.display="inline";
  1551. break;
  1552. case 7:
  1553. getStyleClass('tree_expand_7').style.display="none";
  1554. getStyleClass('tree_collapse_7').style.display="inline";
  1555. break;
  1556. case 6:
  1557. getStyleClass('tree_expand_6').style.display="none";
  1558. getStyleClass('tree_collapse_6').style.display="inline";
  1559. break;
  1560. case 5:
  1561. getStyleClass('tree_expand_5').style.display="none";
  1562. getStyleClass('tree_collapse_5').style.display="inline";
  1563. break;
  1564. case 4:
  1565. getStyleClass('tree_expand_4').style.display="none";
  1566. getStyleClass('tree_collapse_4').style.display="inline";
  1567. break;
  1568. case 3:
  1569. getStyleClass('tree_expand_3').style.display="none";
  1570. getStyleClass('tree_collapse_3').style.display="inline";
  1571. break;
  1572. case 2:
  1573. getStyleClass('tree_expand_2').style.display="none";
  1574. getStyleClass('tree_collapse_2').style.display="inline";
  1575. break;
  1576. case 1:
  1577. getStyleClass('tree_expand_1').style.display="none";
  1578. getStyleClass('tree_collapse_1').style.display="inline";
  1579. break;
  1580. }
  1581. }
  1582. //
  1583. /*
  1584. * 在服务器端保存下载列表
  1585. * public
  1586. * @param
  1587. */
  1588. function wizard_save_download_list(){
  1589. var strDownload = JSON.stringify(gResDownloadList);
  1590. $.post("user_file.php",
  1591. {
  1592. op:"save",
  1593. filename:"dl.json",
  1594. data:strDownload
  1595. },
  1596. function(data,status){
  1597. ntf_show("Data: " + data + "\nStatus: " + status);
  1598. });
  1599. }
  1600. //载入编辑列表
  1601. function open_editor_load_stream(){
  1602. window.open("project.php?op=create","_blank");
  1603. }
  1604. /*
  1605. * load paragraph from database
  1606. * public
  1607. * @param book(string) book GUID
  1608. * @param parBegin(int)
  1609. * @param parEnd(int)
  1610. */
  1611. function pc_loadStream(resIndex){
  1612. //document.getElementById("wizard_div_palicannon").style.display="none";
  1613. gCurrResIndex=resIndex;
  1614. gCurrBook=gResDownloadList[resIndex].book;
  1615. gCurrType=gResDownloadList[resIndex].type;
  1616. //找到第一個應該加載的段落
  1617. gCurrParBegin=gResDownloadList[resIndex].parNum;
  1618. gCurrParEnd=gResDownloadList[resIndex].parEnd;
  1619. gCurrParList=gResDownloadList[resIndex].parlist;
  1620. gCurrParBegin = find_first_enable_par(gCurrParBegin,gCurrParList);
  1621. gResDownloadList[resIndex].parCurrLoading=gCurrParBegin;
  1622. gCurrLoadPar=gCurrParBegin;
  1623. gLoadSteamCanceled=false;
  1624. //清空单词节点数组
  1625. gXmlAllWordInWBW = new Array();
  1626. var d=new Date();
  1627. loadSteamBeginTime=d.getTime();
  1628. //关闭单词修改窗口
  1629. closeModifyWindow();
  1630. //insertTocToXmlBookHead(parBegin,parEnd);
  1631. pc_load_book_par();
  1632. }
  1633. function pc_cancelSteam(){
  1634. gLoadSteamCanceled = true;
  1635. }
  1636. var pc_xmlLoadBookhttp;
  1637. function pc_load_book_par(){
  1638. if (window.XMLHttpRequest)
  1639. {// code for IE7+, Firefox, Chrome, Opera, Safari
  1640. pc_xmlLoadBookhttp=new XMLHttpRequest();
  1641. }
  1642. else
  1643. {// code for IE6, IE5
  1644. pc_xmlLoadBookhttp=new ActiveXObject("Microsoft.XMLHTTP");
  1645. }
  1646. var d=new Date();
  1647. res=gResDownloadList[gCurrResIndex].res;
  1648. book=gResDownloadList[gCurrResIndex].book;
  1649. thisParNum=gResDownloadList[gCurrResIndex].parNum;
  1650. thisParEnd = gResDownloadList[gCurrResIndex].parEnd;
  1651. gResDownloadList[gCurrResIndex].parCurrLoading=gCurrLoadPar;
  1652. author=gResDownloadList[gCurrResIndex].author;
  1653. editor=gResDownloadList[gCurrResIndex].editor;
  1654. revision=gResDownloadList[gCurrResIndex].revision;
  1655. language=gResDownloadList[gCurrResIndex].language;
  1656. edition=gResDownloadList[gCurrResIndex].edition;
  1657. subver=gResDownloadList[gCurrResIndex].subver;
  1658. 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;
  1659. pc_xmlLoadBookhttp.onreadystatechange=pc_load_book_serverResponse;
  1660. pc_xmlLoadBookhttp.open("GET",link,true);
  1661. pc_xmlLoadBookhttp.send();
  1662. }
  1663. function pc_load_book_serverResponse(){
  1664. if (pc_xmlLoadBookhttp.readyState==4)// 4 = "loaded"
  1665. {
  1666. if (pc_xmlLoadBookhttp.status==200)
  1667. {// 200 = "OK"
  1668. var xmlText = pc_xmlLoadBookhttp.responseText;
  1669. if (window.DOMParser)
  1670. {
  1671. parser=new DOMParser();
  1672. xmlBookPar=parser.parseFromString(xmlText,"text/xml");
  1673. }
  1674. else // Internet Explorer
  1675. {
  1676. xmlBookPar=new ActiveXObject("Microsoft.XMLDOM");
  1677. xmlBookPar.async="false";
  1678. xmlBookPar.loadXML(xmlText);
  1679. }
  1680. if (xmlBookPar == null){
  1681. alert("error:can not load book index.");
  1682. return;
  1683. }
  1684. xmlParBlocks = xmlBookPar.getElementsByTagName("block");
  1685. for(iXml=0;iXml<xmlParBlocks.length;iXml++){
  1686. insertBlockToXmlBookData(xmlParBlocks[iXml])
  1687. insertBlockToHtml(xmlParBlocks[iXml])
  1688. }
  1689. if(gLoadSteamCanceled){
  1690. var_dump("load cancel");
  1691. refreshResource();
  1692. updataToc()
  1693. }
  1694. else{
  1695. var d=new Date();
  1696. loadSteamCurrTime=d.getTime()
  1697. passTime=(loadSteamCurrTime-loadSteamBeginTime)/1000;
  1698. gCurrLoadPar++;
  1699. gCurrLoadPar--;
  1700. /*
  1701. var trueLoadPar=-1;
  1702. for(var iSelectPar=gCurrLoadPar+1;iSelectPar<=gCurrParEnd;iSelectPar++){
  1703. var parVisible=document.getElementById("par_enable_"+iSelectPar).checked;
  1704. if(parVisible){
  1705. trueLoadPar=iSelectPar;
  1706. break;
  1707. }
  1708. }
  1709. */
  1710. //gCurrLoadPar=trueLoadPar;
  1711. gCurrLoadPar = find_first_enable_par(gCurrLoadPar+1,gCurrParList);
  1712. if(gCurrLoadPar<=gCurrParEnd && gCurrLoadPar!=-1){
  1713. pc_load_book_par(gCurrSelectedBook,gCurrLoadPar,"vri");
  1714. progress=(gCurrLoadPar-gCurrParBegin)/(gCurrParEnd-gCurrParBegin)
  1715. var c=document.getElementById("book_res_load_progress_canvas_"+gCurrResIndex);
  1716. var cxt=c.getContext("2d");
  1717. cxt.fillStyle="#6baaff";
  1718. cxt.fillRect(0,0,300*progress,5);
  1719. remainTime=(passTime/progress)-passTime;
  1720. strProgress=(progress*100).toFixed(1)+"%"
  1721. document.getElementById('id_book_res_load_progress').innerHTML=strProgress+"<br />pass:"+passTime.toFixed(1)+"s remain: "+remainTime.toFixed(1)+"s";
  1722. }
  1723. else{
  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="Load Finished<br />耗时:"+passTime.toFixed(1)+" s";
  1732. document.getElementById('id_book_res_load_progress').innerHTML += "one res load finished";
  1733. refreshResource();
  1734. updataToc();
  1735. if(gCurrResIndex==(gResDownloadList.length-1)){
  1736. //全部资源加载完
  1737. var_dump("doc load finished");
  1738. }
  1739. else{
  1740. //一个资源加载完毕 加载另一个资源
  1741. pc_loadStream(gCurrResIndex+1);
  1742. }
  1743. }
  1744. }
  1745. }
  1746. else
  1747. {
  1748. //document.getElementById('id_palicannon_index_filelist')="Problem retrieving data:" + xmlhttp.statusText;
  1749. }
  1750. }
  1751. }
  1752. function set_pali_loader_visible(visible){
  1753. if(visible){
  1754. document.getElementById('pc_res_loader').style.display="block"
  1755. editor_show_right_tool_bar(true);
  1756. }
  1757. else{
  1758. document.getElementById('pc_res_loader').style.display="none"
  1759. editor_show_right_tool_bar(false);
  1760. }
  1761. }
  1762. //目录段落勾选动作
  1763. function wizard_toc_par_enable(obj,iParIndex){
  1764. gTocList[iParIndex].enable=obj.checked
  1765. document.getElementById("par_enable_"+gTocList[iParIndex].parNum).checked=obj.checked;
  1766. wizard_palicannon_updata_pali_par_text_enable(gTocList[iParIndex].parNum,obj.checked);
  1767. if(gTocList[iParIndex].level>0){
  1768. endIndex=wizard_palicanon_get_par_end_index(iParIndex)
  1769. for(var iPar=iParIndex+1;iPar<=endIndex;iPar++){
  1770. gTocList[iPar].enable=obj.checked
  1771. document.getElementById("toc_par_enable_"+iPar).checked=obj.checked;
  1772. document.getElementById("par_enable_"+gTocList[iPar].parNum).checked=obj.checked;
  1773. wizard_palicannon_updata_pali_par_text_enable(gTocList[iPar].parNum,obj.checked);
  1774. }
  1775. }
  1776. }
  1777. //文章段落勾选动作
  1778. function par_enable_change(iParNum,obj){
  1779. var parIndex=-1;
  1780. for(var iPar=0;iPar<gTocList.length;iPar++){
  1781. if(iParNum==gTocList[iPar].parNum){
  1782. parIndex=iPar;
  1783. break;
  1784. }
  1785. }
  1786. if(parIndex>=0){
  1787. gTocList[parIndex].enable=obj.checked;
  1788. document.getElementById("toc_par_enable_"+parIndex).checked=obj.checked;
  1789. }
  1790. wizard_palicannon_updata_pali_par_text_enable(iParNum,obj.checked);
  1791. }
  1792. //找到当前第一个可用的段落
  1793. //找到:返回段落号
  1794. //没找到:-1
  1795. function find_first_enable_par(iBeginParNum,strParList){
  1796. var arrayParList=strParList.split(",");
  1797. for(iPar in arrayParList){
  1798. curr = arrayParList[iPar];
  1799. curr++;
  1800. curr--;
  1801. if(curr>=iBeginParNum){
  1802. output = arrayParList[iPar];
  1803. output++;
  1804. output--;
  1805. return(output);
  1806. break;
  1807. }
  1808. }
  1809. return(-1);
  1810. }
  1811. //显示浮动的段落资源窗口
  1812. function palicannon_par_res_show_window(parIndex){
  1813. eWin=document.getElementById("palicannon_par_res_list");
  1814. output="";
  1815. output += "<div id=\"palicannon_par_res_list_title\">";
  1816. output += "<button onclick='book_res_edit_now(2)'>";
  1817. output += "立即编辑</button>";
  1818. output += "<button onclick='book_res_add_to_list(2)'>加入到编辑列表</button><button onclick='book_res_win_close()'>关闭</button>"
  1819. output += "</div>"
  1820. output += "<div id=\"palicannon_par_res_list_body\">";
  1821. output += wizard_palicannon_render_res_list_onepart(parIndex,2);
  1822. output += "</div>";
  1823. eWin.innerHTML = output;
  1824. eWin.style.display="block";
  1825. objParent = document.getElementById("id_pc_nav_par_"+parIndex);
  1826. objInsert = null;
  1827. objParent.insertBefore(eWin,objInsert);
  1828. }
  1829. function book_res_win_close(){
  1830. eWin=document.getElementById("palicannon_par_res_list");
  1831. objParent=document.getElementById("palicannon_par_res_list_shell");
  1832. objInsert=null;
  1833. objParent.insertBefore(eWin,objInsert);
  1834. }
  1835. function wizard_get_toc_from_res(){
  1836. gTocLanguage = new Array()
  1837. gTocLanguageItem = new Array()
  1838. gTocCurrLanguage="pali";
  1839. for(var iPar=0;iPar<gTocList.length;iPar++){
  1840. parTitle=gTocList[iPar].title;
  1841. parHeadingLevel=gTocList[iPar].level;
  1842. parNum=gTocList[iPar].parNum;
  1843. var newObj=Object();
  1844. newObj.par=parNum;
  1845. newObj.language="pali";
  1846. newObj.title=parTitle;
  1847. wizard_push_new_to_toc_language_list("pali");
  1848. var newArray = Array();
  1849. newArray.push(newObj);
  1850. gTocLanguageItem.push(newArray);
  1851. }
  1852. for(x in gResList){
  1853. if(gResList[x].type=="translate"){
  1854. var newObj=Object();
  1855. newObj.par=gResList[x].parNum;
  1856. newObj.language=gResList[x].language;
  1857. newObj.title=gResList[x].title;
  1858. wizard_push_new_to_toc_language_list(newObj.language);
  1859. gTocLanguageItem[newObj.par-1].push(newObj);
  1860. }
  1861. }
  1862. }
  1863. function wizard_push_new_to_toc_language_list(newLanguage){
  1864. for(x in gTocLanguage){
  1865. if(gTocLanguage[x]==newLanguage){
  1866. return;
  1867. }
  1868. }
  1869. gTocLanguage.push(newLanguage)
  1870. }
  1871. function wizard_ger_toc_title(parIndex,language){
  1872. for(var x in gTocLanguageItem[parIndex]){
  1873. if(gTocLanguageItem[parIndex][x].language==language){
  1874. return(gTocLanguageItem[parIndex][x].title);
  1875. }
  1876. }
  1877. return(null);
  1878. }
  1879. function wizard_palicannon_nav_language_change(obj){
  1880. gTocCurrLanguage=obj.value;
  1881. $("#wizard_palicannon_par_select_toc").html(wizard_palicannon_renderBookToc(gTocCurrRoot));
  1882. }
  1883. //重新设定目录的根层级
  1884. function palicannon_par_toc_reset_root(newRoot){
  1885. document.getElementById('wizard_palicannon_par_select_toc').innerHTML=wizard_palicannon_renderBookToc(newRoot);
  1886. var parentArray = new Array();
  1887. currPar=newRoot;
  1888. do{
  1889. iParent=palicannon_par_get_parent(currPar);
  1890. var objParent = new Object();
  1891. objParent.parent=iParent;
  1892. objParent.curr=currPar;
  1893. parentArray.push(objParent);
  1894. //wizard_palicanon_heading_change(iParent,currPar);
  1895. currPar=iParent;
  1896. }
  1897. while(iParent>-1)
  1898. for(var i=parentArray.length-1;i>=0;i--){
  1899. wizard_palicanon_heading_change(parentArray[i].parent,parentArray[i].curr);
  1900. }
  1901. //当改变当前标题时 更新资源列表
  1902. wizard_palicannon_updata_res_info(newRoot);
  1903. //当改变当前标题时 隐藏不需要显示的巴利文本
  1904. wizard_palicanon_updata_pali_text(newRoot);
  1905. }
  1906. function palicannon_par_get_parent(index){
  1907. var currLevel=gTocList[index].level;
  1908. for(var iPar=currLevel;iPar>=0;iPar--){
  1909. if(gTocList[iPar].level>0 && gTocList[iPar].level<currLevel){
  1910. return(iPar)
  1911. }
  1912. }
  1913. return(-1);
  1914. }
  1915. //从服务器获取段落单词数
  1916. var wizard_palicannon_res_word_num_xmlhttp;
  1917. function wizard_palicannon_res_word_num_query(bookId,begin,end){
  1918. if (window.XMLHttpRequest)
  1919. {// code for IE7+, Firefox, Chrome, Opera, Safari
  1920. wizard_palicannon_res_word_num_xmlhttp=new XMLHttpRequest();
  1921. }
  1922. else
  1923. {// code for IE6, IE5
  1924. wizard_palicannon_res_word_num_xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  1925. }
  1926. var d=new Date();
  1927. wizard_palicannon_res_word_num_xmlhttp.onreadystatechange=wizard_palicannon_res_word_num_serverResponse;
  1928. wizard_palicannon_res_word_num_xmlhttp.open("GET","pc_get_word_num.php?t="+d.getTime()+"&book="+bookId+"&begin="+begin+"&end="+end,true);
  1929. wizard_palicannon_res_word_num_xmlhttp.send();
  1930. }
  1931. function get_time_by_min(min){
  1932. if(Math.round(min)==0){
  1933. workload_time="";
  1934. }
  1935. else if(min<60){
  1936. var workload_time=min;
  1937. workload_time=Math.round(workload_time)+gLocal.gui.min;
  1938. }
  1939. else if(min>=60 && min<2400){//60min-40h
  1940. var workload_time=min/60;
  1941. left_lime=(workload_time-Math.round(workload_time))*60;
  1942. workload_time=Math.round(workload_time)+gLocal.gui.h;
  1943. }
  1944. else if(min/60/8<261 && min>=2400){//40h-261天
  1945. var workload_time=min/60/40;
  1946. left_lime=(workload_time-Math.floor(workload_time))*60*40;
  1947. workload_time=Math.floor(workload_time)+gLocal.gui.week
  1948. if(left_lime>=60){
  1949. workload_time+=get_time_by_min(left_lime);
  1950. }
  1951. }
  1952. else if(min/60/8>=261){//一年以上
  1953. var workload_time=min/60/8/261;
  1954. left_lime=(workload_time-Math.floor(workload_time))*60*8*261;
  1955. workload_time=Math.floor(workload_time)+gLocal.gui.year
  1956. if(left_lime>=60){
  1957. workload_time+=get_time_by_min(left_lime);
  1958. }
  1959. }
  1960. return(workload_time);
  1961. }
  1962. function get_shortnum_by_num(num){
  1963. var new_num=""
  1964. if(num<900){
  1965. new_num=Math.round(num);
  1966. }
  1967. else if(num>=900 && num<10000){
  1968. num=num/1000
  1969. new_num=Math.round(num*100)/100+gLocal.gui.num_k
  1970. }
  1971. else if(num>=10000 && num<100000){
  1972. num=num/1000
  1973. new_num=Math.round(num*10)/10+gLocal.gui.num_k
  1974. }
  1975. else if(num>=100000 && num<900000){
  1976. num=num/1000
  1977. new_num=Math.round(num)+gLocal.gui.num_k
  1978. }
  1979. else{
  1980. num=num/1000000
  1981. new_num=Math.round(num*100)/100+gLocal.gui.num_m
  1982. }
  1983. return(new_num);
  1984. }
  1985. //收到资源列表
  1986. function wizard_palicannon_res_word_num_serverResponse(){
  1987. if (wizard_palicannon_res_word_num_xmlhttp.readyState==4)// 4 = "loaded"
  1988. {
  1989. if (wizard_palicannon_res_word_num_xmlhttp.status==200)
  1990. {// 200 = "OK"
  1991. var xmlText = wizard_palicannon_res_word_num_xmlhttp.responseText;
  1992. var wordInfo=xmlText.split(",");
  1993. 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;//總詞數
  1994. 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;//詞匯量
  1995. 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位小數
  1996. document.getElementById('pc_res_par_quotiety').innerHTML=Math.round(wordInfo[2]/wordInfo[3]*100)/100+"-"+Math.round(wordInfo[0]/wordInfo[1]*100)/100;//重複率,取2位小數
  1997. document.getElementById('pc_res_par_tran_workload').innerHTML=get_time_by_min(wordInfo[2]/22.95);//翻译工作量
  1998. document.getElementById('pc_res_par_wbw_workload').innerHTML=get_time_by_min(wordInfo[3]/5.61);//逐词解析工作量
  1999. document.getElementById('pc_res_par_total_workload').innerHTML=get_time_by_min(wordInfo[3]/5.61+wordInfo[2]/22.95);//工作总量
  2000. document.getElementById('pc_res_par_product').innerHTML=get_shortnum_by_num(wordInfo[2]*0.37);//译文预期字数
  2001. var difficulty_lv=Math.round(wordInfo[3]/5.61/wordInfo[0]*100)/10
  2002. document.getElementById('pc_res_par_difficulty').innerHTML=difficulty_lv;//整体复杂度
  2003. document.getElementById('star_lv').innerHTML=get_star_by_lv(difficulty_lv,10,5);//整体复杂度
  2004. }
  2005. else
  2006. {
  2007. //document.getElementById('id_pc_')="Problem retrieving data:" + xmlhttp.statusText;
  2008. }
  2009. }
  2010. }
  2011. function get_star_by_lv(lv,max_lv,max_star){
  2012. var lv=lv*max_star/max_lv;
  2013. var lv_base=Math.floor(lv);
  2014. var lv_end=lv-lv_base;
  2015. var star_str=""
  2016. for(i=0;i<lv_base;i++){
  2017. star_str += "<svg class=\"icon\"><use xlink:href=\"svg/icon.svg#ic_star\"></use></svg>"
  2018. }
  2019. if(lv_end<0.5){
  2020. star_str += "<svg class=\"icon\"><use xlink:href=\"svg/icon.svg#ic_star_border\"></use></svg>"
  2021. }
  2022. else{
  2023. star_str += "<svg class=\"icon\"><use xlink:href=\"svg/icon.svg#ic_star_half\"></use></svg>"
  2024. }
  2025. return(star_str)
  2026. }