預約系統 IOS / Android Windows

index3.html 58KB

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