wizard.js 73 KB

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