預約系統 IOS / Android Windows

index3.html 58KB

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