| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261 |
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
- <meta name="description" content="">
- <meta name="author" content="">
- <script src="js/mqttws31.min.js" type="text/javascript"></script>
- <script src="js/jquery-3.5.1.min.js"></script>
- <script src="js/teacrypt.js" type="text/javascript"></script>
- <script src="js/jquery-qrcode-0.17.0.min.js" type="text/javascript" ></script>
- <script src="js/html2canvas.js" type="text/javascript" ></script>
- <script src="js/canvas2image.js" type="text/javascript" ></script>
- <script type="text/javascript">
- var message999;
- var message0 ;
- var message4 ;
- var message9 ;
- var message6;
- var message7 ;
- var message2 ;
- var issame=false;
- var vvqrcd= '';
- var orgcycle='';
- var fincycle='';
- var orgtimestamp='';
- var isconn = false;
- var CID = '';
- var ID = '';
- var PW = '';
- var TYPE = '';
- var client;
- var kname='';
- var myclientid='';
- var tt = '';
- var st = '';
- var et = '';
- var idx = '';
- var cy='';
- var vtype='';
- var vtttt='';
- var isget = false;
- var isget2 = false;
- var isget3 = false;
- var vtstpqr='';
- var vcyd='';
- var vmqtt='';
- var SN='';
- var SubID='';
- var vsn='';
- var vobj;
- var sstitle ='三品御(#7)';
- var sqr;
- var ooodata='';
- var vvvtime='';
- var whoorder='';
- var tt;
- function init()
- {
- try
- {
- CID = getUrlParameter('CID');
- ID = getUrlParameter('ID');
- PW= getUrlParameter('PW');
- TYPE= getUrlParameter('TYPE');
- SN = getUrlParameter('SN');
- vmqtt = getUrlParameter('MQTT');
- SubID = getUrlParameter('SubID');
- sqr = getUrlParameter('sqr');
- tt= getUrlParameter('tt');
- vvqrcd= getUrlParameter('qrcd');
- vvqrcd=vvqrcd.replaceAll('-','=');
-
- // alert(vvqrcd);
-
-
-
- kname= getUrlParameter("name");
-
- document.getElementById("btn100").innerHTML =kname;
-
- sqr=sqr.replaceAll('-','=');
- sqr=sqr.replace('*','');
- sqr=sqr.replaceAll('*','<br>');
- //alert(sqr);
- var vobj = JSON.parse( sqr);
- var vd = vobj.data;
- var abc=vd.QRCode;
- whoorder=vd.note;
- document.getElementById("btn8000").innerHTML =sstitle;
- document.getElementById("btn9000").innerHTML =whoorder;
- document.getElementById("btn9100").innerHTML =vd.time;
- vvvtime=vd.time;
- vvvtime=vvvtime.replaceAll('/','-');
- vvvtime=vvvtime.replaceAll(':','-');
- if (vd.cycle.length==0)
- {
- // alert('0');
- }
- document.getElementById("btn9200").innerHTML =vd.cycle;
-
- document.getElementById("jquery-qrcode-div").innerHTML = '';
- //alert(abc);
- $("#jquery-qrcode-div").qrcode({
- render: 'div',
- size: 380,
- text: abc,
- fill: '#000000'
-
- });
-
- }catch(e)
- {
- alert(e);
- }
-
-
- }
- function onConnectionLost(message)
- {
- //alert('連線失敗或重複登入');
- //document.location = "index.html?TYPE=PC&ID=00000000";
- client.connect( {onSuccess: onConnect, onFailure : onFailedConnect});
- }
- function onMessageArrived(message)
- {
-
- //alert(message.payloadString);
- var errda = message.payloadString;
-
- if (errda.startsWith('modify'))
- {
- try
- {
- var kkdd = errda.split(',');
-
-
- if (kkdd[3]==kname)
- {
-
- if (kkdd[1]==idx)
- {
- if (kkdd[2]!=SubID)
- {
- alert('此筆資料已修改');
- window.history.go(-1);
- }
- }
- }
- else
- {
-
- }
- }catch
- {}
-
- }else
- {
-
- vobj = JSON.parse( errda);
- var jsonString = "{\"action\":\"decode\", \"serial\":\"002\",\"data\":\""+vobj.data+"\"}";
- //updateOutput('----------------------------------------------');
- //updateOutput(jsonString);
- if (vsn=='001')
- {
- vsn='002';
- }
- else if (vsn=='003')
- {
- vsn='004';
- }
- else if (vsn=='102')
- {
- jsonString = "{\"action\":\"decode\", \"serial\":\"103\",\"data\":\""+vobj.data+"\"}"
- vsn='103';
- //alert('103');
- //alert(errda);
- }
- //alert(vsn);
- /// "WebToApp". 為我們和前端開發人員的約定
- if (TYPE=='IOS')
- {
- window.webkit.messageHandlers.WebToApp.postMessage(jsonString);
- }
- if (TYPE=='ANDROID')
- {
- webSocket.send(jsonString);
- }
-
- if (TYPE=='PC')
- {
- selfendecode(vobj.data);
- }
-
- }
-
- }
- function onFailedConnect()
- {
- //alert('連線異常');
- }
- function onConnect()
- {
- isconn=true;
- client.subscribe('Reserve'+CID+'1-'+SubID);
- try
- {
-
-
-
- }
- catch(e)
- {
- alert(e);
- }
- //alert('c');
- }
-
- </script>
- <title>預約 QR Code</title>
- <link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" />
- </head>
-
- <body class="text-center" onload="init()">
- <div>
-
-
-
-
- <div class="card" style="width: 480px ;box-shadow: 0px 0px 1px 1px rgba(0,0,0,0.1);margin: 21px auto;background-color:#FFFFFF;">
- <table style="width: 100%">
- <tbody>
- <tr>
- <td style="width: 33.3%"><button type="button" style="border-color: #dcdcdc;border-width: 0px;border-color: #dcdcdc;border-width: 0px;margin: 0px 0px 0px 0px;color:#787878;font-family: Roboto_Light; font-size: 24px;width: 110px; height: 60px; background-color: transparent;width:100%;" onclick="btback()"><img src="image/arrowiosback.png" width="40" height="40" style=" margin: -8px 0px 0px -120px ;" alt=""/></button></td><td style="width: 33.3%"><button type="button" style="border-color: #dcdcdc;border-width: 1px;border-color: #dcdcdc;border-width: 1px;margin: 0px 0px 0px 0px;color:#FFFFFF;font-family: Roboto_Light; font-size: 24px;width: 110px; height: 60px; background-color: #64c800;width:100%;" hidden onclick="pcbtnSaveqr()">下載</button></td><td style="width: 33.3%"><button type="button" style="border-color: #dcdcdc;border-width: 1px;border-color: #dcdcdc;border-width: 1px;margin: 0px 0px 0px 0px;color:#787878;font-family: Roboto_Light; font-size: 24px;width: 110px; height: 60px; background-color: #cce8fc;width:100%;" hidden onclick="pcbtnSaveTmp()"'+
- '>複製</button> </td>
- </tbody>
- </table>
-
- <div style="margin: 6px 0 0px 1px;background-color:#FFFFFF; " id="987">
- <button id="btn8000" style="margin: 6px 0px 0px 0px;outline:none;line-height:40px;vertical-align: middle; text-align: left;width:100%;border:0px white none;background-color:#FFFFFF;font-weight: bold;font-family:Roboto_Light;font-size:30px;color:#000000;height:42px;"></button>
-
- <button id="btn100" style="margin: 12px 0px 0px 0px;outline:none;line-height:40px;vertical-align: middle; text-align: left;width:100%;border:0px white none;background-color:#FFFFFF;font-weight: bold;font-family:Roboto_Light;font-size:30px;color:#000000;height:42px;"></button>
- <button id="btn9000" style="margin: 12px 0px 0px 0px;outline:none;line-height:32px;vertical-align: middle; text-align: left;width:100%;border:0px white none;background-color:#FFFFFF;font-weight: bold;font-family:Roboto_Light;font-size:28px;color:#000000;height:32px;"></button>
- <button id="btn9100" style="margin: 12px 0px 0px 0px;outline:none;line-height:32px;vertical-align: middle; text-align: left;width:100%;border:0px white none;background-color:#FFFFFF;font-weight: bold;font-family:Roboto_Light;font-size:28px;color:#000000;height:32px;"></button>
- <button id="btn9200" style="margin: 12px 0px 0px 0px;outline:none;line-height:32px;vertical-align: middle; text-align: left;width:100%;border:0px white none;background-color:#FFFFFF;font-weight: bold;font-family:Roboto_Light;font-size:28px;color:#000000;height:32px;"></button>
- <div style="text-align:center">
- <!-- <h1 class="h3 mb-3 font-weight-normal">預收貨款</h1> -->
- <!-- <form class="form-signin" id="senddocument"> -->
- </br>
- </br>
- </br>
- </br>
- <center>
- <div id="jquery-qrcode-div" ></div>
- </br>
- </center>
- </br>
- </div> </div>
- <table style="width: 100%">
- <tbody>
- <tr>
- <td style="width: 50%"><button type="button" style="border-color: #dcdcdc;border-width: 1px;border-color: #dcdcdc;border-width: 1px;margin: 20px 0px 20px 0px;color:#FFFFFF;font-family: Roboto_Light; font-size: 24px;width: 110px; height: 60px; background-color: #64c800;width:100%;" onclick="pcbtnSaveqr()">存檔</button></td><td style="width: 50%"><button type="button" style="border-color: #dcdcdc;border-width: 1px;border-color: #dcdcdc;border-width: 1px;margin: 20px 0px 20px 0px;color:#787878;font-family: Roboto_Light; font-size: 24px;width: 110px; height: 60px; background-color: #cce8fc;width:100%;" onclick="ccop()"'+
- '>複製</button></td></tr>
- </tbody>
- </table>
-
-
- </div>
- <div id="output" style="display:none">
- <h2>Output</h2>
- </div>
-
- <script type="text/javascript">
- function ccop()
- {
- try
- {
- navigator.clipboard.write();
- const el = document.getElementById("987");
- html2canvas(el).then(canvas => {
- canvas.toBlob(blob => navigator.clipboard.write([new ClipboardItem({'image/png': blob})]));
- alert('已經複製到剪貼簿');
- });
-
-
- }catch(e)
- {
- alert(e);
- }
-
- }
- function pcbtnSaveTmp() //複製
- {
- var data = new Uint8Array([
- 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,8,0,0,
- 0,8,8,2,0,0,0,75,109,41,220,0,0,0,34,73,68,65,84,8,215,99,120,
- 173,168,135,21,49,0,241,255,15,90,104,8,33,129,83,7,97,163,136,
- 214,129,93,2,43,2,0,181,31,90,179,225,252,176,37,0,0,0,0,73,69,
- 78,68,174,66,96,130]);
- var blob = new Blob([data], { type: "image/png" });
- var url = URL.createObjectURL(blob);
- var img = new Image();
- img.src = url;
- img.height=400;
- img.width=400;
-
-
- document.body.appendChild(img);
-
- alert('OK');
- }
-
- function downloadURI(uri, name) {
- var link = document.createElement("a");
-
- link.download = name;
- link.href = uri;
- document.body.appendChild(link);
- link.click();
-
- }
-
-
-
- /*
- var saveData = (function () {
- var a = document.createElement("a");
- document.body.appendChild(a);
- a.style = "display: none";
- return function (data, fileName) {
- var blob = new Blob([data], {type: "image/png"}),
- url = window.URL.createObjectURL(blob);
- a.href = url;
- a.download = fileName;
- a.click();
- window.URL.revokeObjectURL(url);
- };
- }());
- */
- function canvasToImage(canvas) {
- try
- {
- // const filename = 'xxxxx';
- const filename =kname+' '+whoorder+' '+vvvtime;
-
- Canvas2Image.saveAsPNG(
- canvas,
- canvas.width, canvas.height,
- filename
- );
- }catch(e)
- {alert(e);}
- }
-
- function pcbtnSaveqr() //下載
- {
-
- const el = document.getElementById("987");
- html2canvas(el).then(canvas => {
- canvasToImage(canvas);
- });
-
-
- /*
- var data = new Uint8Array([
- 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,8,0,0,
- 0,8,8,2,0,0,0,75,109,41,220,0,0,0,34,73,68,65,84,8,215,99,120,
- 173,168,135,21,49,0,241,255,15,90,104,8,33,129,83,7,97,163,136,
- 214,129,93,2,43,2,0,181,31,90,179,225,252,176,37,0,0,0,0,73,69,
- 78,68,174,66,96,130]);
- var blob = new Blob([data], { type: "image/png" });
- var url = URL.createObjectURL(blob);
- var img = new Image();
- img.src = url;
- img.height=400;
- img.width=400;
-
- saveData(data, '123.png');
- */
- }
-
- function btback()
- {
- try
- {
- // document.location = "index3.html?idx="+idx+"&qrcd="+vvqrcd+"&tt="+tt+"&cy="+cy+"&name="+kname+"&st="+vst+"&et="+vet+"&tp="+type+"&CID="+CID+"&ID="+kkid+"&PW="+PW+"&TYPE="+TYPE+"&SN="+SN+"&MQTT="+vmqtt+"&SubID="+SubID;;
- history.go(-1);
- }catch(e)
- {
- alert(e);
- }
- }
-
-
- function btnSaveTmp()
- {
- try
- {
- issame=false;
- //alert(idx);
- var vvee1='';
- var vvee2='';
- var vvee3='';
- var cycy='';
-
- var st1 = '0000' ;
- var et1= '0000' ;
-
- var st2 = '0000' ;
- var et2= '0000' ;
-
- var st3 = '0000' ;
- var et3= '0000' ;
- //12345
- var vItemNOSer=document.getElementById("ItemNOSer").value;
- if (vItemNOSer.length<1)
- {
- alert('請輸入預約人');
- return;
- }
-
- if((document.getElementById("sd").value<1) || (document.getElementById("ed").value<1) ||(document.getElementById("sdt1").value<1) || (document.getElementById("sdt2").value<1))
- {
- alert('請輸入開始與結束日期時間');
- return;
- }
-
- var vsdsd=document.getElementById("sd").value+'T'+document.getElementById("sdt1").value;
- //alert(vsdsd);
- //return;
- var veded =document.getElementById("ed").value+'T'+document.getElementById("sdt2").value;
- //alert(veded);
- if ((vsdsd.length<2)|| (veded.length<2))
- {
- alert('請輸入開始與結束日期時間');
- return;
- }
- //alert('pass');
- if (vsdsd.length>16)
- {
- vsdsd=vsdsd.substring(0,16);
- }
- if (veded.length>16)
- {
- veded=veded.substring(0,16);
- }
- vsdsd=vsdsd.replace('T','_');
- vsdsd=vsdsd.replace('-','/');
- vsdsd=vsdsd.replace('-','/');
-
- veded=veded.replace('T','_');
- veded=veded.replace('-','/');
- veded=veded.replace('-','/');
- vsdsd=vsdsd.substring(2,vsdsd.length);
- veded=veded.substring(2,veded.length);
- //alert(vsdsd);
- //alert(veded);
- var vtstp=vsdsd+','+veded;
-
- //alert(vtstp);
- //return;
- //if (document.getElementById("d11").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png')
- if (document.getElementById("d11").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee1='1';
- //alert('bgreen');
- }else
- {
- vvee1='0';
- //alert('bgrey');
- }
- if (document.getElementById("d12").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee1=vvee1+'1';
- }else
- {
- vvee1=vvee1+'0';
- }
- if (document.getElementById("d13").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee1=vvee1+'1';
- }else
- {
- vvee1=vvee1+'0';
- }
- if (document.getElementById("d14").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee1=vvee1+'1';
- }else
- {
- vvee1=vvee1+'0';
- }
- if (document.getElementById("d15").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee1=vvee1+'1';
- }else
- {
- vvee1=vvee1+'0';
- }
- if (document.getElementById("d16").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee1=vvee1+'1';
- }else
- {
- vvee1=vvee1+'0';
- }
- if (document.getElementById("d17").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee1=vvee1+'1';
- }else
- {
- vvee1=vvee1+'0';
- }
- //alert(vvee1);
-
-
-
- if (document.getElementById("d21").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee2='1';
- //alert('bgreen');
- }else
- {
- vvee2='0';
- //alert('bgrey');
- }
- if (document.getElementById("d22").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee2=vvee2+'1';
- }else
- {
- vvee2=vvee2+'0';
- }
- if (document.getElementById("d23").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee2=vvee2+'1';
- }else
- {
- vvee2=vvee2+'0';
- }
- if (document.getElementById("d24").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee2=vvee2+'1';
- }else
- {
- vvee2=vvee2+'0';
- }
- if (document.getElementById("d25").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee2=vvee2+'1';
- }else
- {
- vvee2=vvee2+'0';
- }
- if (document.getElementById("d26").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee2=vvee2+'1';
- }else
- {
- vvee2=vvee2+'0';
- }
- if (document.getElementById("d27").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee2=vvee2+'1';
- }else
- {
- vvee2=vvee2+'0';
- }
- // alert(vvee2);
-
-
- if (document.getElementById("d31").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee3='1';
- //alert('bgreen');
- }else
- {
- vvee3='0';
- //alert('bgrey');
- }
- if (document.getElementById("d32").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee3=vvee3+'1';
- }else
- {
- vvee3=vvee3+'0';
- }
- if (document.getElementById("d33").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee3=vvee3+'1';
- }else
- {
- vvee3=vvee3+'0';
- }
- if (document.getElementById("d34").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee3=vvee3+'1';
- }else
- {
- vvee3=vvee3+'0';
- }
- if (document.getElementById("d35").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee3=vvee3+'1';
- }else
- {
- vvee3=vvee3+'0';
- }
- if (document.getElementById("d36").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee3=vvee3+'1';
- }else
- {
- vvee3=vvee3+'0';
- }
- if (document.getElementById("d37").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee3=vvee3+'1';
- }else
- {
- vvee3=vvee3+'0';
- }
- //alert(vvee3);
- var ktype = '1';
- if (vvee1=='0000000')
- {
-
- }else
- {
- ktype='2';
- st1 = document.getElementById("st1").value.replace(':','') ;
- et1= document.getElementById("et1").value.replace(':','') ;
- if (st1.length==0 || et1.length==0)
- {
- alert('請選擇時段1的起始與結束時間');
- return;
- }
- }
- if (vvee2=='0000000')
- {
-
- }else
- {
- ktype='2';
- st2 = document.getElementById("st2").value.replace(':','') ;
- et2= document.getElementById("et2").value.replace(':','') ;
- if (st2.length==0 || et2.length==0)
- {
- alert('請選擇時段2的起始與結束時間');
- return;
- }
- }
- if (vvee3=='0000000')
- {
-
- }else
- {
- ktype='2';
- st3 = document.getElementById("st3").value.replace(':','') ;
- et3= document.getElementById("et3").value.replace(':','') ;
-
- //alert(st3.length)
- if (st3.length==0 || et3.length==0)
- {
- alert('請選擇時段3的起始與結束時間');
- return;
- }
- }
-
- //alert(ktype);
-
-
- if (ktype=='2')
- {
- cycy=vvee1+','+st1 +','+ et1+','+ vvee2+','+st2+','+et2+','+vvee3+','+st3+','+et3;
- }
- else
- {
- //cycy='';
- }
- // alert(ktype);
- //updateOutput('cycy='+cycy);
- //alert(cycy);
-
-
- fincycle='';
- fincycle= document.getElementById("ItemNOSer").value+';';
- fincycle=fincycle+ vtstp+';';
-
- fincycle=fincycle+cycy+';';
-
- //alert(cycy);
- // alert(fincycle);
- if (orgcycle==fincycle)
- {
- issame=true;
- // alert('相同');
- }
-
- if (issame)
- {
- alert('OK');
- window.history.go(-1);
- }
- else
- {
-
- var vt=new Date().format("yyyy/MM/dd_HH:mm:ss");
- //alert(document.getElementById("ItemNOSer").value);
- vtttt = document.getElementById("ItemNOSer").value;
-
- // alert(ktype);
- // return;
-
- 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\"}}";
-
- var jsonString = "{\"action\":\"encode\", \"serial\":\"001\",\"data\":"+edata+"}";
- vsn='001';
- isget2=false;
- // updateOutput(jsonString);
- //alert(jsonString
-
- if (TYPE=='IOS')
- {
- window.webkit.messageHandlers.WebToApp.postMessage(jsonString);
- }
-
- if (TYPE=='ANDROID')
- {
- webSocket.send(jsonString);
- }
-
- if (TYPE=='PC')
- {
- //alert(edata);
- selfendecode(edata);
- }
-
- }
-
- }catch(e)
- {
- alert(e);
- }
-
- }
-
- function senttoother()
- {
- try
- {
- message999 = new Paho.MQTT.Message( "modify,"+idx+","+SubID+","+kname );
- // alert('send to other = '+ "modify,"+idx+","+SubID+","+kname );
- message999.qos = 0;
- message999.retained = false;
-
- for (var iii = 1; iii < 9; iii++)
- {
- if ( iii.toString() !=SubID.toString())
- {
- message999.destinationName = 'ReservePC'+CID+'1-'+iii.toString() ;
- client.send(message999);
-
- message999.destinationName = 'Reserve'+CID+'1-'+iii.toString() ;
- client2.send(message999);
- }
- }
-
- }
- catch(e)
- {
- alert(e);
- }
- }
-
- function btnSaveqr()
- {
-
- issame=false;
- //alert(idx);
- var vvee1='';
- var vvee2='';
- var vvee3='';
- var cycy='';
-
- var st1 = '0000' ;
- var et1= '0000' ;
-
- var st2 = '0000' ;
- var et2= '0000' ;
-
- var st3 = '0000' ;
- var et3= '0000' ;
-
-
- //var vsdsd=document.getElementById("sd").value;
- //var veded =document.getElementById("ed").value;
- var vsdsd=document.getElementById("sd").value+'T'+document.getElementById("sdt1").value;
- //alert(vsdsd);
- //return;
- var veded =document.getElementById("ed").value+'T'+document.getElementById("sdt2").value;
-
- if (vsdsd.length>16)
- {
- vsdsd=vsdsd.substring(0,16);
- }
- if (veded.length>16)
- {
- veded=veded.substring(0,16);
- }
- //var vsdsd=document.getElementById("sd").value.format("yyyy/MM/dd_HH:mm");
- //vsdsd=vsdsd.substring(0,16);
- //alert(vsdsd);
- //return;
-
- //12345
- var vItemNOSer=document.getElementById("ItemNOSer").value;
- if (vItemNOSer.length<1)
- {
- alert('請輸入預約人');
- return;
- }
-
- if((document.getElementById("sd").value<1) || (document.getElementById("ed").value<1) ||(document.getElementById("sdt1").value<1) || (document.getElementById("sdt2").value<1))
- {
- alert('請輸入開始與結束日期時間');
- return;
- }
-
- var vsdsd=document.getElementById("sd").value+'T'+document.getElementById("sdt1").value;
- //alert(vsdsd);
- //return;
- var veded =document.getElementById("ed").value+'T'+document.getElementById("sdt2").value;
- //alert(veded);
- if ((vsdsd.length<2)|| (veded.length<2))
- {
- alert('請輸入開始與結束日期時間');
- return;
- }
- vsdsd=vsdsd.replace('T','_');
- vsdsd=vsdsd.replace('-','/');
- vsdsd=vsdsd.replace('-','/');
-
- veded=veded.replace('T','_');
- veded=veded.replace('-','/');
- veded=veded.replace('-','/');
- vsdsd=vsdsd.substring(2,vsdsd.length);
- veded=veded.substring(2,veded.length);
- //alert(vsdsd);
- //alert(veded);
- var vtstp=vsdsd+','+veded;
- vtstpqr=vtstp;
- vtstpqr=vtstpqr.replace('_',' ');
- vtstpqr=vtstpqr.replace('_',' ');
- vtstpqr=vtstpqr.replace(',','~');
-
- //alert(vtstp);
- //return;
-
- if (document.getElementById("d11").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee1='1';
- //alert('bgreen');
- }else
- {
- vvee1='0';
- //alert('bgrey');
- }
- if (document.getElementById("d12").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee1=vvee1+'1';
- }else
- {
- vvee1=vvee1+'0';
- }
- if (document.getElementById("d13").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee1=vvee1+'1';
- }else
- {
- vvee1=vvee1+'0';
- }
- if (document.getElementById("d14").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee1=vvee1+'1';
- }else
- {
- vvee1=vvee1+'0';
- }
- if (document.getElementById("d15").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee1=vvee1+'1';
- }else
- {
- vvee1=vvee1+'0';
- }
- if (document.getElementById("d16").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee1=vvee1+'1';
- }else
- {
- vvee1=vvee1+'0';
- }
- if (document.getElementById("d17").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee1=vvee1+'1';
- }else
- {
- vvee1=vvee1+'0';
- }
- //alert(vvee1);
-
-
-
- if (document.getElementById("d21").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee2='1';
- //alert('bgreen');
- }else
- {
- vvee2='0';
- //alert('bgrey');
- }
- if (document.getElementById("d22").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee2=vvee2+'1';
- }else
- {
- vvee2=vvee2+'0';
- }
- if (document.getElementById("d23").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee2=vvee2+'1';
- }else
- {
- vvee2=vvee2+'0';
- }
- if (document.getElementById("d24").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee2=vvee2+'1';
- }else
- {
- vvee2=vvee2+'0';
- }
- if (document.getElementById("d25").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee2=vvee2+'1';
- }else
- {
- vvee2=vvee2+'0';
- }
- if (document.getElementById("d26").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee2=vvee2+'1';
- }else
- {
- vvee2=vvee2+'0';
- }
- if (document.getElementById("d27").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee2=vvee2+'1';
- }else
- {
- vvee2=vvee2+'0';
- }
- // alert(vvee2);
-
-
- if (document.getElementById("d31").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee3='1';
- //alert('bgreen');
- }else
- {
- vvee3='0';
- //alert('bgrey');
- }
- if (document.getElementById("d32").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee3=vvee3+'1';
- }else
- {
- vvee3=vvee3+'0';
- }
- if (document.getElementById("d33").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee3=vvee3+'1';
- }else
- {
- vvee3=vvee3+'0';
- }
- if (document.getElementById("d34").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee3=vvee3+'1';
- }else
- {
- vvee3=vvee3+'0';
- }
- if (document.getElementById("d35").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee3=vvee3+'1';
- }else
- {
- vvee3=vvee3+'0';
- }
- if (document.getElementById("d36").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee3=vvee3+'1';
- }else
- {
- vvee3=vvee3+'0';
- }
- if (document.getElementById("d37").style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- vvee3=vvee3+'1';
- }else
- {
- vvee3=vvee3+'0';
- }
- //alert(vvee3);
- var ktype = '1';
- if (vvee1=='0000000')
- {
-
- }else
- {
- ktype='2';
- st1 = document.getElementById("st1").value.replace(':','') ;
- et1= document.getElementById("et1").value.replace(':','') ;
- if (st1.length==0 || et1.length==0)
- {
- alert('請選擇時段1的起始與結束時間');
- return;
- }
- }
- if (vvee2=='0000000')
- {
-
- }else
- {
- ktype='2';
- st2 = document.getElementById("st2").value.replace(':','') ;
- et2= document.getElementById("et2").value.replace(':','') ;
- if (st2.length==0 || et2.length==0)
- {
- alert('請選擇時段2的起始與結束時間');
- return;
- }
- }
- if (vvee3=='0000000')
- {
-
- }else
- {
- ktype='2';
- st3 = document.getElementById("st3").value.replace(':','') ;
- et3= document.getElementById("et3").value.replace(':','') ;
-
- //alert(st3.length)
- if (st3.length==0 || et3.length==0)
- {
- alert('請選擇時段3的起始與結束時間');
- return;
- }
- }
-
-
-
-
- if (ktype=='2')
- {
- cycy=vvee1+','+st1 +','+ et1+','+ vvee2+','+st2+','+et2+','+vvee3+','+st3+','+et3;
-
- vcyd='';
- var vcy = cycy.split(',');
- let days=[];
-
- if (vcy[0]=='0000000')
- {
- }else
- {
-
-
- if (vcy[0].substring(0,1)=='1')
- days.push('日');
- if (vcy[0].substring(1,2)=='1')
- days.push('一');
- if (vcy[0].substring(2,3)=='1')
- days.push('二');
- if (vcy[0].substring(3,4)=='1')
- days.push('三');
- if (vcy[0].substring(4,5)=='1')
- days.push('四');
- if (vcy[0].substring(5,6)=='1')
- days.push('五');
- if (vcy[0].substring(6,7)=='1')
- days.push('六');
- vcy[1]=vcy[1].substring(0,2)+':'+vcy[1].substring(2,4);
- vcy[2]=vcy[2].substring(0,2)+':'+vcy[2].substring(2,4);
- vcyd=vcyd+'#1.'+vcy[1]+'~'+vcy[2]+' '+' '+days.join(',');
- }
-
- days=[];
- if (vcy[3]=='0000000')
- {
- }else
- {
-
-
- if (vcy[3].substring(0,1)=='1')
- days.push('日');
- if (vcy[3].substring(1,2)=='1')
- days.push('一');
- if (vcy[3].substring(2,3)=='1')
- days.push('二');
- if (vcy[3].substring(3,4)=='1')
- days.push('三');
- if (vcy[3].substring(4,5)=='1')
- days.push('四');
- if (vcy[3].substring(5,6)=='1')
- days.push('五');
- if (vcy[3].substring(6,7)=='1')
- days.push('六');
- vcy[4]=vcy[4].substring(0,2)+':'+vcy[4].substring(2,4);
- vcy[5]=vcy[5].substring(0,2)+':'+vcy[5].substring(2,4);
- vcyd=vcyd+'#2.'+vcy[4]+'~'+vcy[5]+' '+' '+days.join(',');
- }
-
- days=[];
- if (vcy[6]=='0000000')
- {
- }else
- {
-
-
- if (vcy[6].substring(0,1)=='1')
- days.push('日');
- if (vcy[6].substring(1,2)=='1')
- days.push('一');
- if (vcy[6].substring(2,3)=='1')
- days.push('二');
- if (vcy[6].substring(3,4)=='1')
- days.push('三');
- if (vcy[6].substring(4,5)=='1')
- days.push('四');
- if (vcy[6].substring(5,6)=='1')
- days.push('五');
- if (vcy[6].substring(6,7)=='1')
- days.push('六');
- vcy[7]=vcy[7].substring(0,2)+':'+vcy[7].substring(2,4);
- vcy[8]=vcy[8].substring(0,2)+':'+vcy[8].substring(2,4);
- vcyd=vcyd+'#3.'+vcy[7]+'~'+vcy[8]+' '+' '+days.join(',');
- }
-
-
- }
- else
- {
- //cycy='';
- }
-
- fincycle='';
- fincycle= document.getElementById("ItemNOSer").value+';';
- fincycle=fincycle+ vtstp+';';
-
- fincycle=fincycle+cycy+';';
-
- //alert(cycy);
- // alert(fincycle);
- if (orgcycle==fincycle)
- {
- issame=true;
- // alert('相同');
- }
- vtttt = document.getElementById("ItemNOSer").value;
- if (issame)
- {
-
- vsn='';
- try
- {
-
- vtttt = document.getElementById("ItemNOSer").value;
-
-
- var jsonString = "{\"action\":\"shareQr\", \"serial\":\"001\",\"data\":{\"name\":\""+kname+"\",\"note\":\""+vtttt+"\",\"QRCode\":\""+vvqrcd+"\",\"time\":\""+vtstpqr+"\",\"cycle\":\""+vcyd+"\"}}";
-
- if (TYPE=='IOS')
- {
- window.webkit.messageHandlers.WebToApp.postMessage(jsonString);
- }
- if (TYPE=='ANDROID')
- {
- webSocket.send(jsonString);
- }
-
- if (TYPE=='PC')
- {
- shareQrPC(jsonString);
- }
-
- }catch(e)
- {
- alert('連線異常');
- }
-
-
- }
- else
- {
-
-
-
- var vt=new Date().format("yyyy/MM/dd_HH:mm:ss")
- // alert(document.getElementById("ItemNOSer").value);
- vtttt = document.getElementById("ItemNOSer").value;
- // alert(ktype);
- // return;
- 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\"}}";
-
- var jsonString333 = "{\"action\":\"encode\", \"serial\":\"003\",\"data\":"+edata456+"}";
- vsn='003';
- //updateOutput(jsonString);
- //alert(jsonString);
- //return;
- if (TYPE=='IOS')
- {
- window.webkit.messageHandlers.WebToApp.postMessage(jsonString333);
- }
-
- if (TYPE=='ANDROID')
- {
- webSocket.send(jsonString333);
- }
-
- if (TYPE=='PC')
- {
- selfendecode(edata456);
- }
- }
-
-
-
-
- }
-
- function btnitemback(vid)
- {
- try
- {
- //alert(vid);
- // alert(document.getElementById(vid).style.backgroundImage.slice(4, -1).replace(/"/g, ""));
-
- if (document.getElementById(vid).style.backgroundImage.slice(4, -1).replace(/"/g, "").includes('bgreen.png'))
- {
- document.getElementById(vid).style.background="url('image/bgrey.png') no-repeat center/100%";
- }else
- {
- document.getElementById(vid).style.background="url('image/bgreen.png') no-repeat center/100%";
- }
-
-
- }catch(e)
- {
- alert(e);
- }
-
- }
-
- function btndddel()
- {
-
- var yes = confirm('確定刪除?');
- if (yes) {
-
- try
- {
-
- //alert('ue');
- //return;
- var vt=new Date().format("yyyy/MM/dd_HH:mm:ss")
- // alert(document.getElementById("ItemNOSer").value);
- vtttt = document.getElementById("ItemNOSer").value;
- // alert(ktype);
-
- // return;
- var edata3 ="";
- edata3 ="{\"action\":\"mqttdeleteRemoteKey\",\"data\":{\"Command\":\"PassWord="+PW+"&IndexID="+idx+"&UserID="+ID+"\",\"SerialNo\":\"Reserve"+CID+"1-"+SubID+"\",\"TimeStamp\":\""+vt+"\",\"Token\":\"Gigatech23634857\"}}";
- // alert(edata);
- var jsonString4 ="";
- jsonString4 = "{\"action\":\"encode\", \"serial\":\"101\",\"data\":"+edata3+"}";
-
- vsn='101';
- // updateOutput(jsonString);
- //alert(jsonString);
- //return;
- if (TYPE=='IOS')
- {
- window.webkit.messageHandlers.WebToApp.postMessage(jsonString4);
- }
-
- if (TYPE=='ANDROID')
- {
- webSocket.send(jsonString4);
- }
-
- if (TYPE=='PC')
- {
- selfendecode(edata3);
- }
-
- }
- catch(e)
- {
- alert('連線異常');
- }
- } else {
- }
-
- }
-
-
- function getdoorlist()
- {
-
- var vt=new Date().format("yyyy/MM/dd_HH:mm:ss")
-
-
-
- var edata ="{\"action\":\"mqttqueryCallList\",\"data\":{\"Command\":\"PassWord="+PW+"\",\"SerialNo\":\"Reserve"+CID+"1\",\"TimeStamp\":\""+vt+"\",\"Token\":\"Gigatech23634857\"}}";
-
- var jsonString = "{\"action\":\"encode\", \"serial\":\"001\",\"data\":"+edata+"}";
- vsn='001';
- // updateOutput(jsonString);
- isget2=false;
- if (TYPE=='IOS')
- {
- window.webkit.messageHandlers.WebToApp.postMessage(jsonString);
- }
-
- if (TYPE=='ANDROID')
- {
- webSocket.send(jsonString);
- }
-
- if (TYPE=='PC')
- {
- selfendecode(edata);
- }
-
- }
-
-
-
- </script>
- <script type="text/javascript">
- var webSocket;
- var input = document.getElementById("input")
- var output = document.getElementById("output");
- var vdata="";
- var isok=true;
- var webSocket;
- //var connectBtn = document.getElementById("connectBtn");
- //var wsUrl = "ws://localhost:2980/";
- // var wsUrl = "ws://192.168.0.27:2980/";
- // var wsUrl = "ws://192.168.0.30:2980/";
- var wsUrl = "ws://127.0.0.1:2980/";
- //var wsUrl = "ws://192.168.0.25:2980/";
- function connect() {
- // open the connection if one does not exist
- if (webSocket !== undefined
- && webSocket.readyState !== WebSocket.CLOSED) {
- return;
- }
-
- // updateOutput("Trying to establish a WebSocket connection to <code>" + wsUrl + "</code>");
-
- // Create a websocket
- webSocket = new WebSocket(wsUrl);
-
- webSocket.onopen = function(event) {
-
- // updateOutput("Connected!");
- // connectBtn.disabled = true;
- try
- {
-
-
- /*
- setTimeout(() => {
- if (isget)
- {
- }else
- {
-
- getdoorlist() ;
- }
- }, 1000);
- */
-
- }catch(e)
- {
- alert(e);
- }
-
- };
-
- webSocket.onmessage = function(event)
- {
-
- if (vsn=='002'||vsn=='103')
- {
- // alert(vsn);
- isget=true;
- var ress = event.data;
- vsn='104';
- try
- {
- // var vobj = JSON.parse( ress);
- //alert( vobj.data);
- //var sevobj = JSON.parse( vobj);
- //alert('de'+ ress);
- senttoother();
- alert('OK');
- //23456
- window.history.go(-1);
- //document.location = "index2.html?KID="+ID +"&name="+ kname;
- }
- catch(e)
- {
- alert(e);
- }
- }
-
- if (vsn=='004')
- {
- isget3 = true;
- //alert('004');
- vsn='';
- var ress = event.data;
- try
- {
- // alert('de'+ ress);
- vobj = JSON.parse( ress);
- var qrcd= vobj.data.data.CardID;
- // alert( qrcd);
- //var sevobj = JSON.parse( vobj);
- // alert('de'+ ress);
- //alert('OK');
- //window.history.go(-1);
- //document.location = "index2.html?KID="+ID +"&name="+ kname;
- //"name":"健身房","note":"王大明09123456789","QRCode":"KaiZvhWz5dcUqkkuvAK0q6T/iw4dbE7CpGKDozTFL2LkH6g1YRdayW=="
- // alert(vtttt);
- //vcyd
- var jsonString = "{\"action\":\"shareQr\", \"serial\":\"001\",\"data\":{\"name\":\""+kname+"\",\"note\":\""+vtttt+"\",\"QRCode\":\""+qrcd+"\",\"time\":\""+vtstpqr+"\",\"cycle\":\""+vcyd+"\"}}";
- // updateOutput(jsonString);
- /// "WebToApp". 為我們和前端開發人員的約定
- orgcycle=fincycle;
- vvqrcd=qrcd;
- senttoother();
- if (TYPE=='IOS')
- {
- window.webkit.messageHandlers.WebToApp.postMessage(jsonString);
- }
- if (TYPE=='ANDROID')
- {
- webSocket.send(jsonString);
- }
-
- if (TYPE=='PC')
- {
- shareQrPC(jsonString);
- }
-
- }catch(e)
- {
- alert('連線異常');
- }
- }
-
- if (vsn=='001')
- {
- try
- {
- isget2=true;
- // alert( '001');
- var ress = event.data;
- // alert( ress);
-
- vobj = JSON.parse( ress);
- isget=false;
- // vdata = "{\"encrypt\":\"1\",\"data\":\""+vobj.data+"\"}";
- }catch(e)
- {
- alert(e);
- }
- //updateOutput('---------------------------');
- // updateOutput(vdata);
- // updateOutput('get en='+vobj.data);
- //var payload =vdata;
- var payload = "{\"encrypt\":\"1\",\"data\":\""+vobj.data+"\"}";
- //alert(payload);
- //23456
-
- message2 = new Paho.MQTT.Message( "{\"encrypt\":\"1\",\"data\":\""+vobj.data+"\"}");
- message2.destinationName = SN ;
- message2.qos = 0;
- message2.retained = false;
-
-
- // client.send(message);
- //setTimeout(() => {
- var vivi = 0;
- var intervalID = setInterval(() => {
- if (isget)
- {
-
- }
- else
- {
- if (vivi>15)
- {
- clearInterval(intervalID);
- alert('連線異常');
-
- }else
- {
- vivi++;
- updateOutput('message2 send ='+ message2.payloadString);
- if (isconn)
- {
- client.send(message2);
- }
-
- }
-
- }
- }, 400);
-
-
-
-
- }
-
- if (vsn=='101')
- {
- try
- {
- vsn='102';
- // alert( '102');
- var ress = event.data;
- // alert( ress);
- vobj = JSON.parse( ress);
- isget=false;
- // vdata = "{\"encrypt\":\"1\",\"data\":\""+vobj.data+"\"}";
-
- //updateOutput('---------------------------');
- // updateOutput(vdata);
-
- // var payload =vdata;
-
- message0 = new Paho.MQTT.Message("{\"encrypt\":\"1\",\"data\":\""+vobj.data+"\"}");
- message0.qos = 0;
- message0.retained = false;
- message0.destinationName = SN ;
- //setTimeout(() => {
- // client.send(message);
- var vivi = 0;
-
- var intervalID = setInterval(() => {
- if (isget)
- {
-
- }
- else
- {
- if (vivi>15)
- {
- clearInterval(intervalID);
- alert('連線異常');
-
- }else
- {
- vivi++;
- if (isconn)
- {
- client.send(message0);
- }
-
- }
-
- }
- }, 400);
-
-
-
-
- }catch(e)
- {
- alert(e);
- }
- }
-
- if (vsn=='003')
- {
-
- // alert( '003');
- var ress = event.data;
- // alert( ress);
- vobj = JSON.parse( ress);
- isget3=false;
- vdata = "{\"encrypt\":\"1\",\"data\":\""+vobj.data+"\"}";
-
- //updateOutput('---------------------------');
- // updateOutput(vdata);
-
- updateOutput('rece ='+vobj.data);
- message7 = new Paho.MQTT.Message("{\"encrypt\":\"1\",\"data\":\""+vobj.data+"\"}");
- message7.destinationName = SN ;
- message7.retained = false;
- message7.qos = 0;
- var vivi = 0;
- // client.send(message);
- var intervalID = setInterval(() => {
- if (isget3)
- {
-
- }
- else
- {
- if (vivi>15)
- {
- clearInterval(intervalID);
- alert('連線異常');
-
- }else
- {
- vivi++;
- updateOutput('message7 send ='+ message7.payloadString);
- if (isconn)
- {
- client.send(message7);
- }
- }
-
- }
- }, 400);
-
-
-
-
- }
- //updateOutput('---------------------------');
- // updateOutput(event.data);
-
- };
-
- webSocket.onclose = function(event) {
- // updateOutput("Connection Closed");
- //connectBtn.disabled = false;
- //sendBtn.disabled = true;
- };
- }
-
-
- function shareQr() {
- var text = input.value;
- var jsonString = "{\"action\":\"shareQr\", \"serial\":\"001\",\"data\":\""+text+"\"}";
- //updateOutput(jsonString);
- /// "WebToApp". 為我們和前端開發人員的約定
-
- if (TYPE=='IOS')
- {
- window.webkit.messageHandlers.WebToApp.postMessage(jsonString);
- }
- if (TYPE=='ANDROID')
- {
- webSocket.send(jsonString);
- }
- }
-
- function shareQrPC(message) {
- alert('shareQrPC '+message);
- }
-
- //self start
- function selfendecode(message) {
-
- if (vsn=='002'||vsn=='103')
- {
- isget=true;
- // alert(vsn);
- message = teaDecrypt(message,'75$095huOQ77kKv!');
- // alert('002 or 103 '+message);
- var ress = message;
- vsn='104';
- try
- {
- // var vobj = JSON.parse( ress);
- //alert( vobj.data);
- //var sevobj = JSON.parse( vobj);
- // alert('de'+ ress);
- senttoother();
- alert('OK');
- //23456
- window.history.go(-1);
- //document.location = "index2.html?KID="+ID +"&name="+ kname;
- }catch(e)
- {
- alert(e);
- }
- }
-
- if (vsn=='004')
- {
- //alert('004');
- vsn='';
- message = teaDecrypt(message,'75$095huOQ77kKv!');
- isget3 = true;
- var ress = message;
-
-
- try
- {
- // alert('de'+ ress);
- vobj = JSON.parse( ress);
- var qrcd= vobj.data.CardID;
- alert('004 '+message);
-
- // var qrcd= vobj.data.data.CardID;
- // alert( qrcd);
- //var sevobj = JSON.parse( vobj);
- // alert('de'+ ress);
- //alert('OK');
- //window.history.go(-1);
- //document.location = "index2.html?KID="+ID +"&name="+ kname;
- //"name":"健身房","note":"王大明09123456789","QRCode":"KaiZvhWz5dcUqkkuvAK0q6T/iw4dbE7CpGKDozTFL2LkH6g1YRdayW=="
- // alert(vtttt);
- //vcyd
- var jsonString = "{\"action\":\"shareQr\", \"serial\":\"001\",\"data\":{\"name\":\""+kname+"\",\"note\":\""+vtttt+"\",\"QRCode\":\""+qrcd+"\",\"time\":\""+vtstpqr+"\",\"cycle\":\""+vcyd+"\"}}";
- // alert(jsonString);
- // updateOutput(jsonString);
- /// "WebToApp". 為我們和前端開發人員的約定
- orgcycle=fincycle;
- vvqrcd=qrcd;
- senttoother();
- if (TYPE=='IOS')
- {
- window.webkit.messageHandlers.WebToApp.postMessage(jsonString);
- }
- if (TYPE=='ANDROID')
- {
- webSocket.send(jsonString);
- }
-
- if (TYPE=='PC')
- {
- shareQrPC(jsonString);
- }
-
- }catch(e)
- {
- alert(e);
- }
- }
-
- if (vsn=='001')
- {
- try
- {
- // alert( '001');
- message = teaEncrypt(message,'75$095huOQ77kKv!');
- var ress = message;
- // alert( ress);
- isget2=true;
- // vobj = JSON.parse( ress);
- isget=false;
- // vdata = "{\"encrypt\":\"1\",\"data\":\""+vobj.data+"\"}";
- }catch(e)
- {
- alert(e);
- }
- //updateOutput('---------------------------');
- // updateOutput(vdata);
-
-
- message4 = new Paho.MQTT.Message("{\"encrypt\":\"1\",\"data\":\""+message+"\"}");
- message4.destinationName = SN ;
- message4.retained = false;
- message4.qos = 0;
- var vivi = 0;
- // client.send(message);
- var intervalID = setInterval(() => {
- if (isget)
- {
-
- }
- else
- {
- if (vivi>15)
- {
- clearInterval(intervalID);
- alert('連線異常');
-
- }else
- {
- vivi++;
- if (isconn)
- {
- client.send(message4);
- }
-
- }
-
- }
- }, 400);
-
- }
-
- if (vsn=='101')
- {
- try
- {
- vsn='102';
- // alert( '102');
- message = teaEncrypt(message,'75$095huOQ77kKv!');
- var ress = message;
- // alert( ress);
- // vobj = JSON.parse( ress);
- isget=false;
- // vdata = "{\"encrypt\":\"1\",\"data\":\""+message+"\"}";
-
- //updateOutput('---------------------------');
- // updateOutput(vdata);
-
-
- message9 = new Paho.MQTT.Message("{\"encrypt\":\"1\",\"data\":\""+message+"\"}");
- message9.destinationName = SN ;
- message9.retained = false;
- message9.qos = 0;
- var vivi = 0;
-
- // client.send(message);
- var intervalID = setInterval(() => {
- if (isget)
- {
-
- }
- else
- {
- if (vivi>15)
- {
-
- clearInterval(intervalID);
- alert('連線異常');
- }else
- {
- if (isconn)
- {
- client.send(message9);
- }
-
- vivi++;
- }
-
- }
- }, 400);
-
- }catch(e)
- {
- alert(e);
- }
- }
-
- if (vsn=='003')
- {
- try
- {
- // alert( '003');
- message = teaEncrypt(message,'75$095huOQ77kKv!');
- var ress = message;
- // alert( ress);
- // vobj = JSON.parse( ress);
- isget3=false;
- // vdata = "{\"encrypt\":\"1\",\"data\":\""+message+"\"}";
- }catch(e)
- {
- alert(e);
- }
- //updateOutput('---------------------------');
- // updateOutput(vdata);
-
-
- message6= new Paho.MQTT.Message("{\"encrypt\":\"1\",\"data\":\""+message+"\"}");
- message6.destinationName = SN ;
- message6.retained = false;
- message6.qos = 0;
-
- //setTimeout(() => {
- var vivi = 0;
-
-
- var intervalID = setInterval(() => {
- if (isget3)
- {
-
- }
- else
- {
- if (vivi>15)
- {
- alert('連線異常');
- clearInterval(intervalID);
- }else
- {
- vivi++;
- if (isconn)
- {
- client.send(message6);
- }
-
- }
-
- }
- }, 400);
-
-
-
- }
-
- // updateOutput(message);
-
- }
- //self end
-
- function AppToWeb(message) {
-
- if (vsn=='002'||vsn=='103')
- {
- isget=true;
- // alert(vsn);
- var ress = message;
- vsn='104';
- try
- {
- // var vobj = JSON.parse( ress);
- //alert( vobj.data);
- //var sevobj = JSON.parse( vobj);
- // alert('de'+ ress);
- senttoother();
- alert('OK');
- //23456
- window.history.go(-1);
- //document.location = "index2.html?KID="+ID +"&name="+ kname;
- }catch(e)
- {
- alert(e);
- }
- }
-
- if (vsn=='004')
- {
- //alert('004');
- vsn='';
- isget3 = true;
- var ress = message;
- try
- {
- // alert('de'+ ress);
- vobj = JSON.parse( ress);
- var qrcd= vobj.data.data.CardID;
- // alert( qrcd);
- //var sevobj = JSON.parse( vobj);
- // alert('de'+ ress);
- //alert('OK');
- //window.history.go(-1);
- //document.location = "index2.html?KID="+ID +"&name="+ kname;
- //"name":"健身房","note":"王大明09123456789","QRCode":"KaiZvhWz5dcUqkkuvAK0q6T/iw4dbE7CpGKDozTFL2LkH6g1YRdayW=="
- // alert(vtttt);
- //vcyd
- var jsonString = "{\"action\":\"shareQr\", \"serial\":\"001\",\"data\":{\"name\":\""+kname+"\",\"note\":\""+vtttt+"\",\"QRCode\":\""+qrcd+"\",\"time\":\""+vtstpqr+"\",\"cycle\":\""+vcyd+"\"}}";
- // alert(jsonString);
- // updateOutput(jsonString);
- /// "WebToApp". 為我們和前端開發人員的約定
- orgcycle=fincycle;
- vvqrcd=qrcd;
- senttoother();
- if (TYPE=='IOS')
- {
- window.webkit.messageHandlers.WebToApp.postMessage(jsonString);
- }
- if (TYPE=='ANDROID')
- {
- webSocket.send(jsonString);
- }
-
- }catch(e)
- {
- alert(e);
- }
- }
-
- if (vsn=='001')
- {
- try
- {
- // alert( '001');
- var ress = message;
- // alert( ress);
- isget2=true;
- vobj = JSON.parse( ress);
- isget=false;
- vdata = "{\"encrypt\":\"1\",\"data\":\""+vobj.data+"\"}";
- }catch(e)
- {
- alert(e);
- }
- //updateOutput('---------------------------');
- // updateOutput(vdata);
-
-
- message4 = new Paho.MQTT.Message("{\"encrypt\":\"1\",\"data\":\""+vobj.data+"\"}");
- message4.destinationName = SN ;
- message4.retained = false;
- message4.qos = 0;
- var vivi = 0;
- // client.send(message);
- var intervalID = setInterval(() => {
- if (isget)
- {
-
- }
- else
- {
- if (vivi>15)
- {
- clearInterval(intervalID);
- alert('連線異常');
-
- }else
- {
- vivi++;
- if (isconn)
- {
- client.send(message4);
- }
-
- }
-
- }
- }, 400);
-
- }
-
- if (vsn=='101')
- {
- try
- {
- vsn='102';
- // alert( '102');
- var ress = message;
- // alert( ress);
- vobj = JSON.parse( ress);
- isget=false;
- vdata = "{\"encrypt\":\"1\",\"data\":\""+vobj.data+"\"}";
-
- //updateOutput('---------------------------');
- // updateOutput(vdata);
-
-
- message9 = new Paho.MQTT.Message("{\"encrypt\":\"1\",\"data\":\""+vobj.data+"\"}");
- message9.destinationName = SN ;
- message9.retained = false;
- message9.qos = 0;
- var vivi = 0;
-
- // client.send(message);
- var intervalID = setInterval(() => {
- if (isget)
- {
-
- }
- else
- {
- if (vivi>15)
- {
-
- clearInterval(intervalID);
- alert('連線異常');
- }else
- {
- if (isconn)
- {
- client.send(message9);
- }
-
- vivi++;
- }
-
- }
- }, 400);
-
- }catch(e)
- {
- alert(e);
- }
- }
-
- if (vsn=='003')
- {
- try
- {
- // alert( '003');
- var ress = message;
- // alert( ress);
- vobj = JSON.parse( ress);
- isget3=false;
- vdata = "{\"encrypt\":\"1\",\"data\":\""+vobj.data+"\"}";
- }catch(e)
- {
- alert(e);
- }
- //updateOutput('---------------------------');
- // updateOutput(vdata);
-
-
- message6= new Paho.MQTT.Message("{\"encrypt\":\"1\",\"data\":\""+vobj.data+"\"}");
- message6.destinationName = SN ;
- message6.retained = false;
- message6.qos = 0;
-
- //setTimeout(() => {
- var vivi = 0;
-
-
- var intervalID = setInterval(() => {
- if (isget3)
- {
-
- }
- else
- {
- if (vivi>15)
- {
- alert('連線異常');
- clearInterval(intervalID);
- }else
- {
- vivi++;
- if (isconn)
- {
- client.send(message6);
- }
-
- }
-
- }
- }, 400);
-
-
-
- }
-
- // updateOutput(message);
- return "Got it"
- }
-
- function endode() {
- var text = input.value;
- var jsonString = "{\"action\":\"encode\", \"serial\":\"001\",\"data\":"+text+"}";
-
- // updateOutput(jsonString);
- /// "WebToApp". 為我們和前端開發人員的約定
- if (TYPE=='IOS')
- {
- window.webkit.messageHandlers.WebToApp.postMessage(jsonString);
- }
- if (TYPE=='ANDROID')
- {
- webSocket.send(jsonString);
- }
-
- }
-
- function decode() {
- var text = input.value;
- var jsonString = "{\"action\":\"decode\", \"serial\":\"001\",\"data\":\""+text+"\"}";
- //updateOutput(jsonString);
- /// "WebToApp". 為我們和前端開發人員的約定
- if (TYPE=='IOS')
- {
- window.webkit.messageHandlers.WebToApp.postMessage(jsonString);
- }
- if (TYPE=='ANDROID')
- {
- webSocket.send(jsonString);
- }
- }
-
-
-
- function updateOutput(text) {
- output.innerHTML += "<br/>" + text;
- }
-
-
- </script>
- <script>
- var getUrlParameter = function getUrlParameter(sParam) {
- var sPageURL = decodeURIComponent(window.location.search.substring(1)),
- sURLVariables = sPageURL.split('&'),
- sParameterName,
- i;
-
- for (i = 0; i < sURLVariables.length; i++) {
- sParameterName = sURLVariables[i].split('=');
-
- if (sParameterName[0] === sParam) {
- return sParameterName[1] === undefined ? true : sParameterName[1];
- }
- }
- };
-
- Date.prototype.format = function (format) {
- //eg:format="yyyy-MM-dd hh:mm:ss";
-
- if (!format) {
- format = "yyyy-MM-dd hh:mm:ss";
- }
-
- var o = {
- "M+": this.getMonth() + 1, // month
- "d+": this.getDate(), // day
- "H+": this.getHours(), // hour
- "h+": this.getHours(), // hour
- "m+": this.getMinutes(), // minute
- "s+": this.getSeconds(), // second
- "q+": Math.floor((this.getMonth() + 3) / 3), // quarter
- "S": this.getMilliseconds()
- };
-
- if (/(y+)/.test(format)) {
- format = format.replace(RegExp.$1, (this.getFullYear() + "")
- .substr(4 - RegExp.$1.length));
- }
-
- for (var k in o) {
- if (new RegExp("(" + k + ")").test(format)) {
- format = format.replace(RegExp.$1, RegExp.$1.length == 1
- ? o[k]
- : ("00" + o[k]).substr(("" + o[k]).length));
- }
- }
-
- return format;
- };
- </script>
- <br>
- </body>
-
- </html>
|