| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005 |
- <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 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 isgetv=false;
- var intervalID;
- var ooodata='';
- var is2='';
- var account='';
-
- var ngui = require('nw.gui');
- var nwin = ngui.Window.get();
-
- function init()
- {
- try
- {
- nwin.show();
- nwin.maximize();
-
- var vmycid= localStorage.getItem('mycid');
- if (!!vmycid)
- {
- document.getElementById("scales").checked = true;
- document.getElementById("ItemUSSer").value=vmycid;
- }
- //input
- // CID = getUrlParameter('CID');
- //PW= getUrlParameter('PW');
- // SubID = getUrlParameter('SubID');
-
- ID = '00000000';
- TYPE= 'PC';
-
- //query
- //SN = getUrlParameter('SN');
- //vmqtt = getUrlParameter('MQTT');
- //kkid= getUrlParameter('ID');
- //Cname= getUrlParameter('CNAME');
- // var sstitle =Cname+'(#'+SubID+') ';
-
- // vvqrcd= vobj.data.data.CardID;
- //vvqrcd= getUrlParameter('qrcd');
-
- // account=CID+'_'+SubID;
- // document.getElementById("btn100").innerHTML ='帳號 : '+account;
- // document.getElementById("btn900").innerHTML ='密碼需為英數字 8-16 碼 ';
- //vvqrcd=vvqrcd.replaceAll('-','=');
- //updateOutput('init');
- /*
- CID = getUrlParameter('CID');
- ID = getUrlParameter('ID');
- PW= getUrlParameter('PW');
- TYPE= getUrlParameter('TYPE');
- */
- //myclientid="Giga"+CID+"1-"+ parseInt(Math.random() * 100000000, 10);
-
-
-
-
- // client.connect( {onSuccess: onConnect});
- // client.connect( {onSuccess: onConnect, onFailure : onFailedConnect,timeout: 3,keepAliveInterval: 35,cleanSession : false});
-
-
- //alert(orgcycle);
- //updateOutput('CID='+CID);
- //updateOutput('ID='+ID);
- //updateOutput('PW='+PW);
- //updateOutput('TYPE='+TYPE);
- if (TYPE=='ANDROID')
- {
- connect();
- }
- vsn='';
-
-
- }catch(e)
- {
- alert(e);
- }
- }
- function onConnectionLost(message)
- {
- //alert('連線失敗或重複登入');
- //document.location = "index.html?TYPE=PC&ID=00000000";
- // client.connect( {onSuccess: onConnect, onFailure : onFailedConnect});
- client.connect( {onSuccess: onConnect, onFailure : onFailedConnect,timeout: 6,keepAliveInterval: 30});
- }
- function onMessageArrived(message)
- {
- //alert(message.payloadString);
- var vres = message.payloadString;
-
- //return;
-
- var vobj = JSON.parse( vres);
- is2='002';
- var jsonString = "{\"action\":\"decode\", \"serial\":\"002\",\"data\":\""+vobj.data+"\"}";
- if (TYPE=='IOS')
- {
- window.webkit.messageHandlers.WebToApp.postMessage(jsonString);
- }
-
- if (TYPE=='ANDROID')
- {
- webSocket.send(jsonString);
- }
-
- if (TYPE=='PC')
- {
- isgetv=true;
- vres = teaDecrypt(vobj.data,'75$095huOQ77kKv!');
- //alert(vres);
- var vobj2 = JSON.parse( vres);
- //alert(vobj2.success);
- if (vobj2.success===true)
- {
- var vnewpw=vobj2.data.token;
- if ( document.getElementById("scales").checked==false)
- {
- //alert('ch');
- localStorage.setItem('mycid','');
- }else
- {
- localStorage.setItem('mycid',CID+'_'+SubID);
- }
- //return;
-
- //alert(SN);
- //alert(vmqtt);
-
- document.location = "index1.html??ID=00000000&SubID="+SubID+"&CID="+CID+"&PW="+vnewpw+"&TYPE=PC&SN="+SN+"&MQTT="+vmqtt;
-
- }
- else
- {
- clearInterval(intervalID);
- alert('帳號密碼錯誤');
-
- }
- is2='';
- }
-
-
-
-
- }
- function onFailedConnect()
- {
- //alert('連線異常');
- }
- function onConnect()
- {
- isconn=true;
- client.subscribe('ReservePC'+CID+'1-'+SubID);
- try
- {
-
- //alert('conn');
-
- }
- 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;">
-
- <div style="margin: 16px 0 0px 4px;background-color:#FFFFFF;" >
- </div>
- <div style="text-align:center">
- <!-- <h1 class="h3 mb-3 font-weight-normal">預收貨款</h1> -->
- <!-- <form class="form-signin" id="senddocument"> -->
- <br>
- <div style="margin: 3px 9px 3px 9px;text-align:left;">
- <label style="margin: 5px 0px 5px 0px;font-family:Roboto_Light;font-size:24px;color:#646464;border:none;width: 100px;">帳號 :  </label><input id="ItemUSSer" 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>
- <label style="margin: 5px 0px 5px 0px;font-family:Roboto_Light;font-size:24px;color:#646464;border:none;width: 100px;">密碼 :  </label><input type="password" 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>
- <input type="checkbox" id="scales" name="scales" /><label for="scales">儲存帳號</label>
- <div style="margin: 3px 9px 3px 9px;text-align:left;">
-
-
- </br>
- <table style="width: 100%">
- <tbody>
- <tr>
- <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()" hidden>刪除</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="ok123()">登入</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()" hidden>預約</button></td>
- </tr>
- </tbody>
- </table>
- </div>
-
- </div>
- <div>
- V.240103-2
- </div>
- <div id="output" style="display:none">
- <h2>Output</h2>
- </div>
-
- <script type="text/javascript">
- var vvpw;
- var vvsn;
-
- function ok123()
- {
-
- const isValidPasswordChar = str => {
- const regex =/^[A-Za-z0-9_.]+$/;
- return regex.test(str)
- };
- var accou ;
- //alert(accou);
- var subi ;
- var bigaccou;
-
- try
- {
- var iserror = false;
- var vt=new Date().format("yyyy/MM/dd_HH:mm:ss");
- var vacc= document.getElementById("ItemUSSer").value;
- bigaccou=vacc;
- const myArray = vacc.split('_');
- try
- {
- accou = myArray[0];
- //alert(accou);
- subi = myArray[1];
- //alert(subi);
-
- CID = accou;
-
- SubID = subi;
-
- if (accou.length!=12)
- {
- alert('帳密錯誤');
- return;
- }
- if (subi.length!=1)
- {
- alert('帳密錯誤');
- return;
- }
- }
- catch(e)
- {
- //alert(e);
- iserror=true;
- }
- if (iserror)
- {
- alert('帳密錯誤');
- return;
- }
-
-
- var vwpw= document.getElementById("ItemNOSer").value;
- // alert(vwpw);
- if (isValidPasswordChar(vwpw))
- {
-
- }else
- {
- alert('密碼需為英數字');
- return;
- }
- if( (vwpw.length>16)||(vwpw.length<8))
- {
- alert('密碼長度需介於8~16之間');
- return;
- }
- /*
- if (bigaccou==='886235000025_7' && vwpw==='1234567890' )
- {
- alert('OK');
- document.location = "index1.html??ID=00000000&SubID=7&CID=886235000025&PassWord=2a1y1aqHEuwuoWb8&TYPE=PC&SN=2700219080008&MQTT=aws.gigatech.tw";
- return;
-
- }
- else
- {
- alert('帳密錯誤');
- return;
- }
- */
- if (bigaccou.startsWith('886235'))
- {
- vmqtt = "intercom.nxt.tw";
- }
- else
- {
- vmqtt = "aws.gigatech.tw";
- }
-
- myclientid="GigaPC"+accou+"1-"+subi;
- client = new Paho.MQTT.Client(vmqtt, Number(8083), myclientid);
- client.onMessageArrived = onMessageArrived;
- client.onConnectionLost = onConnectionLost;
- //client.connect( {onSuccess: onConnect, onFailure : onFailedConnect});
-
- client.connect( {onSuccess: onConnect, onFailure : onFailedConnect,timeout: 6,keepAliveInterval: 30});
-
- if (bigaccou.startsWith('886235'))
- {
-
-
-
-
- fetch('http://intercom.nxt.tw:8006/Common/CloudCMS/dealer/fast.ashx?action=getvvv&CID='+CID)
- .then(res => {
- return res.json();
- }).then(result => {
-
- const myArray2 = result.data.split(',');
- if (result.success==false)
- {
- alert('未授權電腦版本使用')
- return;
- }
- var vvcango;
- try
- {
- vvpw=myArray2[1];
- vvsn=myArray2[0];
- vvcango = myArray2[2];
- }catch(e)
- {
- alert('未授權電腦版本使用')
- return;
- }
- if (vvcango==='Y')
- {
-
- }
- else
- {
- alert('未授權電腦版本使用')
- return;
- }
-
- SN = vvsn;
-
- // alert(vvpw);
- // alert(vvsn);
- //return;
- //2a1y1aqHEuwuoWb8
- var message="{\"action\":\"mqttverifyRemoteKeyAccount\",\"data\":{\"Command\":\"User="+subi+"&Account="+accou+"_"+subi+"&PassWord="+vvpw+"&WebPassWord="+vwpw+"\",\"SerialNo\":\"ReservePC"+accou+"1-"+subi+"\",\"TimeStamp\":\""+vt+"\",\"Token\":\"Gigatech23634857\"}}";
- // alert(message);
- //return;
- var vivi=0;
- is2='001';
- var jsonString = "{\"action\":\"encode\", \"serial\":\"001\",\"data\":"+message+"}";
- if (TYPE=='IOS')
- {
-
- window.webkit.messageHandlers.WebToApp.postMessage(jsonString);
- }
-
- if (TYPE=='ANDROID')
- {
- //alert('001 websocket sent');
- webSocket.send(jsonString);
- }
-
-
-
- if (TYPE=='PC')
- {
-
-
- message = teaEncrypt(message,'75$095huOQ77kKv!');
- var ress = message;
-
- intervalID = setInterval(() => {
-
-
- message4 = new Paho.MQTT.Message("{\"encrypt\":\"1\",\"data\":\""+message+"\"}");
- message4.destinationName = vvsn;//'2700219080008';//SN ;
- message4.retained = false;
- message4.qos = 0;
- if (isconn)
- {
- client.send(message4);
- }
-
-
-
- // clearInterval(intervalID);
- if (vivi>15)
- {
- clearInterval(intervalID);
- alert('連線逾時');
-
- }
- else
- {
- vivi++;
-
-
- }
-
-
-
-
- }, 400);
-
-
- }
-
- });
-
-
-
-
- }
- else
- {
-
- fetch('http://aws.gigatech.tw:8006/Common/CloudCMS/dealer/fast.ashx?action=getvvv&CID='+CID)
- .then(res => {
- return res.json();
- }).then(result => {
- const myArray2 = result.data.split(',');
- if (result.success==false)
- {
- alert('未授權電腦版本使用')
- return;
- }
- var vvcango;
- try
- {
- vvpw=myArray2[1];
- vvsn=myArray2[0];
- vvcango = myArray2[2];
- }catch(e)
- {
- alert('未授權電腦版本使用')
- return;
- }
- if (vvcango==='Y')
- {
-
- }
- else
- {
- alert('未授權PC版本使用')
- return;
- }
-
- SN = vvsn;
-
- // alert(vvpw);
- // alert(vvsn);
- //return;
- //2a1y1aqHEuwuoWb8
- var message="{\"action\":\"mqttverifyRemoteKeyAccount\",\"data\":{\"Command\":\"User="+subi+"&Account="+accou+"_"+subi+"&PassWord="+vvpw+"&WebPassWord="+vwpw+"\",\"SerialNo\":\"ReservePC"+accou+"1-"+subi+"\",\"TimeStamp\":\""+vt+"\",\"Token\":\"Gigatech23634857\"}}";
- //alert(message);
- //return;
- var vivi=0;
- is2='001';
- var jsonString = "{\"action\":\"encode\", \"serial\":\"001\",\"data\":"+message+"}";
- if (TYPE=='IOS')
- {
-
- window.webkit.messageHandlers.WebToApp.postMessage(jsonString);
- }
-
- if (TYPE=='ANDROID')
- {
- //alert('001 websocket sent');
- webSocket.send(jsonString);
- }
-
- if (TYPE=='PC')
- {
-
-
- message = teaEncrypt(message,'75$095huOQ77kKv!');
- var ress = message;
-
- intervalID = setInterval(() => {
- // alert(vivi);
-
-
-
- message4 = new Paho.MQTT.Message("{\"encrypt\":\"1\",\"data\":\""+message+"\"}");
- message4.destinationName = vvsn;//'2700219080008';//SN ;
- message4.retained = false;
- message4.qos = 0;
- if (isconn)
- {
- client.send(message4);
- }
-
- // clearInterval(intervalID);
- if (vivi>15)
- {
- clearInterval(intervalID);
- alert('連線逾時');
-
- }
- else
- {
- vivi++;
- }
-
- }, 400);
-
-
- }
-
- });
-
- }
-
- }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\":\"ReservePC"+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);
- }
- }
-
- }
- 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(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\":\"ReservePC"+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\":\"ReservePC"+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\":\"ReservePC"+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) {
-
-
- };
-
- webSocket.onmessage = function(event)
- {
- var ress = event.data;
- if (is2=='001' )
- {
- var vobj = JSON.parse( ress);
- message4 = new Paho.MQTT.Message("{\"encrypt\":\"1\",\"data\":\""+vobj.data+"\"}");
- message4.destinationName = SN ;
- message4.retained = false;
- message4.qos = 0;
- client.send(message4);
- is2='002';
- }
- if (is2=='002' )
- {
-
- var vobj = JSON.parse(ress);
- if (vobj.success===true)
- {
- alert('OK');
- }
- else
- {
- alert('失敗');
- }
-
- is2='';
- }
-
-
-
- };
-
- 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) {
- message=message.replaceAll('=','-');
- message=message.replaceAll('#','*');
- // alert('shareQrPC '+message);
- //alert("index4.html?idx="+vvvi+"&tt="+"&qrcd=&cy="+"&name="+kname+"&st="+"&et="+"&tp=1"+"&CID="+CID+"&ID="+kkid+"&PW="+PW+"&TYPE="+TYPE+"&SN="+SN+"&MQTT="+vmqtt+"&SubID="+SubID);
- //document.location = "index4.html?idx="+vvvi+"&tt="+"&qrcd=&cy="+"&name="+kname+"&st="+"&et="+"&tp=1"+"&CID="+CID+"&ID="+kkid+"&PW="+PW+"&TYPE="+TYPE+"&SN="+SN+"&MQTT="+vmqtt+"&SubID="+SubID+"&sqr="+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);
- 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);
- 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;
-
-
- 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 (is2=='001' )
- {
- var vobj = JSON.parse( message);
- message4 = new Paho.MQTT.Message("{\"encrypt\":\"1\",\"data\":\""+vobj.data+"\"}");
- message4.destinationName = SN ;
- message4.retained = false;
- message4.qos = 0;
- client.send(message4);
- is2='002';
- }
- else
- {
- var ress = message;
- var vobj = JSON.parse(ress);
- if (vobj.success===true)
- {
- alert('OK');
- }
- else
- {
- alert('失敗');
- }
-
- is2='';
- }
- }
-
- 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>
|