預約系統 IOS / Android Windows

index3.html 67KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  5. <meta name="description" content="">
  6. <meta name="author" content="">
  7. <script src="js/mqttws31.min.js" type="text/javascript"></script>
  8. <script src="js/jquery-3.5.1.min.js"></script>
  9. <script src="js/teacrypt.js" type="text/javascript"></script>
  10. <script type="text/javascript">
  11. var message999;
  12. var message0 ;
  13. var message4 ;
  14. var message9 ;
  15. var message6;
  16. var message7 ;
  17. var message2 ;
  18. var issame=false;
  19. var vvqrcd= '';
  20. var orgcycle='';
  21. var fincycle='';
  22. var orgtimestamp='';
  23. var isconn = false;
  24. var CID = '';
  25. var ID = '';
  26. var PW = '';
  27. var TYPE = '';
  28. var client;
  29. var kname='';
  30. var myclientid='';
  31. var client2;
  32. var myclientid2='';
  33. var tt = '';
  34. var st = '';
  35. var et = '';
  36. var idx = '';
  37. var cy='';
  38. var vtype='';
  39. var vtttt='';
  40. var isget = false;
  41. var isget2 = false;
  42. var isget3 = false;
  43. var vtstpqr='';
  44. var vcyd='';
  45. var vmqtt='';
  46. var SN='';
  47. var SubID='';
  48. var vsn='';
  49. var vobj;
  50. var vvvi;
  51. var ooodata='';
  52. function btback()
  53. {
  54. try
  55. {
  56. document.location = "index2.html?KID="+kkid+"&name="+kname+"&CID="+CID+"&ID="+kkid+"&PW="+PW+"&TYPE="+TYPE+"&SN="+SN+"&MQTT="+vmqtt+"&SubID="+SubID;
  57. }catch(e)
  58. {
  59. alert(e);
  60. }
  61. }
  62. function init()
  63. {
  64. try
  65. {
  66. CID = getUrlParameter('CID');
  67. ID = getUrlParameter('ID');
  68. PW= getUrlParameter('PW');
  69. TYPE= getUrlParameter('TYPE');
  70. SN = getUrlParameter('SN');
  71. vmqtt = getUrlParameter('MQTT');
  72. SubID = getUrlParameter('SubID');
  73. vvvi= getUrlParameter('idx');
  74. kkid= getUrlParameter('ID');
  75. // vvqrcd= vobj.data.data.CardID;
  76. vvqrcd= getUrlParameter('qrcd');
  77. vvqrcd=vvqrcd.replaceAll('-','=');
  78. //updateOutput('init');
  79. /*
  80. CID = getUrlParameter('CID');
  81. ID = getUrlParameter('ID');
  82. PW= getUrlParameter('PW');
  83. TYPE= getUrlParameter('TYPE');
  84. */
  85. //myclientid="Giga"+CID+"1-"+ parseInt(Math.random() * 100000000, 10);
  86. myclientid="GigaPC"+CID+"1-"+SubID;
  87. client = new Paho.MQTT.Client(vmqtt, Number(8083), myclientid);
  88. client.onMessageArrived = onMessageArrived;
  89. client.onConnectionLost = onConnectionLost;
  90. // client.connect( {onSuccess: onConnect});
  91. // client.connect( {onSuccess: onConnect, onFailure : onFailedConnect,timeout: 3,keepAliveInterval: 35,cleanSession : false});
  92. client.connect( {onSuccess: onConnect, onFailure : onFailedConnect});
  93. //
  94. myclientid2="GigaPCT"+CID+"1-"+SubID;
  95. client2 = new Paho.MQTT.Client(vmqtt, Number(8083), myclientid2);
  96. client2.onMessageArrived = onMessageArrived2;
  97. client2.onConnectionLost = onConnectionLost2;
  98. client2.connect( {onSuccess: onConnect2, onFailure : onFailedConnect});
  99. //
  100. tt = getUrlParameter("tt");
  101. orgcycle=tt+';';
  102. orgtimestamp=getUrlParameter("st")+','+getUrlParameter("et");
  103. // alert(orgtimestamp);
  104. orgcycle=orgcycle+orgtimestamp+';';
  105. st ='20'+ getUrlParameter("st").replace('_','T');
  106. st=st.replace('/','-');
  107. st=st.replace('/','-');
  108. et = '20'+ getUrlParameter("et").replace('_','T');
  109. et=et.replace('/','-');
  110. et=et.replace('/','-');
  111. document.getElementById("ItemNOSer").value=tt;
  112. //document.getElementById("sd").value= '2017-06-01T08:30';
  113. //alert(st);
  114. document.getElementById("sd").value= st.split('T')[0];//'2022-09-01';//st;
  115. document.getElementById("sdt1").value= st.split('T')[1];
  116. //let theDay = new Date();
  117. //alert(theDay.toLocaleString('en-US', { hour12: false }));
  118. // alert(et);
  119. document.getElementById("ed").value=et.split('T')[0];
  120. document.getElementById("sdt2").value= et.split('T')[1];
  121. //document.getElementById("ed").value=theDay.toLocaleString('en-US', { hour12: false });
  122. idx= getUrlParameter("idx");
  123. vtype= getUrlParameter("tp");
  124. // ID= getUrlParameter("cid");
  125. //alert(ID);
  126. kname= getUrlParameter("name");
  127. //CID = '886999000230';
  128. //ID = '00000000';
  129. //PW= 'CMM87krWqj8Ltt00';
  130. // TYPE='IOS';
  131. document.getElementById("btn100").innerHTML =kname;
  132. cy= getUrlParameter("cy");
  133. orgcycle=orgcycle+cy+';';
  134. if (vtype=='1')
  135. {
  136. }
  137. if (vtype=='2')
  138. {
  139. //alert(cy);
  140. var vcy = cy.split(',');
  141. //alert(vcy[0]);
  142. if ( vcy[0]=='0000000')
  143. {
  144. }else
  145. {
  146. if (vcy[0].substring(0,1)=='1'){document.getElementById("d11").style.background="url('image/bgreen.png') no-repeat center/100%";}
  147. //days.push('日');
  148. if (vcy[0].substring(1,2)=='1'){document.getElementById("d12").style.background="url('image/bgreen.png') no-repeat center/100%";}
  149. //days.push('一');
  150. if (vcy[0].substring(2,3)=='1'){document.getElementById("d13").style.background="url('image/bgreen.png') no-repeat center/100%";}
  151. //days.push('二');
  152. if (vcy[0].substring(3,4)=='1'){document.getElementById("d14").style.background="url('image/bgreen.png') no-repeat center/100%";}
  153. //days.push('三');
  154. if (vcy[0].substring(4,5)=='1'){document.getElementById("d15").style.background="url('image/bgreen.png') no-repeat center/100%";}
  155. //days.push('四');
  156. if (vcy[0].substring(5,6)=='1'){document.getElementById("d16").style.background="url('image/bgreen.png') no-repeat center/100%";}
  157. //days.push('五');
  158. if (vcy[0].substring(6,7)=='1'){document.getElementById("d17").style.background="url('image/bgreen.png') no-repeat center/100%";}
  159. //days.push('六');
  160. document.getElementById("st1").value= vcy[1].substring(0,2)+':'+vcy[1].substring(2,4);
  161. document.getElementById("et1").value=vcy[2].substring(0,2)+':'+vcy[2].substring(2,4);
  162. }
  163. if ( vcy[3]=='0000000')
  164. {
  165. }else
  166. {
  167. if (vcy[3].substring(0,1)=='1')
  168. {document.getElementById("d21").style.background="url('image/bgreen.png') no-repeat center/100%";}
  169. //days.push('日');
  170. if (vcy[3].substring(1,2)=='1'){document.getElementById("d22").style.background="url('image/bgreen.png') no-repeat center/100%";}
  171. //days.push('一');
  172. if (vcy[3].substring(2,3)=='1'){document.getElementById("d23").style.background="url('image/bgreen.png') no-repeat center/100%";}
  173. //days.push('二');
  174. if (vcy[3].substring(3,4)=='1'){document.getElementById("d24").style.background="url('image/bgreen.png') no-repeat center/100%";}
  175. //days.push('三');
  176. if (vcy[3].substring(4,5)=='1'){document.getElementById("d25").style.background="url('image/bgreen.png') no-repeat center/100%";}
  177. //days.push('四');
  178. if (vcy[3].substring(5,6)=='1'){document.getElementById("d26").style.background="url('image/bgreen.png') no-repeat center/100%";}
  179. //days.push('五');
  180. if (vcy[3].substring(6,7)=='1'){document.getElementById("d27").style.background="url('image/bgreen.png') no-repeat center/100%";}
  181. //days.push('六');
  182. document.getElementById("st2").value= vcy[4].substring(0,2)+':'+vcy[4].substring(2,4);
  183. document.getElementById("et2").value=vcy[5].substring(0,2)+':'+vcy[5].substring(2,4);
  184. }
  185. if ( vcy[6]=='0000000')
  186. {
  187. }else
  188. {
  189. if (vcy[6].substring(0,1)=='1')
  190. {document.getElementById("d31").style.background="url('image/bgreen.png') no-repeat center/100%";}
  191. //days.push('日');
  192. if (vcy[6].substring(1,2)=='1')
  193. {document.getElementById("d32").style.background="url('image/bgreen.png') no-repeat center/100%";}
  194. //days.push('一');
  195. if (vcy[6].substring(2,3)=='1')
  196. {document.getElementById("d33").style.background="url('image/bgreen.png') no-repeat center/100%";}
  197. //days.push('二');
  198. if (vcy[6].substring(3,4)=='1')
  199. {document.getElementById("d34").style.background="url('image/bgreen.png') no-repeat center/100%";}
  200. //days.push('三');
  201. if (vcy[6].substring(4,5)=='1')
  202. {document.getElementById("d35").style.background="url('image/bgreen.png') no-repeat center/100%";}
  203. //days.push('四');
  204. if (vcy[6].substring(5,6)=='1')
  205. {document.getElementById("d36").style.background="url('image/bgreen.png') no-repeat center/100%";}
  206. //days.push('五');
  207. if (vcy[6].substring(6,7)=='1')
  208. {document.getElementById("d37").style.background="url('image/bgreen.png') no-repeat center/100%";}
  209. //days.push('六');
  210. document.getElementById("st3").value= vcy[7].substring(0,2)+':'+vcy[7].substring(2,4);
  211. document.getElementById("et3").value=vcy[8].substring(0,2)+':'+vcy[8].substring(2,4);
  212. }
  213. }
  214. //alert(orgcycle);
  215. //updateOutput('CID='+CID);
  216. //updateOutput('ID='+ID);
  217. //updateOutput('PW='+PW);
  218. //updateOutput('TYPE='+TYPE);
  219. if (TYPE=='ANDROID')
  220. {
  221. connect();
  222. }
  223. vsn='';
  224. }catch(e)
  225. {
  226. alert(e);
  227. }
  228. }
  229. function onConnectionLost(message)
  230. {
  231. //alert('連線失敗或重複登入');
  232. //document.location = "index.html?TYPE=PC&ID=00000000";
  233. client.connect( {onSuccess: onConnect, onFailure : onFailedConnect});
  234. }
  235. function onConnectionLost2(message)
  236. {
  237. //alert('連線失敗或重複登入');
  238. //document.location = "index.html?TYPE=PC&ID=00000000";
  239. client2.connect( {onSuccess: onConnect2, onFailure : onFailedConnect});
  240. }
  241. function onMessageArrived2(message)
  242. {
  243. var errda = message.payloadString;
  244. if (errda.startsWith('modify'))
  245. {
  246. try
  247. {
  248. var kkdd = errda.split(',');
  249. if (kkdd[3]==kname)
  250. {
  251. if (kkdd[1]==idx)
  252. {
  253. if (kkdd[2]!=SubID)
  254. {
  255. alert('此筆資料已修改');
  256. window.history.go(-1);
  257. }
  258. }
  259. }
  260. else
  261. {
  262. }
  263. }catch
  264. {}
  265. }
  266. }
  267. function onMessageArrived(message)
  268. {
  269. var errda = message.payloadString;
  270. if (errda.startsWith('modify'))
  271. {
  272. try
  273. {
  274. var kkdd = errda.split(',');
  275. if (kkdd[3]==kname)
  276. {
  277. if (kkdd[1]==idx)
  278. {
  279. if (kkdd[2]!=SubID)
  280. {
  281. alert('此筆資料已修改');
  282. window.history.go(-1);
  283. }
  284. }
  285. }
  286. else
  287. {
  288. }
  289. }catch
  290. {}
  291. }else
  292. {
  293. vobj = JSON.parse( errda);
  294. var jsonString = "{\"action\":\"decode\", \"serial\":\"002\",\"data\":\""+vobj.data+"\"}";
  295. //updateOutput('----------------------------------------------');
  296. //updateOutput(jsonString);
  297. if (vsn=='001')
  298. {
  299. vsn='002';
  300. }
  301. else if (vsn=='003')
  302. {
  303. vsn='004';
  304. }
  305. else if (vsn=='102')
  306. {
  307. jsonString = "{\"action\":\"decode\", \"serial\":\"103\",\"data\":\""+vobj.data+"\"}"
  308. vsn='103';
  309. //alert('103');
  310. //alert(errda);
  311. }
  312. //alert(vsn);
  313. /// "WebToApp". 為我們和前端開發人員的約定
  314. if (TYPE=='IOS')
  315. {
  316. window.webkit.messageHandlers.WebToApp.postMessage(jsonString);
  317. }
  318. if (TYPE=='ANDROID')
  319. {
  320. webSocket.send(jsonString);
  321. }
  322. if (TYPE=='PC')
  323. {
  324. selfendecode(vobj.data);
  325. }
  326. }
  327. }
  328. function onFailedConnect()
  329. {
  330. //alert('連線異常');
  331. }
  332. function onConnect()
  333. {
  334. isconn=true;
  335. client.subscribe('ReservePC'+CID+'1-'+SubID);
  336. try
  337. {
  338. }
  339. catch(e)
  340. {
  341. alert(e);
  342. }
  343. //alert('c');
  344. }
  345. function onConnect2()
  346. {
  347. client2.subscribe('Reserve'+CID+'1-'+SubID);
  348. try
  349. {
  350. }
  351. catch(e)
  352. {
  353. alert(e);
  354. }
  355. //alert('c');
  356. }
  357. </script>
  358. <title>預約 QR Code</title>
  359. <link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" />
  360. </head>
  361. <body class="text-center" onload="init()">
  362. <div>
  363. <div class="card" style="width: 480px ;box-shadow: 0px 0px 1px 1px rgba(0,0,0,0.1);margin: 21px auto;background-color:#FFFFFF;">
  364. <table style="width: 100%">
  365. <tbody>
  366. <tr>
  367. <td style="width: 33.3%"><button type="button" style="border-color: #dcdcdc;border-width: 0px;border-color: #dcdcdc;border-width: 0px;margin: 0px 0px 0px 0px;color:#787878;font-family: Roboto_Light; font-size: 24px;width: 110px; height: 60px; background-color: transparent;width:100%;" onclick="btback()"><img src="image/arrowiosback.png" width="40" height="40" style=" margin: -8px 0px 0px -120px ;" alt=""/></button></td><td style="width: 33.3%"><button type="button" style="border-color: #dcdcdc;border-width: 1px;border-color: #dcdcdc;border-width: 1px;margin: 0px 0px 0px 0px;color:#787878;font-family: Roboto_Light; font-size: 24px;width: 110px; height: 60px; background-color: #cce8fc;width:100%;" hidden onclick="pcbtnSaveTmp()"'+
  368. '>複製</button> </td><td style="width: 33.3%"><button type="button" style="border-color: #dcdcdc;border-width: 1px;border-color: #dcdcdc;border-width: 1px;margin: 0px 0px 0px 0px;color:#FFFFFF;font-family: Roboto_Light; font-size: 24px;width: 110px; height: 60px; background-color: #64c800;width:100%;" hidden onclick="pcbtnSaveqr()">下載</button></td>
  369. </tbody>
  370. </table>
  371. <div style="margin: 1px 0 0px 1px;background-color:#FFFFFF;" >
  372. <button id="btn100" style="margin: 2px 0px 0px 0px;outline:none;line-height:40px;vertical-align: middle; text-align: left;width:100%;border:0px white none;background-color:#FFFFFF;font-family:Roboto_Light;font-size:24px;color:#646464;height:42px;"></button>
  373. </div>
  374. <div style="text-align:center">
  375. <!-- <h1 class="h3 mb-3 font-weight-normal">預收貨款</h1> -->
  376. <!-- <form class="form-signin" id="senddocument"> -->
  377. <div style="margin: 3px 9px 3px 9px;text-align:left;">
  378. <label style="margin: 5px 0px 5px 0px;font-family:Roboto_Light;font-size:24px;color:#646464;border:none;width: 100px;">預約人&nbsp:&nbsp </label><input type="text" id="ItemNOSer" style="height:40px;box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.5);margin: 5px 0px 5px 0px;font-family:Roboto_Light;font-size:20px;color:#646464;border:none;width:calc(99% - 100px);" placeholder="" required></div>
  379. <div style="margin: 3px 9px 3px 9px;text-align:left;">
  380. <label style="margin: 5px 0px 5px 0px;font-family:Roboto_Light;font-size:24px;color:#646464;border:none;width: 100px;">開始日&nbsp:&nbsp </label><input type="date" id="sd" style="height:40px;box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.5);width: calc(99% - 100px);margin: 5px 0px 5px 0px;font-family:Roboto_Light;font-size:20px;color:#646464;border:none;"></div>
  381. <div style="margin: 3px 9px 3px 9px;text-align:left;">
  382. <label style="margin: 5px 0px 5px 0px;font-family:Roboto_Light;font-size:24px;color:#646464;border:none;width: 100px;">開始時&nbsp:&nbsp </label><input type="time" id="sdt1" style="height:40px;box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.5);width: calc(99% - 100px);margin: 5px 0px 5px 0px;font-family:Roboto_Light;font-size:20px;color:#646464;border:none;"></div>
  383. <div style="margin: 3px 9px 3px 9px;text-align:left;">
  384. <label style="margin: 5px 0px 5px 0px;font-family:Roboto_Light;font-size:24px;color:#646464;border:none;width: 100px;">結束日&nbsp:&nbsp </label><input type="date" id="ed" style="height:40px;box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.5);width: calc(99% - 100px);margin: 5px 0px 5px 0px;font-family:Roboto_Light;font-size:20px;color:#646464;border:none;"></div>
  385. <div style="margin: 3px 9px 3px 9px;text-align:left;">
  386. <label style="margin: 5px 0px 5px 0px;font-family:Roboto_Light;font-size:24px;color:#646464;border:none;width: 100px;">結束時&nbsp:&nbsp </label><input type="time" id="sdt2" style="height:40px;box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.5);width: calc(99% - 100px);margin: 5px 0px 5px 0px;font-family:Roboto_Light;font-size:20px;color:#646464;border:none;"></div>
  387. <hr style="margin: 23px 9px 15px 9px;border: solid 1px #979797;">
  388. <table style="width: 100%">
  389. <tbody>
  390. <tr>
  391. <td style="width: 13%;text-align: center; vertical-align: middle;">
  392. <button id ='d11' type="button" style="padding:0px 0px 0px 0px;border-width: 0px;margin: 0px 0px 5px 0px;color:#787878;font-family: Roboto_Light; font-size: 24px; height: 40px;background-color:#FFFFFF;width:40px;background-image: url(image/bgrey.png); background-repeat: no-repeat;background-size: 40px 40px;" onclick="btnitemback(this.id)">日</button>
  393. </td>
  394. <td style="width: 13%;text-align: center; vertical-align: middle;">
  395. <button id ='d12' type="button" style="padding:0px 0px 0px 0px;border-width: 0px;margin: 0px 0px 5px 0px;color:#787878;font-family: Roboto_Light; font-size: 24px; height: 40px;background-color:#FFFFFF;width:40px;background-image: url(image/bgrey.png) ; background-repeat: no-repeat;background-size: 40px 40px;" onclick="btnitemback(this.id)">一</button>
  396. </td>
  397. <td style="width: 13%;text-align: center; vertical-align: middle;">
  398. <button id ='d13' type="button" style="padding:0px 0px 0px 0px;border-width: 0px;margin: 0px 0px 5px 0px;color:#787878;font-family: Roboto_Light; font-size: 24px; height: 40px;background-color:#FFFFFF;width:40px;background-image: url(image/bgrey.png); background-repeat: no-repeat;background-size: 40px 40px;" onclick="btnitemback(this.id)">二</button>
  399. </td>
  400. <td style="width: 13%;text-align: center; vertical-align: middle;">
  401. <button id ='d14' type="button" style="padding:0px 0px 0px 0px;border-width: 0px;margin: 0px 0px 5px 0px;color:#787878;font-family: Roboto_Light; font-size: 24px; height: 40px;background-color:#FFFFFF;width:40px;background-image: url(image/bgrey.png); background-repeat: no-repeat;background-size: 40px 40px;" onclick="btnitemback(this.id)">三</button>
  402. </td>
  403. <td style="width: 13%;text-align: center; vertical-align: middle;">
  404. <button id ='d15' type="button" style="padding:0px 0px 0px 0px;border-width: 0px;margin: 0px 0px 5px 0px;color:#787878;font-family: Roboto_Light; font-size: 24px; height: 40px;background-color:#FFFFFF;width:40px;background-image: url(image/bgrey.png); background-repeat: no-repeat;background-size: 40px 40px;" onclick="btnitemback(this.id)">四</button>
  405. </td>
  406. <td style="width: 13%;text-align: center; vertical-align: middle;">
  407. <button id ='d16' type="button" style="padding:0px 0px 0px 0px;border-width: 0px;margin: 0px 0px 5px 0px;color:#787878;font-family: Roboto_Light; font-size: 24px; height: 40px;background-color:#FFFFFF;width:40px;background-image: url(image/bgrey.png); background-repeat: no-repeat;background-size: 40px 40px;" onclick="btnitemback(this.id)">五</button>
  408. </td>
  409. <td style="width: 13%;text-align: center; vertical-align: middle;">
  410. <button id ='d17' type="button" style="padding:0px 0px 0px 0px;border-width: 0px;margin: 0px 0px 5px 0px;color:#787878;font-family: Roboto_Light; font-size: 24px; height: 40px;background-color:#FFFFFF;width:40px;background-image: url(image/bgrey.png); background-repeat: no-repeat;background-size: 40px 40px;" onclick="btnitemback(this.id)" >六</button>
  411. </td>
  412. </tbody>
  413. </table>
  414. </div>
  415. <div style="margin: 3px 9px 3px 9px;text-align:left;">
  416. <label style="margin: 5px 0px 5px 0px;font-family:Roboto_Light;font-size:24px;color:#646464;border:none;width: 100px;">開始時&nbsp:&nbsp </label><input type="time" id="st1" style="height:40px;box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.5);width: calc(99% - 100px);margin: 5px 0px 5px 0px;font-family:Roboto_Light;font-size:20px;color:#646464;border:none;"></div>
  417. <div style="margin: 3px 9px 3px 9px;text-align:left;">
  418. <label style="margin: 5px 0px 5px 0px;font-family:Roboto_Light;font-size:24px;color:#646464;border:none;width: 100px;">結束時&nbsp:&nbsp </label><input type="time" id="et1" style="height:40px;box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.5);width: calc(99% - 100px);margin: 5px 0px 5px 0px;font-family:Roboto_Light;font-size:20px;color:#646464;border:none;"></div>
  419. <hr style="margin: 23px 9px 15px 9px;border: solid 1px #979797;">
  420. <table style="width: 100%">
  421. <tbody>
  422. <tr>
  423. <td style="width: 13%;text-align: center; vertical-align: middle;">
  424. <button id ='d21' type="button" style="padding:0px 0px 0px 0px;border-width: 0px;margin: 0px 0px 5px 0px;color:#787878;font-family: Roboto_Light; font-size: 24px; height: 40px;background-color:#FFFFFF;width:40px;background-image: url(image/bgrey.png); background-repeat: no-repeat;background-size: 40px 40px;" onclick="btnitemback(this.id)">日</button>
  425. </td>
  426. <td style="width: 13%;text-align: center; vertical-align: middle;">
  427. <button id ='d22' type="button" style="padding:0px 0px 0px 0px;border-width: 0px;margin: 0px 0px 5px 0px;color:#787878;font-family: Roboto_Light; font-size: 24px; height: 40px;background-color:#FFFFFF;width:40px;background-image: url(image/bgrey.png); background-repeat: no-repeat;background-size: 40px 40px;" onclick="btnitemback(this.id)">一</button>
  428. </td>
  429. <td style="width: 13%;text-align: center; vertical-align: middle;">
  430. <button id ='d23' type="button" style="padding:0px 0px 0px 0px;padding:0px 0px 0px 0px;border-width: 0px;margin: 0px 0px 5px 0px;color:#787878;font-family: Roboto_Light; font-size: 24px; height: 40px;background-color:#FFFFFF;width:40px;background-image: url(image/bgrey.png); background-repeat: no-repeat;background-size: 40px 40px;" onclick="btnitemback(this.id)">二</button>
  431. </td>
  432. <td style="width: 13%;text-align: center; vertical-align: middle;">
  433. <button id ='d24' type="button" style="padding:0px 0px 0px 0px;border-width: 0px;margin: 0px 0px 5px 0px;color:#787878;font-family: Roboto_Light; font-size: 24px; height: 40px;background-color:#FFFFFF;width:40px;background-image: url(image/bgrey.png); background-repeat: no-repeat;background-size: 40px 40px;" onclick="btnitemback(this.id)">三</button>
  434. </td>
  435. <td style="width: 13%;text-align: center; vertical-align: middle;">
  436. <button id ='d25' type="button" style="padding:0px 0px 0px 0px;border-width: 0px;margin: 0px 0px 5px 0px;color:#787878;font-family: Roboto_Light; font-size: 24px; height: 40px;background-color:#FFFFFF;width:40px;background-image: url(image/bgrey.png); background-repeat: no-repeat;background-size: 40px 40px;" onclick="btnitemback(this.id)">四</button>
  437. </td>
  438. <td style="width: 13%;text-align: center; vertical-align: middle;">
  439. <button id ='d26' type="button" style="padding:0px 0px 0px 0px;border-width: 0px;margin: 0px 0px 5px 0px;color:#787878;font-family: Roboto_Light; font-size: 24px; height: 40px;background-color:#FFFFFF;width:40px;background-image: url(image/bgrey.png); background-repeat: no-repeat;background-size: 40px 40px;" onclick="btnitemback(this.id)">五</button>
  440. </td>
  441. <td style="width: 13%;text-align: center; vertical-align: middle;">
  442. <button id ='d27' type="button" style="padding:0px 0px 0px 0px;border-width: 0px;margin: 0px 0px 5px 0px;color:#787878;font-family: Roboto_Light; font-size: 24px; height: 40px;background-color:#FFFFFF;width:40px;background-image: url(image/bgrey.png); background-repeat: no-repeat;background-size: 40px 40px;" onclick="btnitemback(this.id)" >六</button>
  443. </td>
  444. </tbody>
  445. </table>
  446. <div style="margin: 3px 9px 3px 9px;text-align:left;">
  447. <label style="margin: 5px 0px 5px 0px;font-family:Roboto_Light;font-size:24px;color:#646464;border:none;width: 100px;">開始時&nbsp:&nbsp </label><input type="time" id="st2" style="height:40px;box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.5);width: calc(99% - 100px);margin: 5px 0px 5px 0px;font-family:Roboto_Light;font-size:20px;color:#646464;border:none;"></div>
  448. <div style="margin: 3px 9px 3px 9px;text-align:left;">
  449. <label style="margin: 5px 0px 5px 0px;font-family:Roboto_Light;font-size:24px;color:#646464;border:none;width: 100px;">結束時&nbsp:&nbsp </label><input type="time" id="et2" style="height:40px;box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.5);width: calc(99% - 100px);margin: 5px 0px 5px 0px;font-family:Roboto_Light;font-size:20px;color:#646464;border:none;"></div>
  450. <hr style="margin: 23px 9px 15px 9px;border: solid 1px #979797;">
  451. <table style="width: 100%">
  452. <tbody>
  453. <tr>
  454. <td style="width: 13%;text-align: center; vertical-align: middle;">
  455. <button id ='d31' type="button" style="padding:0px 0px 0px 0px;border-width: 0px;margin: 0px 0px 5px 0px;color:#787878;font-family: Roboto_Light; font-size: 24px; height: 40px;background-color:#FFFFFF;width:40px;background-image: url(image/bgrey.png); background-repeat: no-repeat;background-size: 40px 40px;" onclick="btnitemback(this.id)">日</button>
  456. </td>
  457. <td style="width: 13%;text-align: center; vertical-align: middle;">
  458. <button id ='d32' type="button" style="padding:0px 0px 0px 0px;border-width: 0px;margin: 0px 0px 5px 0px;color:#787878;font-family: Roboto_Light; font-size: 24px; height: 40px;background-color:#FFFFFF;width:40px;background-image: url(image/bgrey.png); background-repeat: no-repeat;background-size: 40px 40px;" onclick="btnitemback(this.id)">一</button>
  459. </td>
  460. <td style="width: 13%;text-align: center; vertical-align: middle;">
  461. <button id ='d33' type="button" style="padding:0px 0px 0px 0px;border-width: 0px;margin: 0px 0px 5px 0px;color:#787878;font-family: Roboto_Light; font-size: 24px; height: 40px;background-color:#FFFFFF;width:40px;background-image: url(image/bgrey.png); background-repeat: no-repeat;background-size: 40px 40px;" onclick="btnitemback(this.id)">二</button>
  462. </td>
  463. <td style="width: 13%;text-align: center; vertical-align: middle;">
  464. <button id ='d34' type="button" style="padding:0px 0px 0px 0px;border-width: 0px;margin: 0px 0px 5px 0px;color:#787878;font-family: Roboto_Light; font-size: 24px; height: 40px;background-color:#FFFFFF;width:40px;background-image: url(image/bgrey.png); background-repeat: no-repeat;background-size: 40px 40px;" onclick="btnitemback(this.id)">三</button>
  465. </td>
  466. <td style="width: 13%;text-align: center; vertical-align: middle;">
  467. <button id ='d35' type="button" style="padding:0px 0px 0px 0px;border-width: 0px;margin: 0px 0px 5px 0px;color:#787878;font-family: Roboto_Light; font-size: 24px; height: 40px;background-color:#FFFFFF;width:40px;background-image: url(image/bgrey.png); background-repeat: no-repeat;background-size: 40px 40px;" onclick="btnitemback(this.id)">四</button>
  468. </td>
  469. <td style="width: 13%;text-align: center; vertical-align: middle;">
  470. <button id ='d36' type="button" style="padding:0px 0px 0px 0px;border-width: 0px;margin: 0px 0px 5px 0px;color:#787878;font-family: Roboto_Light; font-size: 24px; height: 40px;background-color:#FFFFFF;width:40px;background-image: url(image/bgrey.png); background-repeat: no-repeat;background-size: 40px 40px;" onclick="btnitemback(this.id)">五</button>
  471. </td>
  472. <td style="width: 13%;text-align: center; vertical-align: middle;">
  473. <button id ='d37' type="button" style="padding:0px 0px 0px 0px;border-width: 0px;margin: 0px 0px 5px 0px;color:#787878;font-family: Roboto_Light; font-size: 24px; height: 40px;background-color:#FFFFFF;width:40px;background-image: url(image/bgrey.png); background-repeat: no-repeat;background-size: 40px 40px;" onclick="btnitemback(this.id)" >六</button>
  474. </td>
  475. </tbody>
  476. </table>
  477. <div style="margin: 3px 9px 3px 9px;text-align:left;">
  478. <label style="margin: 5px 0px 5px 0px;font-family:Roboto_Light;font-size:24px;color:#646464;border:none;width: 100px;">開始時&nbsp:&nbsp </label><input type="time" id="st3" style="height:40px;box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.5);width: calc(99% - 100px);margin: 5px 0px 5px 0px;font-family:Roboto_Light;font-size:20px;color:#646464;border:none;"></div>
  479. <div style="margin: 3px 9px 3px 9px;text-align:left;">
  480. <label style="margin: 5px 0px 5px 0px;font-family:Roboto_Light;font-size:24px;color:#646464;border:none;width: 100px;">結束時&nbsp:&nbsp </label><input type="time" id="et3" style="height:40px;box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.5);width: calc(99% - 100px);margin: 5px 0px 5px 0px;font-family:Roboto_Light;font-size:20px;color:#646464;border:none;"></div>
  481. </br>
  482. <table style="width: 100%">
  483. <tbody>
  484. <tr>
  485. <td style="width: 33.3%"><button type="button" style="border-color: #dcdcdc;border-width: 1px;border-color: #dcdcdc;border-width: 1px;margin: 0px 0px 20px 0px;color:#787878;font-family: Roboto_Light; font-size: 24px;width: 110px; height: 60px; background-color: rgba(255, 0, 20, 0.2);width:100%;" onclick="btndddel()">刪除</button></td><td style="width: 33.3%"><button type="button" style="border-color: #dcdcdc;border-width: 1px;border-color: #dcdcdc;border-width: 1px;margin: 0px 0px 20px 0px;color:#787878;font-family: Roboto_Light; font-size: 24px;width: 110px; height: 60px; background-color: #cce8fc;width:100%;" onclick="btnSaveTmp()"'+
  486. '>儲存</button> </td><td style="width: 33.3%"><button type="button" style="border-color: #dcdcdc;border-width: 1px;border-color: #dcdcdc;border-width: 1px;margin: 0px 0px 20px 0px;color:#FFFFFF;font-family: Roboto_Light; font-size: 24px;width: 110px; height: 60px; background-color: #64c800;width:100%;" onclick="btnSaveqr()">預約</button></td>
  487. </tbody>
  488. </table>
  489. </div>
  490. </div>
  491. <div id="output" style="display:none">
  492. <h2>Output</h2>
  493. </div>
  494. <script type="text/javascript">
  495. function btnSaveTmp()
  496. {
  497. try
  498. {
  499. issame=false;
  500. //alert(idx);
  501. var vvee1='';
  502. var vvee2='';
  503. var vvee3='';
  504. var cycy='';
  505. var st1 = '0000' ;
  506. var et1= '0000' ;
  507. var st2 = '0000' ;
  508. var et2= '0000' ;
  509. var st3 = '0000' ;
  510. var et3= '0000' ;
  511. //12345
  512. var vItemNOSer=document.getElementById("ItemNOSer").value;
  513. if (vItemNOSer.length<1)
  514. {
  515. alert('請輸入預約人');
  516. return;
  517. }
  518. if((document.getElementById("sd").value<1) || (document.getElementById("ed").value<1) ||(document.getElementById("sdt1").value<1) || (document.getElementById("sdt2").value<1))
  519. {
  520. alert('請輸入開始與結束日期時間');
  521. return;
  522. }
  523. var vsdsd=document.getElementById("sd").value+'T'+document.getElementById("sdt1").value;
  524. //alert(vsdsd);
  525. //return;
  526. var veded =document.getElementById("ed").value+'T'+document.getElementById("sdt2").value;
  527. //alert(veded);
  528. if ((vsdsd.length<2)|| (veded.length<2))
  529. {
  530. alert('請輸入開始與結束日期時間');
  531. return;
  532. }
  533. //alert('pass');
  534. if (vsdsd.length>16)
  535. {
  536. vsdsd=vsdsd.substring(0,16);
  537. }
  538. if (veded.length>16)
  539. {
  540. veded=veded.substring(0,16);
  541. }
  542. vsdsd=vsdsd.replace('T','_');
  543. vsdsd=vsdsd.replace('-','/');
  544. vsdsd=vsdsd.replace('-','/');
  545. veded=veded.replace('T','_');
  546. veded=veded.replace('-','/');
  547. veded=veded.replace('-','/');
  548. vsdsd=vsdsd.substring(2,vsdsd.length);
  549. veded=veded.substring(2,veded.length);
  550. //alert(vsdsd);
  551. //alert(veded);
  552. var vtstp=vsdsd+','+veded;
  553. //alert(vtstp);
  554. //return;
  555. //if (document.getElementById("d11").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png')
  556. if (document.getElementById("d11").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  557. {
  558. vvee1='1';
  559. //alert('bgreen');
  560. }else
  561. {
  562. vvee1='0';
  563. //alert('bgrey');
  564. }
  565. if (document.getElementById("d12").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  566. {
  567. vvee1=vvee1+'1';
  568. }else
  569. {
  570. vvee1=vvee1+'0';
  571. }
  572. if (document.getElementById("d13").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  573. {
  574. vvee1=vvee1+'1';
  575. }else
  576. {
  577. vvee1=vvee1+'0';
  578. }
  579. if (document.getElementById("d14").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  580. {
  581. vvee1=vvee1+'1';
  582. }else
  583. {
  584. vvee1=vvee1+'0';
  585. }
  586. if (document.getElementById("d15").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  587. {
  588. vvee1=vvee1+'1';
  589. }else
  590. {
  591. vvee1=vvee1+'0';
  592. }
  593. if (document.getElementById("d16").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  594. {
  595. vvee1=vvee1+'1';
  596. }else
  597. {
  598. vvee1=vvee1+'0';
  599. }
  600. if (document.getElementById("d17").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  601. {
  602. vvee1=vvee1+'1';
  603. }else
  604. {
  605. vvee1=vvee1+'0';
  606. }
  607. //alert(vvee1);
  608. if (document.getElementById("d21").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  609. {
  610. vvee2='1';
  611. //alert('bgreen');
  612. }else
  613. {
  614. vvee2='0';
  615. //alert('bgrey');
  616. }
  617. if (document.getElementById("d22").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  618. {
  619. vvee2=vvee2+'1';
  620. }else
  621. {
  622. vvee2=vvee2+'0';
  623. }
  624. if (document.getElementById("d23").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  625. {
  626. vvee2=vvee2+'1';
  627. }else
  628. {
  629. vvee2=vvee2+'0';
  630. }
  631. if (document.getElementById("d24").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  632. {
  633. vvee2=vvee2+'1';
  634. }else
  635. {
  636. vvee2=vvee2+'0';
  637. }
  638. if (document.getElementById("d25").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  639. {
  640. vvee2=vvee2+'1';
  641. }else
  642. {
  643. vvee2=vvee2+'0';
  644. }
  645. if (document.getElementById("d26").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  646. {
  647. vvee2=vvee2+'1';
  648. }else
  649. {
  650. vvee2=vvee2+'0';
  651. }
  652. if (document.getElementById("d27").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  653. {
  654. vvee2=vvee2+'1';
  655. }else
  656. {
  657. vvee2=vvee2+'0';
  658. }
  659. // alert(vvee2);
  660. if (document.getElementById("d31").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  661. {
  662. vvee3='1';
  663. //alert('bgreen');
  664. }else
  665. {
  666. vvee3='0';
  667. //alert('bgrey');
  668. }
  669. if (document.getElementById("d32").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  670. {
  671. vvee3=vvee3+'1';
  672. }else
  673. {
  674. vvee3=vvee3+'0';
  675. }
  676. if (document.getElementById("d33").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  677. {
  678. vvee3=vvee3+'1';
  679. }else
  680. {
  681. vvee3=vvee3+'0';
  682. }
  683. if (document.getElementById("d34").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  684. {
  685. vvee3=vvee3+'1';
  686. }else
  687. {
  688. vvee3=vvee3+'0';
  689. }
  690. if (document.getElementById("d35").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  691. {
  692. vvee3=vvee3+'1';
  693. }else
  694. {
  695. vvee3=vvee3+'0';
  696. }
  697. if (document.getElementById("d36").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  698. {
  699. vvee3=vvee3+'1';
  700. }else
  701. {
  702. vvee3=vvee3+'0';
  703. }
  704. if (document.getElementById("d37").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  705. {
  706. vvee3=vvee3+'1';
  707. }else
  708. {
  709. vvee3=vvee3+'0';
  710. }
  711. //alert(vvee3);
  712. var ktype = '1';
  713. if (vvee1=='0000000')
  714. {
  715. }else
  716. {
  717. ktype='2';
  718. st1 = document.getElementById("st1").value.replace(':','') ;
  719. et1= document.getElementById("et1").value.replace(':','') ;
  720. if (st1.length==0 || et1.length==0)
  721. {
  722. alert('請選擇時段1的起始與結束時間');
  723. return;
  724. }
  725. }
  726. if (vvee2=='0000000')
  727. {
  728. }else
  729. {
  730. ktype='2';
  731. st2 = document.getElementById("st2").value.replace(':','') ;
  732. et2= document.getElementById("et2").value.replace(':','') ;
  733. if (st2.length==0 || et2.length==0)
  734. {
  735. alert('請選擇時段2的起始與結束時間');
  736. return;
  737. }
  738. }
  739. if (vvee3=='0000000')
  740. {
  741. }else
  742. {
  743. ktype='2';
  744. st3 = document.getElementById("st3").value.replace(':','') ;
  745. et3= document.getElementById("et3").value.replace(':','') ;
  746. //alert(st3.length)
  747. if (st3.length==0 || et3.length==0)
  748. {
  749. alert('請選擇時段3的起始與結束時間');
  750. return;
  751. }
  752. }
  753. //alert(ktype);
  754. if (ktype=='2')
  755. {
  756. cycy=vvee1+','+st1 +','+ et1+','+ vvee2+','+st2+','+et2+','+vvee3+','+st3+','+et3;
  757. }
  758. else
  759. {
  760. //cycy='';
  761. }
  762. // alert(ktype);
  763. //updateOutput('cycy='+cycy);
  764. //alert(cycy);
  765. fincycle='';
  766. fincycle= document.getElementById("ItemNOSer").value+';';
  767. fincycle=fincycle+ vtstp+';';
  768. fincycle=fincycle+cycy+';';
  769. //alert(cycy);
  770. // alert(fincycle);
  771. if (orgcycle==fincycle)
  772. {
  773. issame=true;
  774. // alert('相同');
  775. }
  776. if (issame)
  777. {
  778. alert('OK');
  779. window.history.go(-1);
  780. }
  781. else
  782. {
  783. var vt=new Date().format("yyyy/MM/dd_HH:mm:ss");
  784. //alert(document.getElementById("ItemNOSer").value);
  785. vtttt = document.getElementById("ItemNOSer").value;
  786. // alert(ktype);
  787. // return;
  788. var edata ="{\"action\":\"mqttupdateRemoteKey\",\"data\":{\"Command\":\"PassWord="+PW+"&ReGenerate=1&Stat=0&Type="+ktype+"&IndexID="+idx+"&TimeStamp="+vtstp+"&Cycle="+cycy+"&UserID="+ID+"&Title="+vtttt+"\",\"SerialNo\":\"ReservePC"+CID+"1-"+SubID+"\",\"TimeStamp\":\""+vt+"\",\"Token\":\"Gigatech23634857\"}}";
  789. var jsonString = "{\"action\":\"encode\", \"serial\":\"001\",\"data\":"+edata+"}";
  790. vsn='001';
  791. isget2=false;
  792. // updateOutput(jsonString);
  793. //alert(jsonString
  794. if (TYPE=='IOS')
  795. {
  796. window.webkit.messageHandlers.WebToApp.postMessage(jsonString);
  797. }
  798. if (TYPE=='ANDROID')
  799. {
  800. webSocket.send(jsonString);
  801. }
  802. if (TYPE=='PC')
  803. {
  804. //alert(edata);
  805. selfendecode(edata);
  806. }
  807. }
  808. }catch(e)
  809. {
  810. alert(e);
  811. }
  812. }
  813. function senttoother()
  814. {
  815. try
  816. {
  817. message999 = new Paho.MQTT.Message( "modify,"+idx+","+SubID+","+kname );
  818. // alert('send to other = '+ "modify,"+idx+","+SubID+","+kname );
  819. message999.qos = 0;
  820. message999.retained = false;
  821. for (var iii = 1; iii < 9; iii++)
  822. {
  823. if ( iii.toString() !=SubID.toString())
  824. {
  825. message999.destinationName = 'Reserve'+CID+'1-'+iii.toString() ;
  826. client.send(message999);
  827. message999.destinationName = 'ReservePC'+CID+'1-'+iii.toString() ;
  828. client.send(message999);
  829. }
  830. }
  831. }
  832. catch(e)
  833. {
  834. alert(e);
  835. }
  836. }
  837. function btnSaveqr()
  838. {
  839. issame=false;
  840. //alert(idx);
  841. var vvee1='';
  842. var vvee2='';
  843. var vvee3='';
  844. var cycy='';
  845. var st1 = '0000' ;
  846. var et1= '0000' ;
  847. var st2 = '0000' ;
  848. var et2= '0000' ;
  849. var st3 = '0000' ;
  850. var et3= '0000' ;
  851. //var vsdsd=document.getElementById("sd").value;
  852. //var veded =document.getElementById("ed").value;
  853. var vsdsd=document.getElementById("sd").value+'T'+document.getElementById("sdt1").value;
  854. //alert(vsdsd);
  855. //return;
  856. var veded =document.getElementById("ed").value+'T'+document.getElementById("sdt2").value;
  857. if (vsdsd.length>16)
  858. {
  859. vsdsd=vsdsd.substring(0,16);
  860. }
  861. if (veded.length>16)
  862. {
  863. veded=veded.substring(0,16);
  864. }
  865. //var vsdsd=document.getElementById("sd").value.format("yyyy/MM/dd_HH:mm");
  866. //vsdsd=vsdsd.substring(0,16);
  867. //alert(vsdsd);
  868. //return;
  869. //12345
  870. var vItemNOSer=document.getElementById("ItemNOSer").value;
  871. if (vItemNOSer.length<1)
  872. {
  873. alert('請輸入預約人');
  874. return;
  875. }
  876. if((document.getElementById("sd").value<1) || (document.getElementById("ed").value<1) ||(document.getElementById("sdt1").value<1) || (document.getElementById("sdt2").value<1))
  877. {
  878. alert('請輸入開始與結束日期時間');
  879. return;
  880. }
  881. var vsdsd=document.getElementById("sd").value+'T'+document.getElementById("sdt1").value;
  882. //alert(vsdsd);
  883. //return;
  884. var veded =document.getElementById("ed").value+'T'+document.getElementById("sdt2").value;
  885. //alert(veded);
  886. if ((vsdsd.length<2)|| (veded.length<2))
  887. {
  888. alert('請輸入開始與結束日期時間');
  889. return;
  890. }
  891. vsdsd=vsdsd.replace('T','_');
  892. vsdsd=vsdsd.replace('-','/');
  893. vsdsd=vsdsd.replace('-','/');
  894. veded=veded.replace('T','_');
  895. veded=veded.replace('-','/');
  896. veded=veded.replace('-','/');
  897. vsdsd=vsdsd.substring(2,vsdsd.length);
  898. veded=veded.substring(2,veded.length);
  899. //alert(vsdsd);
  900. //alert(veded);
  901. var vtstp=vsdsd+','+veded;
  902. vtstpqr=vtstp;
  903. vtstpqr=vtstpqr.replace('_',' ');
  904. vtstpqr=vtstpqr.replace('_',' ');
  905. vtstpqr=vtstpqr.replace(',','~');
  906. //alert(vtstp);
  907. //return;
  908. if (document.getElementById("d11").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  909. {
  910. vvee1='1';
  911. //alert('bgreen');
  912. }else
  913. {
  914. vvee1='0';
  915. //alert('bgrey');
  916. }
  917. if (document.getElementById("d12").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  918. {
  919. vvee1=vvee1+'1';
  920. }else
  921. {
  922. vvee1=vvee1+'0';
  923. }
  924. if (document.getElementById("d13").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  925. {
  926. vvee1=vvee1+'1';
  927. }else
  928. {
  929. vvee1=vvee1+'0';
  930. }
  931. if (document.getElementById("d14").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  932. {
  933. vvee1=vvee1+'1';
  934. }else
  935. {
  936. vvee1=vvee1+'0';
  937. }
  938. if (document.getElementById("d15").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  939. {
  940. vvee1=vvee1+'1';
  941. }else
  942. {
  943. vvee1=vvee1+'0';
  944. }
  945. if (document.getElementById("d16").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  946. {
  947. vvee1=vvee1+'1';
  948. }else
  949. {
  950. vvee1=vvee1+'0';
  951. }
  952. if (document.getElementById("d17").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  953. {
  954. vvee1=vvee1+'1';
  955. }else
  956. {
  957. vvee1=vvee1+'0';
  958. }
  959. //alert(vvee1);
  960. if (document.getElementById("d21").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  961. {
  962. vvee2='1';
  963. //alert('bgreen');
  964. }else
  965. {
  966. vvee2='0';
  967. //alert('bgrey');
  968. }
  969. if (document.getElementById("d22").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  970. {
  971. vvee2=vvee2+'1';
  972. }else
  973. {
  974. vvee2=vvee2+'0';
  975. }
  976. if (document.getElementById("d23").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  977. {
  978. vvee2=vvee2+'1';
  979. }else
  980. {
  981. vvee2=vvee2+'0';
  982. }
  983. if (document.getElementById("d24").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  984. {
  985. vvee2=vvee2+'1';
  986. }else
  987. {
  988. vvee2=vvee2+'0';
  989. }
  990. if (document.getElementById("d25").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  991. {
  992. vvee2=vvee2+'1';
  993. }else
  994. {
  995. vvee2=vvee2+'0';
  996. }
  997. if (document.getElementById("d26").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  998. {
  999. vvee2=vvee2+'1';
  1000. }else
  1001. {
  1002. vvee2=vvee2+'0';
  1003. }
  1004. if (document.getElementById("d27").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  1005. {
  1006. vvee2=vvee2+'1';
  1007. }else
  1008. {
  1009. vvee2=vvee2+'0';
  1010. }
  1011. // alert(vvee2);
  1012. if (document.getElementById("d31").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  1013. {
  1014. vvee3='1';
  1015. //alert('bgreen');
  1016. }else
  1017. {
  1018. vvee3='0';
  1019. //alert('bgrey');
  1020. }
  1021. if (document.getElementById("d32").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  1022. {
  1023. vvee3=vvee3+'1';
  1024. }else
  1025. {
  1026. vvee3=vvee3+'0';
  1027. }
  1028. if (document.getElementById("d33").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  1029. {
  1030. vvee3=vvee3+'1';
  1031. }else
  1032. {
  1033. vvee3=vvee3+'0';
  1034. }
  1035. if (document.getElementById("d34").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  1036. {
  1037. vvee3=vvee3+'1';
  1038. }else
  1039. {
  1040. vvee3=vvee3+'0';
  1041. }
  1042. if (document.getElementById("d35").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  1043. {
  1044. vvee3=vvee3+'1';
  1045. }else
  1046. {
  1047. vvee3=vvee3+'0';
  1048. }
  1049. if (document.getElementById("d36").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  1050. {
  1051. vvee3=vvee3+'1';
  1052. }else
  1053. {
  1054. vvee3=vvee3+'0';
  1055. }
  1056. if (document.getElementById("d37").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  1057. {
  1058. vvee3=vvee3+'1';
  1059. }else
  1060. {
  1061. vvee3=vvee3+'0';
  1062. }
  1063. //alert(vvee3);
  1064. var ktype = '1';
  1065. if (vvee1=='0000000')
  1066. {
  1067. }else
  1068. {
  1069. ktype='2';
  1070. st1 = document.getElementById("st1").value.replace(':','') ;
  1071. et1= document.getElementById("et1").value.replace(':','') ;
  1072. if (st1.length==0 || et1.length==0)
  1073. {
  1074. alert('請選擇時段1的起始與結束時間');
  1075. return;
  1076. }
  1077. }
  1078. if (vvee2=='0000000')
  1079. {
  1080. }else
  1081. {
  1082. ktype='2';
  1083. st2 = document.getElementById("st2").value.replace(':','') ;
  1084. et2= document.getElementById("et2").value.replace(':','') ;
  1085. if (st2.length==0 || et2.length==0)
  1086. {
  1087. alert('請選擇時段2的起始與結束時間');
  1088. return;
  1089. }
  1090. }
  1091. if (vvee3=='0000000')
  1092. {
  1093. }else
  1094. {
  1095. ktype='2';
  1096. st3 = document.getElementById("st3").value.replace(':','') ;
  1097. et3= document.getElementById("et3").value.replace(':','') ;
  1098. //alert(st3.length)
  1099. if (st3.length==0 || et3.length==0)
  1100. {
  1101. alert('請選擇時段3的起始與結束時間');
  1102. return;
  1103. }
  1104. }
  1105. if (ktype=='2')
  1106. {
  1107. cycy=vvee1+','+st1 +','+ et1+','+ vvee2+','+st2+','+et2+','+vvee3+','+st3+','+et3;
  1108. vcyd='';
  1109. var vcy = cycy.split(',');
  1110. let days=[];
  1111. if (vcy[0]=='0000000')
  1112. {
  1113. }else
  1114. {
  1115. if (vcy[0].substring(0,1)=='1')
  1116. days.push('日');
  1117. if (vcy[0].substring(1,2)=='1')
  1118. days.push('一');
  1119. if (vcy[0].substring(2,3)=='1')
  1120. days.push('二');
  1121. if (vcy[0].substring(3,4)=='1')
  1122. days.push('三');
  1123. if (vcy[0].substring(4,5)=='1')
  1124. days.push('四');
  1125. if (vcy[0].substring(5,6)=='1')
  1126. days.push('五');
  1127. if (vcy[0].substring(6,7)=='1')
  1128. days.push('六');
  1129. vcy[1]=vcy[1].substring(0,2)+':'+vcy[1].substring(2,4);
  1130. vcy[2]=vcy[2].substring(0,2)+':'+vcy[2].substring(2,4);
  1131. vcyd=vcyd+'#1.'+vcy[1]+'~'+vcy[2]+' '+' '+days.join(',');
  1132. }
  1133. days=[];
  1134. if (vcy[3]=='0000000')
  1135. {
  1136. }else
  1137. {
  1138. if (vcy[3].substring(0,1)=='1')
  1139. days.push('日');
  1140. if (vcy[3].substring(1,2)=='1')
  1141. days.push('一');
  1142. if (vcy[3].substring(2,3)=='1')
  1143. days.push('二');
  1144. if (vcy[3].substring(3,4)=='1')
  1145. days.push('三');
  1146. if (vcy[3].substring(4,5)=='1')
  1147. days.push('四');
  1148. if (vcy[3].substring(5,6)=='1')
  1149. days.push('五');
  1150. if (vcy[3].substring(6,7)=='1')
  1151. days.push('六');
  1152. vcy[4]=vcy[4].substring(0,2)+':'+vcy[4].substring(2,4);
  1153. vcy[5]=vcy[5].substring(0,2)+':'+vcy[5].substring(2,4);
  1154. vcyd=vcyd+'#2.'+vcy[4]+'~'+vcy[5]+' '+' '+days.join(',');
  1155. }
  1156. days=[];
  1157. if (vcy[6]=='0000000')
  1158. {
  1159. }else
  1160. {
  1161. if (vcy[6].substring(0,1)=='1')
  1162. days.push('日');
  1163. if (vcy[6].substring(1,2)=='1')
  1164. days.push('一');
  1165. if (vcy[6].substring(2,3)=='1')
  1166. days.push('二');
  1167. if (vcy[6].substring(3,4)=='1')
  1168. days.push('三');
  1169. if (vcy[6].substring(4,5)=='1')
  1170. days.push('四');
  1171. if (vcy[6].substring(5,6)=='1')
  1172. days.push('五');
  1173. if (vcy[6].substring(6,7)=='1')
  1174. days.push('六');
  1175. vcy[7]=vcy[7].substring(0,2)+':'+vcy[7].substring(2,4);
  1176. vcy[8]=vcy[8].substring(0,2)+':'+vcy[8].substring(2,4);
  1177. vcyd=vcyd+'#3.'+vcy[7]+'~'+vcy[8]+' '+' '+days.join(',');
  1178. }
  1179. }
  1180. else
  1181. {
  1182. //cycy='';
  1183. }
  1184. fincycle='';
  1185. fincycle= document.getElementById("ItemNOSer").value+';';
  1186. fincycle=fincycle+ vtstp+';';
  1187. fincycle=fincycle+cycy+';';
  1188. //alert(cycy);
  1189. // alert(fincycle);
  1190. if (orgcycle==fincycle)
  1191. {
  1192. issame=true;
  1193. // alert('相同');
  1194. }
  1195. vtttt = document.getElementById("ItemNOSer").value;
  1196. if (issame)
  1197. {
  1198. vsn='';
  1199. try
  1200. {
  1201. vtttt = document.getElementById("ItemNOSer").value;
  1202. var jsonString = "{\"action\":\"shareQr\", \"serial\":\"001\",\"data\":{\"name\":\""+kname+"\",\"note\":\""+vtttt+"\",\"QRCode\":\""+vvqrcd+"\",\"time\":\""+vtstpqr+"\",\"cycle\":\""+vcyd+"\"}}";
  1203. if (TYPE=='IOS')
  1204. {
  1205. window.webkit.messageHandlers.WebToApp.postMessage(jsonString);
  1206. }
  1207. if (TYPE=='ANDROID')
  1208. {
  1209. webSocket.send(jsonString);
  1210. }
  1211. if (TYPE=='PC')
  1212. {
  1213. shareQrPC(jsonString);
  1214. }
  1215. }catch(e)
  1216. {
  1217. alert(e);
  1218. alert('連線異常');
  1219. }
  1220. }
  1221. else
  1222. {
  1223. var vt=new Date().format("yyyy/MM/dd_HH:mm:ss")
  1224. // alert(document.getElementById("ItemNOSer").value);
  1225. vtttt = document.getElementById("ItemNOSer").value;
  1226. // alert(ktype);
  1227. // return;
  1228. var edata456 ="{\"action\":\"mqttupdateRemoteKey\",\"data\":{\"Command\":\"PassWord="+PW+"&ReGenerate=1&Stat=1&Type="+ktype+"&IndexID="+idx+"&TimeStamp="+vtstp+"&Cycle="+cycy+"&UserID="+ID+"&Title="+vtttt+"\",\"SerialNo\":\"ReservePC"+CID+"1-"+SubID+"\",\"TimeStamp\":\""+vt+"\",\"Token\":\"Gigatech23634857\"}}";
  1229. var jsonString333 = "{\"action\":\"encode\", \"serial\":\"003\",\"data\":"+edata456+"}";
  1230. vsn='003';
  1231. //updateOutput(jsonString);
  1232. //alert(jsonString);
  1233. //return;
  1234. if (TYPE=='IOS')
  1235. {
  1236. window.webkit.messageHandlers.WebToApp.postMessage(jsonString333);
  1237. }
  1238. if (TYPE=='ANDROID')
  1239. {
  1240. webSocket.send(jsonString333);
  1241. }
  1242. if (TYPE=='PC')
  1243. {
  1244. selfendecode(edata456);
  1245. }
  1246. }
  1247. }
  1248. function btnitemback(vid)
  1249. {
  1250. try
  1251. {
  1252. //alert(vid);
  1253. // alert(document.getElementById(vid).style.backgroundImage.slice(4, -1).replace(/"/g, ""));
  1254. if (document.getElementById(vid).style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
  1255. {
  1256. document.getElementById(vid).style.background="url('image/bgrey.png') no-repeat center/100%";
  1257. }else
  1258. {
  1259. document.getElementById(vid).style.background="url('image/bgreen.png') no-repeat center/100%";
  1260. }
  1261. }catch(e)
  1262. {
  1263. alert(e);
  1264. }
  1265. }
  1266. function btndddel()
  1267. {
  1268. var yes = confirm('確定刪除?');
  1269. if (yes) {
  1270. try
  1271. {
  1272. //alert('ue');
  1273. //return;
  1274. var vt=new Date().format("yyyy/MM/dd_HH:mm:ss")
  1275. // alert(document.getElementById("ItemNOSer").value);
  1276. vtttt = document.getElementById("ItemNOSer").value;
  1277. // alert(ktype);
  1278. // return;
  1279. var edata3 ="";
  1280. edata3 ="{\"action\":\"mqttdeleteRemoteKey\",\"data\":{\"Command\":\"PassWord="+PW+"&IndexID="+idx+"&UserID="+ID+"\",\"SerialNo\":\"ReservePC"+CID+"1-"+SubID+"\",\"TimeStamp\":\""+vt+"\",\"Token\":\"Gigatech23634857\"}}";
  1281. // alert(edata);
  1282. var jsonString4 ="";
  1283. jsonString4 = "{\"action\":\"encode\", \"serial\":\"101\",\"data\":"+edata3+"}";
  1284. vsn='101';
  1285. // updateOutput(jsonString);
  1286. //alert(jsonString);
  1287. //return;
  1288. if (TYPE=='IOS')
  1289. {
  1290. window.webkit.messageHandlers.WebToApp.postMessage(jsonString4);
  1291. }
  1292. if (TYPE=='ANDROID')
  1293. {
  1294. webSocket.send(jsonString4);
  1295. }
  1296. if (TYPE=='PC')
  1297. {
  1298. selfendecode(edata3);
  1299. }
  1300. }
  1301. catch(e)
  1302. {
  1303. alert('連線異常');
  1304. }
  1305. } else {
  1306. }
  1307. }
  1308. function getdoorlist()
  1309. {
  1310. var vt=new Date().format("yyyy/MM/dd_HH:mm:ss")
  1311. var edata ="{\"action\":\"mqttqueryCallList\",\"data\":{\"Command\":\"PassWord="+PW+"\",\"SerialNo\":\"ReservePC"+CID+"1\",\"TimeStamp\":\""+vt+"\",\"Token\":\"Gigatech23634857\"}}";
  1312. var jsonString = "{\"action\":\"encode\", \"serial\":\"001\",\"data\":"+edata+"}";
  1313. vsn='001';
  1314. // updateOutput(jsonString);
  1315. isget2=false;
  1316. if (TYPE=='IOS')
  1317. {
  1318. window.webkit.messageHandlers.WebToApp.postMessage(jsonString);
  1319. }
  1320. if (TYPE=='ANDROID')
  1321. {
  1322. webSocket.send(jsonString);
  1323. }
  1324. if (TYPE=='PC')
  1325. {
  1326. selfendecode(edata);
  1327. }
  1328. }
  1329. </script>
  1330. <script type="text/javascript">
  1331. var webSocket;
  1332. var input = document.getElementById("input")
  1333. var output = document.getElementById("output");
  1334. var vdata="";
  1335. var isok=true;
  1336. var webSocket;
  1337. //var connectBtn = document.getElementById("connectBtn");
  1338. //var wsUrl = "ws://localhost:2980/";
  1339. // var wsUrl = "ws://192.168.0.27:2980/";
  1340. // var wsUrl = "ws://192.168.0.30:2980/";
  1341. var wsUrl = "ws://127.0.0.1:2980/";
  1342. //var wsUrl = "ws://192.168.0.25:2980/";
  1343. function connect() {
  1344. // open the connection if one does not exist
  1345. if (webSocket !== undefined
  1346. && webSocket.readyState !== WebSocket.CLOSED) {
  1347. return;
  1348. }
  1349. // updateOutput("Trying to establish a WebSocket connection to <code>" + wsUrl + "</code>");
  1350. // Create a websocket
  1351. webSocket = new WebSocket(wsUrl);
  1352. webSocket.onopen = function(event) {
  1353. // updateOutput("Connected!");
  1354. // connectBtn.disabled = true;
  1355. try
  1356. {
  1357. /*
  1358. setTimeout(() => {
  1359. if (isget)
  1360. {
  1361. }else
  1362. {
  1363. getdoorlist() ;
  1364. }
  1365. }, 1000);
  1366. */
  1367. }catch(e)
  1368. {
  1369. alert(e);
  1370. }
  1371. };
  1372. webSocket.onmessage = function(event)
  1373. {
  1374. if (vsn=='002'||vsn=='103')
  1375. {
  1376. // alert(vsn);
  1377. isget=true;
  1378. var ress = event.data;
  1379. vsn='104';
  1380. try
  1381. {
  1382. // var vobj = JSON.parse( ress);
  1383. //alert( vobj.data);
  1384. //var sevobj = JSON.parse( vobj);
  1385. //alert('de'+ ress);
  1386. senttoother();
  1387. alert('OK');
  1388. //23456
  1389. window.history.go(-1);
  1390. //document.location = "index2.html?KID="+ID +"&name="+ kname;
  1391. }
  1392. catch(e)
  1393. {
  1394. alert(e);
  1395. }
  1396. }
  1397. if (vsn=='004')
  1398. {
  1399. isget3 = true;
  1400. //alert('004');
  1401. vsn='';
  1402. var ress = event.data;
  1403. try
  1404. {
  1405. // alert('de'+ ress);
  1406. vobj = JSON.parse( ress);
  1407. var qrcd= vobj.data.data.CardID;
  1408. // alert( qrcd);
  1409. //var sevobj = JSON.parse( vobj);
  1410. // alert('de'+ ress);
  1411. //alert('OK');
  1412. //window.history.go(-1);
  1413. //document.location = "index2.html?KID="+ID +"&name="+ kname;
  1414. //"name":"健身房","note":"王大明09123456789","QRCode":"KaiZvhWz5dcUqkkuvAK0q6T/iw4dbE7CpGKDozTFL2LkH6g1YRdayW=="
  1415. // alert(vtttt);
  1416. //vcyd
  1417. var jsonString = "{\"action\":\"shareQr\", \"serial\":\"001\",\"data\":{\"name\":\""+kname+"\",\"note\":\""+vtttt+"\",\"QRCode\":\""+qrcd+"\",\"time\":\""+vtstpqr+"\",\"cycle\":\""+vcyd+"\"}}";
  1418. // updateOutput(jsonString);
  1419. /// "WebToApp". 為我們和前端開發人員的約定
  1420. orgcycle=fincycle;
  1421. vvqrcd=qrcd;
  1422. senttoother();
  1423. if (TYPE=='IOS')
  1424. {
  1425. window.webkit.messageHandlers.WebToApp.postMessage(jsonString);
  1426. }
  1427. if (TYPE=='ANDROID')
  1428. {
  1429. webSocket.send(jsonString);
  1430. }
  1431. if (TYPE=='PC')
  1432. {
  1433. shareQrPC(jsonString);
  1434. }
  1435. }catch(e)
  1436. {
  1437. alert('連線異常');
  1438. }
  1439. }
  1440. if (vsn=='001')
  1441. {
  1442. try
  1443. {
  1444. isget2=true;
  1445. // alert( '001');
  1446. var ress = event.data;
  1447. // alert( ress);
  1448. vobj = JSON.parse( ress);
  1449. isget=false;
  1450. // vdata = "{\"encrypt\":\"1\",\"data\":\""+vobj.data+"\"}";
  1451. }catch(e)
  1452. {
  1453. alert(e);
  1454. }
  1455. //updateOutput('---------------------------');
  1456. // updateOutput(vdata);
  1457. // updateOutput('get en='+vobj.data);
  1458. //var payload =vdata;
  1459. var payload = "{\"encrypt\":\"1\",\"data\":\""+vobj.data+"\"}";
  1460. //alert(payload);
  1461. //23456
  1462. message2 = new Paho.MQTT.Message( "{\"encrypt\":\"1\",\"data\":\""+vobj.data+"\"}");
  1463. message2.destinationName = SN ;
  1464. message2.qos = 0;
  1465. message2.retained = false;
  1466. // client.send(message);
  1467. //setTimeout(() => {
  1468. var vivi = 0;
  1469. var intervalID = setInterval(() => {
  1470. if (isget)
  1471. {
  1472. }
  1473. else
  1474. {
  1475. if (vivi>15)
  1476. {
  1477. clearInterval(intervalID);
  1478. alert('連線異常');
  1479. }else
  1480. {
  1481. vivi++;
  1482. updateOutput('message2 send ='+ message2.payloadString);
  1483. if (isconn)
  1484. {
  1485. client.send(message2);
  1486. }
  1487. }
  1488. }
  1489. }, 400);
  1490. }
  1491. if (vsn=='101')
  1492. {
  1493. try
  1494. {
  1495. vsn='102';
  1496. // alert( '102');
  1497. var ress = event.data;
  1498. // alert( ress);
  1499. vobj = JSON.parse( ress);
  1500. isget=false;
  1501. // vdata = "{\"encrypt\":\"1\",\"data\":\""+vobj.data+"\"}";
  1502. //updateOutput('---------------------------');
  1503. // updateOutput(vdata);
  1504. // var payload =vdata;
  1505. message0 = new Paho.MQTT.Message("{\"encrypt\":\"1\",\"data\":\""+vobj.data+"\"}");
  1506. message0.qos = 0;
  1507. message0.retained = false;
  1508. message0.destinationName = SN ;
  1509. //setTimeout(() => {
  1510. // client.send(message);
  1511. var vivi = 0;
  1512. var intervalID = setInterval(() => {
  1513. if (isget)
  1514. {
  1515. }
  1516. else
  1517. {
  1518. if (vivi>15)
  1519. {
  1520. clearInterval(intervalID);
  1521. alert('連線異常');
  1522. }else
  1523. {
  1524. vivi++;
  1525. if (isconn)
  1526. {
  1527. client.send(message0);
  1528. }
  1529. }
  1530. }
  1531. }, 400);
  1532. }catch(e)
  1533. {
  1534. alert(e);
  1535. }
  1536. }
  1537. if (vsn=='003')
  1538. {
  1539. // alert( '003');
  1540. var ress = event.data;
  1541. // alert( ress);
  1542. vobj = JSON.parse( ress);
  1543. isget3=false;
  1544. vdata = "{\"encrypt\":\"1\",\"data\":\""+vobj.data+"\"}";
  1545. //updateOutput('---------------------------');
  1546. // updateOutput(vdata);
  1547. updateOutput('rece ='+vobj.data);
  1548. message7 = new Paho.MQTT.Message("{\"encrypt\":\"1\",\"data\":\""+vobj.data+"\"}");
  1549. message7.destinationName = SN ;
  1550. message7.retained = false;
  1551. message7.qos = 0;
  1552. var vivi = 0;
  1553. // client.send(message);
  1554. var intervalID = setInterval(() => {
  1555. if (isget3)
  1556. {
  1557. }
  1558. else
  1559. {
  1560. if (vivi>15)
  1561. {
  1562. clearInterval(intervalID);
  1563. alert('連線異常');
  1564. }else
  1565. {
  1566. vivi++;
  1567. updateOutput('message7 send ='+ message7.payloadString);
  1568. if (isconn)
  1569. {
  1570. client.send(message7);
  1571. }
  1572. }
  1573. }
  1574. }, 400);
  1575. }
  1576. //updateOutput('---------------------------');
  1577. // updateOutput(event.data);
  1578. };
  1579. webSocket.onclose = function(event) {
  1580. // updateOutput("Connection Closed");
  1581. //connectBtn.disabled = false;
  1582. //sendBtn.disabled = true;
  1583. };
  1584. }
  1585. function shareQr() {
  1586. var text = input.value;
  1587. var jsonString = "{\"action\":\"shareQr\", \"serial\":\"001\",\"data\":\""+text+"\"}";
  1588. //updateOutput(jsonString);
  1589. /// "WebToApp". 為我們和前端開發人員的約定
  1590. if (TYPE=='IOS')
  1591. {
  1592. window.webkit.messageHandlers.WebToApp.postMessage(jsonString);
  1593. }
  1594. if (TYPE=='ANDROID')
  1595. {
  1596. webSocket.send(jsonString);
  1597. }
  1598. }
  1599. function shareQrPC(message) {
  1600. message=message.replaceAll('=','-');
  1601. message=message.replaceAll('#','*');
  1602. //alert('shareQrPC '+message);
  1603. //alert("index4.html?idx="+vvvi+"&tt="+"&qrcd=&cy="+"&name="+kname+"&st="+"&et="+"&tp=1"+"&CID="+CID+"&ID="+kkid+"&PW="+PW+"&TYPE="+TYPE+"&SN="+SN+"&MQTT="+vmqtt+"&SubID="+SubID);
  1604. document.location = "index4.html?idx="+vvvi+"&tt="+tt+"&qrcd=&cy="+"&name="+kname+"&st="+"&et="+"&tp=1"+"&CID="+CID+"&ID="+kkid+"&PW="+PW+"&TYPE="+TYPE+"&SN="+SN+"&MQTT="+vmqtt+"&SubID="+SubID+"&sqr="+message;
  1605. }
  1606. //self start
  1607. function selfendecode(message) {
  1608. if (vsn=='002'||vsn=='103')
  1609. {
  1610. isget=true;
  1611. // alert(vsn);
  1612. message = teaDecrypt(message,'75$095huOQ77kKv!');
  1613. // alert('002 or 103 '+message);
  1614. var ress = message;
  1615. vsn='104';
  1616. try
  1617. {
  1618. // var vobj = JSON.parse( ress);
  1619. //alert( vobj.data);
  1620. //var sevobj = JSON.parse( vobj);
  1621. // alert('de'+ ress);
  1622. senttoother();
  1623. alert('OK');
  1624. //23456
  1625. window.history.go(-1);
  1626. //document.location = "index2.html?KID="+ID +"&name="+ kname;
  1627. }catch(e)
  1628. {
  1629. alert(e);
  1630. }
  1631. }
  1632. if (vsn=='004')
  1633. {
  1634. //alert('004');
  1635. vsn='';
  1636. message = teaDecrypt(message,'75$095huOQ77kKv!');
  1637. isget3 = true;
  1638. var ress = message;
  1639. try
  1640. {
  1641. // alert('de'+ ress);
  1642. vobj = JSON.parse( ress);
  1643. var qrcd= vobj.data.CardID;
  1644. // alert('004 '+message);
  1645. // var qrcd= vobj.data.data.CardID;
  1646. // alert( qrcd);
  1647. //var sevobj = JSON.parse( vobj);
  1648. // alert('de'+ ress);
  1649. //alert('OK');
  1650. //window.history.go(-1);
  1651. //document.location = "index2.html?KID="+ID +"&name="+ kname;
  1652. //"name":"健身房","note":"王大明09123456789","QRCode":"KaiZvhWz5dcUqkkuvAK0q6T/iw4dbE7CpGKDozTFL2LkH6g1YRdayW=="
  1653. // alert(vtttt);
  1654. //vcyd
  1655. var jsonString = "{\"action\":\"shareQr\", \"serial\":\"001\",\"data\":{\"name\":\""+kname+"\",\"note\":\""+vtttt+"\",\"QRCode\":\""+qrcd+"\",\"time\":\""+vtstpqr+"\",\"cycle\":\""+vcyd+"\"}}";
  1656. // alert(jsonString);
  1657. // updateOutput(jsonString);
  1658. /// "WebToApp". 為我們和前端開發人員的約定
  1659. orgcycle=fincycle;
  1660. vvqrcd=qrcd;
  1661. senttoother();
  1662. if (TYPE=='IOS')
  1663. {
  1664. window.webkit.messageHandlers.WebToApp.postMessage(jsonString);
  1665. }
  1666. if (TYPE=='ANDROID')
  1667. {
  1668. webSocket.send(jsonString);
  1669. }
  1670. if (TYPE=='PC')
  1671. {
  1672. shareQrPC(jsonString);
  1673. }
  1674. }catch(e)
  1675. {
  1676. alert(e);
  1677. }
  1678. }
  1679. if (vsn=='001')
  1680. {
  1681. try
  1682. {
  1683. // alert( '001');
  1684. message = teaEncrypt(message,'75$095huOQ77kKv!');
  1685. var ress = message;
  1686. // alert( ress);
  1687. isget2=true;
  1688. // vobj = JSON.parse( ress);
  1689. isget=false;
  1690. // vdata = "{\"encrypt\":\"1\",\"data\":\""+vobj.data+"\"}";
  1691. }catch(e)
  1692. {
  1693. alert(e);
  1694. }
  1695. //updateOutput('---------------------------');
  1696. // updateOutput(vdata);
  1697. message4 = new Paho.MQTT.Message("{\"encrypt\":\"1\",\"data\":\""+message+"\"}");
  1698. message4.destinationName = SN ;
  1699. message4.retained = false;
  1700. message4.qos = 0;
  1701. var vivi = 0;
  1702. // client.send(message);
  1703. var intervalID = setInterval(() => {
  1704. if (isget)
  1705. {
  1706. }
  1707. else
  1708. {
  1709. if (vivi>15)
  1710. {
  1711. clearInterval(intervalID);
  1712. alert('連線異常');
  1713. }else
  1714. {
  1715. vivi++;
  1716. if (isconn)
  1717. {
  1718. client.send(message4);
  1719. }
  1720. }
  1721. }
  1722. }, 400);
  1723. }
  1724. if (vsn=='101')
  1725. {
  1726. try
  1727. {
  1728. vsn='102';
  1729. // alert( '102');
  1730. message = teaEncrypt(message,'75$095huOQ77kKv!');
  1731. var ress = message;
  1732. // alert( ress);
  1733. // vobj = JSON.parse( ress);
  1734. isget=false;
  1735. // vdata = "{\"encrypt\":\"1\",\"data\":\""+message+"\"}";
  1736. //updateOutput('---------------------------');
  1737. // updateOutput(vdata);
  1738. message9 = new Paho.MQTT.Message("{\"encrypt\":\"1\",\"data\":\""+message+"\"}");
  1739. message9.destinationName = SN ;
  1740. message9.retained = false;
  1741. message9.qos = 0;
  1742. var vivi = 0;
  1743. // client.send(message);
  1744. var intervalID = setInterval(() => {
  1745. if (isget)
  1746. {
  1747. }
  1748. else
  1749. {
  1750. if (vivi>15)
  1751. {
  1752. clearInterval(intervalID);
  1753. alert('連線異常');
  1754. }else
  1755. {
  1756. if (isconn)
  1757. {
  1758. client.send(message9);
  1759. }
  1760. vivi++;
  1761. }
  1762. }
  1763. }, 400);
  1764. }catch(e)
  1765. {
  1766. alert(e);
  1767. }
  1768. }
  1769. if (vsn=='003')
  1770. {
  1771. try
  1772. {
  1773. // alert( '003');
  1774. message = teaEncrypt(message,'75$095huOQ77kKv!');
  1775. var ress = message;
  1776. // alert( ress);
  1777. // vobj = JSON.parse( ress);
  1778. isget3=false;
  1779. // vdata = "{\"encrypt\":\"1\",\"data\":\""+message+"\"}";
  1780. }catch(e)
  1781. {
  1782. alert(e);
  1783. }
  1784. //updateOutput('---------------------------');
  1785. // updateOutput(vdata);
  1786. message6= new Paho.MQTT.Message("{\"encrypt\":\"1\",\"data\":\""+message+"\"}");
  1787. message6.destinationName = SN ;
  1788. message6.retained = false;
  1789. message6.qos = 0;
  1790. //setTimeout(() => {
  1791. var vivi = 0;
  1792. var intervalID = setInterval(() => {
  1793. if (isget3)
  1794. {
  1795. }
  1796. else
  1797. {
  1798. if (vivi>15)
  1799. {
  1800. alert('連線異常');
  1801. clearInterval(intervalID);
  1802. }else
  1803. {
  1804. vivi++;
  1805. if (isconn)
  1806. {
  1807. client.send(message6);
  1808. }
  1809. }
  1810. }
  1811. }, 400);
  1812. }
  1813. // updateOutput(message);
  1814. }
  1815. //self end
  1816. function AppToWeb(message) {
  1817. if (vsn=='002'||vsn=='103')
  1818. {
  1819. isget=true;
  1820. // alert(vsn);
  1821. var ress = message;
  1822. vsn='104';
  1823. try
  1824. {
  1825. // var vobj = JSON.parse( ress);
  1826. //alert( vobj.data);
  1827. //var sevobj = JSON.parse( vobj);
  1828. // alert('de'+ ress);
  1829. senttoother();
  1830. alert('OK');
  1831. //23456
  1832. window.history.go(-1);
  1833. //document.location = "index2.html?KID="+ID +"&name="+ kname;
  1834. }catch(e)
  1835. {
  1836. alert(e);
  1837. }
  1838. }
  1839. if (vsn=='004')
  1840. {
  1841. //alert('004');
  1842. vsn='';
  1843. isget3 = true;
  1844. var ress = message;
  1845. try
  1846. {
  1847. // alert('de'+ ress);
  1848. vobj = JSON.parse( ress);
  1849. var qrcd= vobj.data.data.CardID;
  1850. // alert( qrcd);
  1851. //var sevobj = JSON.parse( vobj);
  1852. // alert('de'+ ress);
  1853. //alert('OK');
  1854. //window.history.go(-1);
  1855. //document.location = "index2.html?KID="+ID +"&name="+ kname;
  1856. //"name":"健身房","note":"王大明09123456789","QRCode":"KaiZvhWz5dcUqkkuvAK0q6T/iw4dbE7CpGKDozTFL2LkH6g1YRdayW=="
  1857. // alert(vtttt);
  1858. //vcyd
  1859. var jsonString = "{\"action\":\"shareQr\", \"serial\":\"001\",\"data\":{\"name\":\""+kname+"\",\"note\":\""+vtttt+"\",\"QRCode\":\""+qrcd+"\",\"time\":\""+vtstpqr+"\",\"cycle\":\""+vcyd+"\"}}";
  1860. // alert(jsonString);
  1861. // updateOutput(jsonString);
  1862. /// "WebToApp". 為我們和前端開發人員的約定
  1863. orgcycle=fincycle;
  1864. vvqrcd=qrcd;
  1865. senttoother();
  1866. if (TYPE=='IOS')
  1867. {
  1868. window.webkit.messageHandlers.WebToApp.postMessage(jsonString);
  1869. }
  1870. if (TYPE=='ANDROID')
  1871. {
  1872. webSocket.send(jsonString);
  1873. }
  1874. }catch(e)
  1875. {
  1876. alert(e);
  1877. }
  1878. }
  1879. if (vsn=='001')
  1880. {
  1881. try
  1882. {
  1883. // alert( '001');
  1884. var ress = message;
  1885. // alert( ress);
  1886. isget2=true;
  1887. vobj = JSON.parse( ress);
  1888. isget=false;
  1889. vdata = "{\"encrypt\":\"1\",\"data\":\""+vobj.data+"\"}";
  1890. }catch(e)
  1891. {
  1892. alert(e);
  1893. }
  1894. //updateOutput('---------------------------');
  1895. // updateOutput(vdata);
  1896. message4 = new Paho.MQTT.Message("{\"encrypt\":\"1\",\"data\":\""+vobj.data+"\"}");
  1897. message4.destinationName = SN ;
  1898. message4.retained = false;
  1899. message4.qos = 0;
  1900. var vivi = 0;
  1901. // client.send(message);
  1902. var intervalID = setInterval(() => {
  1903. if (isget)
  1904. {
  1905. }
  1906. else
  1907. {
  1908. if (vivi>15)
  1909. {
  1910. clearInterval(intervalID);
  1911. alert('連線異常');
  1912. }else
  1913. {
  1914. vivi++;
  1915. if (isconn)
  1916. {
  1917. client.send(message4);
  1918. }
  1919. }
  1920. }
  1921. }, 400);
  1922. }
  1923. if (vsn=='101')
  1924. {
  1925. try
  1926. {
  1927. vsn='102';
  1928. // alert( '102');
  1929. var ress = message;
  1930. // alert( ress);
  1931. vobj = JSON.parse( ress);
  1932. isget=false;
  1933. vdata = "{\"encrypt\":\"1\",\"data\":\""+vobj.data+"\"}";
  1934. //updateOutput('---------------------------');
  1935. // updateOutput(vdata);
  1936. message9 = new Paho.MQTT.Message("{\"encrypt\":\"1\",\"data\":\""+vobj.data+"\"}");
  1937. message9.destinationName = SN ;
  1938. message9.retained = false;
  1939. message9.qos = 0;
  1940. var vivi = 0;
  1941. // client.send(message);
  1942. var intervalID = setInterval(() => {
  1943. if (isget)
  1944. {
  1945. }
  1946. else
  1947. {
  1948. if (vivi>15)
  1949. {
  1950. clearInterval(intervalID);
  1951. alert('連線異常');
  1952. }else
  1953. {
  1954. if (isconn)
  1955. {
  1956. client.send(message9);
  1957. }
  1958. vivi++;
  1959. }
  1960. }
  1961. }, 400);
  1962. }catch(e)
  1963. {
  1964. alert(e);
  1965. }
  1966. }
  1967. if (vsn=='003')
  1968. {
  1969. try
  1970. {
  1971. // alert( '003');
  1972. var ress = message;
  1973. // alert( ress);
  1974. vobj = JSON.parse( ress);
  1975. isget3=false;
  1976. vdata = "{\"encrypt\":\"1\",\"data\":\""+vobj.data+"\"}";
  1977. }catch(e)
  1978. {
  1979. alert(e);
  1980. }
  1981. //updateOutput('---------------------------');
  1982. // updateOutput(vdata);
  1983. message6= new Paho.MQTT.Message("{\"encrypt\":\"1\",\"data\":\""+vobj.data+"\"}");
  1984. message6.destinationName = SN ;
  1985. message6.retained = false;
  1986. message6.qos = 0;
  1987. //setTimeout(() => {
  1988. var vivi = 0;
  1989. var intervalID = setInterval(() => {
  1990. if (isget3)
  1991. {
  1992. }
  1993. else
  1994. {
  1995. if (vivi>15)
  1996. {
  1997. alert('連線異常');
  1998. clearInterval(intervalID);
  1999. }else
  2000. {
  2001. vivi++;
  2002. if (isconn)
  2003. {
  2004. client.send(message6);
  2005. }
  2006. }
  2007. }
  2008. }, 400);
  2009. }
  2010. // updateOutput(message);
  2011. return "Got it"
  2012. }
  2013. function endode() {
  2014. var text = input.value;
  2015. var jsonString = "{\"action\":\"encode\", \"serial\":\"001\",\"data\":"+text+"}";
  2016. // updateOutput(jsonString);
  2017. /// "WebToApp". 為我們和前端開發人員的約定
  2018. if (TYPE=='IOS')
  2019. {
  2020. window.webkit.messageHandlers.WebToApp.postMessage(jsonString);
  2021. }
  2022. if (TYPE=='ANDROID')
  2023. {
  2024. webSocket.send(jsonString);
  2025. }
  2026. }
  2027. function decode() {
  2028. var text = input.value;
  2029. var jsonString = "{\"action\":\"decode\", \"serial\":\"001\",\"data\":\""+text+"\"}";
  2030. //updateOutput(jsonString);
  2031. /// "WebToApp". 為我們和前端開發人員的約定
  2032. if (TYPE=='IOS')
  2033. {
  2034. window.webkit.messageHandlers.WebToApp.postMessage(jsonString);
  2035. }
  2036. if (TYPE=='ANDROID')
  2037. {
  2038. webSocket.send(jsonString);
  2039. }
  2040. }
  2041. function updateOutput(text) {
  2042. output.innerHTML += "<br/>" + text;
  2043. }
  2044. </script>
  2045. <script>
  2046. var getUrlParameter = function getUrlParameter(sParam) {
  2047. var sPageURL = decodeURIComponent(window.location.search.substring(1)),
  2048. sURLVariables = sPageURL.split('&'),
  2049. sParameterName,
  2050. i;
  2051. for (i = 0; i < sURLVariables.length; i++) {
  2052. sParameterName = sURLVariables[i].split('=');
  2053. if (sParameterName[0] === sParam) {
  2054. return sParameterName[1] === undefined ? true : sParameterName[1];
  2055. }
  2056. }
  2057. };
  2058. Date.prototype.format = function (format) {
  2059. //eg:format="yyyy-MM-dd hh:mm:ss";
  2060. if (!format) {
  2061. format = "yyyy-MM-dd hh:mm:ss";
  2062. }
  2063. var o = {
  2064. "M+": this.getMonth() + 1, // month
  2065. "d+": this.getDate(), // day
  2066. "H+": this.getHours(), // hour
  2067. "h+": this.getHours(), // hour
  2068. "m+": this.getMinutes(), // minute
  2069. "s+": this.getSeconds(), // second
  2070. "q+": Math.floor((this.getMonth() + 3) / 3), // quarter
  2071. "S": this.getMilliseconds()
  2072. };
  2073. if (/(y+)/.test(format)) {
  2074. format = format.replace(RegExp.$1, (this.getFullYear() + "")
  2075. .substr(4 - RegExp.$1.length));
  2076. }
  2077. for (var k in o) {
  2078. if (new RegExp("(" + k + ")").test(format)) {
  2079. format = format.replace(RegExp.$1, RegExp.$1.length == 1
  2080. ? o[k]
  2081. : ("00" + o[k]).substr(("" + o[k]).length));
  2082. }
  2083. }
  2084. return format;
  2085. };
  2086. </script>
  2087. <br>
  2088. </body>
  2089. </html>