set_backend.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. <?php
  2. ini_set('error_reporting', E_ALL | E_STRICT);
  3. $tag_header = 'set';
  4. include 'head.php';
  5. $obj = json_decode(trim($output[3]));//var_dump($obj);
  6. $system = json_decode(trim($output[0]));
  7. $ModelName = $system->{'ModelName'};
  8. $OcppConnStatus='';
  9. switch ($obj->{'OcppConnStatus'}){
  10. case 0:
  11. $OcppConnStatus='disconnected';
  12. break;
  13. case 1:
  14. $OcppConnStatus='connected';
  15. break;
  16. }
  17. ?>
  18. <style>
  19. img {
  20. display: block;
  21. margin-left: auto;
  22. margin-right: auto;
  23. }
  24. <?php if(substr($ModelName,0,1)=="D" && substr($ModelName,3,1)=="C"){?>
  25. /* Colors: Default (blue) */
  26. .toggle-switchy {color:#fff;}
  27. .toggle-switchy > input + .toggle:before {content:'Yes';}
  28. .toggle-switchy > input + .toggle:after {content:'No';}
  29. .toggle-switchy > input + .toggle > .switch {background:#fff;}
  30. .toggle-switchy > input + .toggle + .label {color:#000;}
  31. .toggle-switchy > input:checked + .toggle {background:#3498db;}
  32. .toggle-switchy > input:not(:checked) + .toggle {background:#ccc;}
  33. .toggle-switchy > input:checked + .toggle > .switch {border:3px solid #3498db;}
  34. .toggle-switchy > input:not(:checked) + .toggle > .switch {border:3px solid #ccc;}
  35. .toggle-switchy > input:focus + .toggle,
  36. .toggle-switchy > input:active + .toggle {box-shadow:0 0 5px 3px rgba(0, 119, 200, 0.50);}
  37. /* Rounded switch corners */
  38. .toggle-switchy > input + .toggle {border-radius:4px;}
  39. .toggle-switchy > input + .toggle .switch {border-radius:6px;}
  40. /* //////////////////////////
  41. CORE STYLES BELOW - NO TOUCHY
  42. ////////////////////////// */
  43. .toggle-switchy {display:inline-flex; align-items:center; user-select:none; position:relative;}
  44. .toggle-switchy:hover {cursor:pointer;}
  45. .toggle-switchy > input {position:absolute; opacity:0;}
  46. .toggle-switchy > input + .toggle {align-items:center; position:relative;}
  47. .toggle-switchy > input + .toggle {overflow:hidden; position:relative; flex-shrink:0;}
  48. .toggle-switchy > input[disabled] + .toggle {opacity:0.5;}
  49. .toggle-switchy > input[disabled] + .toggle:hover {cursor:not-allowed;}
  50. .toggle-switchy > input + .toggle {width:100%; height:100%; margin:0; cursor:pointer;}
  51. .toggle-switchy > input + .toggle > .switch {display:block; height:100%; position:absolute; right:0; z-index:3;}
  52. /* Labels */
  53. .toggle-switchy > input + .toggle:before,
  54. .toggle-switchy > input + .toggle:after {display:flex; align-items:center; position:absolute; z-index:2; height:100%;}
  55. .toggle-switchy > input + .toggle:before {right:55%;}
  56. .toggle-switchy > input + .toggle:after {left:50%;}
  57. .toggle-switchy > input + .toggle + .label {margin-left:10px;}
  58. .toggle-switchy[data-label='left'] > input + .toggle {order:2;}
  59. .toggle-switchy[data-label='left'] > input + .toggle + .label {order:1; margin-left:0; margin-right:10px;}
  60. /* Show / Hide */
  61. .toggle-switchy > input + .toggle:before {opacity:0;}
  62. .toggle-switchy > input:checked + .toggle:before {opacity:1;}
  63. .toggle-switchy > input:checked + .toggle:after {opacity:0;}
  64. /* Transitions */
  65. .toggle-switchy > input + .toggle {transition:background 200ms linear, box-shadow 200ms linear;}
  66. .toggle-switchy > input + .toggle:before,
  67. .toggle-switchy > input + .toggle:after {transition:all 200ms linear;}
  68. .toggle-switchy > input + .toggle > .switch {transition:right 200ms linear, border-color 200ms linear;}
  69. /* //////////////////////////
  70. CORE STYLES ABOVE - NO TOUCHY
  71. ////////////////////////// */
  72. /* Size: Extra Large */
  73. .toggle-switchy[data-size='xl'] > input + .toggle {width:85px; height:40px;}
  74. .toggle-switchy[data-size='xl'] > input + .toggle > .switch {width:40px;}
  75. .toggle-switchy[data-size='xl'] > input + .toggle:before,
  76. .toggle-switchy[data-size='xl'] > input + .toggle:after {font-size:1.2rem;}
  77. .toggle-switchy[data-size='xl'] > input:not(:checked) + .toggle > .switch {right:calc(100% - 40px);}
  78. /* Size: Large */
  79. .toggle-switchy[data-size='lg'] > input + .toggle {width:75px; height:35px;}
  80. .toggle-switchy[data-size='lg'] > input + .toggle > .switch {width:35px;}
  81. .toggle-switchy[data-size='lg'] > input + .toggle:before,
  82. .toggle-switchy[data-size='lg'] > input + .toggle:after {font-size:1rem;}
  83. .toggle-switchy[data-size='lg'] > input:not(:checked) + .toggle > .switch {right:calc(100% - 35px);}
  84. /* Size: Default (Medium) */
  85. .toggle-switchy > input + .toggle {width:100px; height:30px;}
  86. .toggle-switchy > input + .toggle > .switch {width:30px;}
  87. .toggle-switchy > input + .toggle:before,
  88. .toggle-switchy > input + .toggle:after {font-size:0.8rem;}
  89. .toggle-switchy > input:not(:checked) + .toggle > .switch {right:calc(100% - 30px);}
  90. /* Size: Small */
  91. .toggle-switchy[data-size='sm'] > input + .toggle {width:55px; height:25px;}
  92. .toggle-switchy[data-size='sm'] > input + .toggle > .switch {width:25px;}
  93. .toggle-switchy[data-size='sm'] > input + .toggle:before,
  94. .toggle-switchy[data-size='sm'] > input + .toggle:after {font-size:0.7rem;}
  95. .toggle-switchy[data-size='sm'] > input:not(:checked) + .toggle > .switch {right:calc(100% - 25px);}
  96. /* Size: Extra Small */
  97. .toggle-switchy[data-size='xs'] > input + .toggle {width:45px; height:20px;}
  98. .toggle-switchy[data-size='xs'] > input + .toggle > .switch {width:20px;}
  99. .toggle-switchy[data-size='xs'] > input + .toggle:before,
  100. .toggle-switchy[data-size='xs'] > input + .toggle:after {font-size:0.5rem;}
  101. .toggle-switchy[data-size='xs'] > input:not(:checked) + .toggle > .switch {right:calc(100% - 20px);}
  102. /* Style: Rounded */
  103. .toggle-switchy[data-style='rounded'] > input + .toggle,
  104. .toggle-switchy[data-style='rounded'] > input + .toggle > .switch {border-radius:50px;}
  105. .toggle-switchy[data-style='rounded'] > input + .toggle:before {right:30%;}
  106. .toggle-switchy[data-style='rounded'] > input + .toggle:after {left:40%;}
  107. /* Style: Square */
  108. .toggle-switchy[data-style='square'] > input + .toggle {border-radius:0;}
  109. .toggle-switchy[data-style='square'] > input + .toggle .switch {border-radius:0;}
  110. /* Text: Off */
  111. .toggle-switchy[data-text='false'] > input + .toggle:before,
  112. .toggle-switchy[data-text='false'] > input + .toggle:after {content:'';}
  113. .toggle-switchy[data-text='false'][data-size='xl'] > input + .toggle {width:80px;}
  114. .toggle-switchy[data-text='false'][data-size='lg'] > input + .toggle {width:70px;}
  115. .toggle-switchy[data-text='false'] > input + .toggle {width:60px;}
  116. .toggle-switchy[data-text='false'][data-size='sm'] > input + .toggle {width:50px;}
  117. .toggle-switchy[data-text='false'][data-size='xs'] > input + .toggle {width:40px;}
  118. /* Color: Red */
  119. .toggle-switchy[data-color='red'] > input:checked + .toggle {background:#e74c3c;}
  120. .toggle-switchy[data-color='red'] > input:checked + .toggle > .switch {border-color:#e74c3c;}
  121. /* Color: Orange */
  122. .toggle-switchy[data-color='orange'] > input:checked + .toggle {background:#e67e22;}
  123. .toggle-switchy[data-color='orange'] > input:checked + .toggle > .switch {border-color:#e67e22;}
  124. /* Color: Yellow */
  125. .toggle-switchy[data-color='yellow'] > input:checked + .toggle {background:#f1c40f;}
  126. .toggle-switchy[data-color='yellow'] > input:checked + .toggle > .switch {border-color:#f1c40f;}
  127. /* Color: Green */
  128. .toggle-switchy[data-color='green'] > input:checked + .toggle {background:#2ecc71;}
  129. .toggle-switchy[data-color='green'] > input:checked + .toggle > .switch {border-color:#2ecc71;}
  130. /* Color: Blue */
  131. .toggle-switchy[data-color='blue'] > input:checked + .toggle {background:#3498db;}
  132. .toggle-switchy[data-color='blue'] > input:checked + .toggle > .switch {border-color:#3498db;}
  133. /* Color: Purple */
  134. .toggle-switchy[data-color='purple'] > input:checked + .toggle {background:#9b59b6;}
  135. .toggle-switchy[data-color='purple'] > input:checked + .toggle > .switch {border-color:#9b59b6;}
  136. /* Color: Gray */
  137. .toggle-switchy[data-color='gray'] > input:checked + .toggle {background:#555;}
  138. .toggle-switchy[data-color='gray'] > input:checked + .toggle > .switch {border-color:#555;}
  139. <?php } ?>
  140. </style>
  141. <div class="envor-content">
  142. <!--
  143. Page Title start
  144. //-->
  145. <section class="envor-page-title-1" data-stellar-background-ratio="0.5">
  146. <div class="container">
  147. <div class="row">
  148. <div class="col-lg-9 col-md-9 col-sm-9">
  149. <h1><?php echo $lang->showWord("backend"); ?></h1>
  150. </div>
  151. </div>
  152. </div>
  153. <!--
  154. Page Title end
  155. //-->
  156. </section>
  157. <!--
  158. Main Content start
  159. //-->
  160. <a id="loadinghref"><div id="loading" style="display:none;"><img src="img/giphy.gif"/></div></a>
  161. <section class="envor-section">
  162. <div class="container">
  163. <div class="row">
  164. <div class="col-lg-12">
  165. <div class="envor-sorting" id="faq-sorting">
  166. <div class="envor-toggle">
  167. <!--Common Information-->
  168. <article class="envor-sorting-item css">
  169. <header><?php echo $lang->showWord("common_information"); ?><i class="fa fa-plus"></i></header>
  170. <section>
  171. <div class="form-group" style="display:<?php echo $am101;?>">
  172. <label>Backend Connection Timeout</label>
  173. <input type="text" name="BackendConnTimeout" id="BackendConnTimeout" class="form-control" value="<?php echo $obj->{'BackendConnTimeout'};?>">
  174. <small class="form-text text-muted-red">seconds</small>
  175. </div>
  176. <div class="form-group" style="display:<?php echo $am101;?>">
  177. <label>Offline Policy</label>
  178. <select class="form-control" id="OfflinePolicy" name="OfflinePolicy">
  179. <option value="0" <?php echo $obj->{'OfflinePolicy'}=="0"?"selected":""?>>local list</option>
  180. <?php /* <option value="1" <?php echo $obj->{'OfflinePolicy'}=="1"?"selected":""?>>Phihong RFID tag</option>*/?>
  181. <option value="2" <?php echo $obj->{'OfflinePolicy'}=="2"?"selected":""?>>free charging</option>
  182. <option value="3" <?php echo $obj->{'OfflinePolicy'}=="3"?"selected":""?>>no charging</option>
  183. </select>
  184. </div>
  185. <div class="form-group" style="display:<?php echo $am101;?>">
  186. <label>Offline Max Charge Energy</label>
  187. <small class="form-text text-muted-red">kWh</small>
  188. <input type="text" name="OfflineMaxChargeEnergy" id="OfflineMaxChargeEnergy" class="form-control" value="<?php echo $obj->{'OfflineMaxChargeEnergy'};?>">
  189. </div>
  190. <div class="form-group" style="display:<?php echo $am101;?>">
  191. <label>Offline Max Charge Duration</label>
  192. <small class="form-text text-muted-red">minutes</small>
  193. <input type="text" name="OfflineMaxChargeDuration" id="OfflineMaxChargeDuration" class="form-control" value="<?php echo $obj->{'OfflineMaxChargeDuration'};?>">
  194. </div>
  195. </section>
  196. </article>
  197. <!--OCPP Backend-->
  198. <article class="envor-sorting-item css">
  199. <header><?php echo $lang->showWord("OCPP_backend"); ?><i class="fa fa-plus"></i></header>
  200. <section>
  201. <div class="form-group" style="display:<?php echo $am101;?>">
  202. <label>Ocpp Connection Status</label>
  203. <input type="text" readonly class="form-control" placeholder="<?php echo $OcppConnStatus;?>">
  204. <input type="hidden" name="OcppConnStatus" id="OcppConnStatus" value="<?php echo $obj->{'OcppConnStatus'};?>">
  205. </div>
  206. <div class="form-group" style="display:<?php echo $am101;?>">
  207. <label>Central System URL</label>
  208. <input type="text" name="OcppServerURL" id="OcppServerURL" class="form-control" value="<?php echo $obj->{'OcppServerURL'};?>">
  209. </div>
  210. <div class="form-group" style="display:<?php echo $am101;?>">
  211. <label>Charge Box Id</label>
  212. <input type="text" name="ChargeBoxId" id="ChargeBoxId" class="form-control" value="<?php echo $obj->{'ChargeBoxId'};?>">
  213. </div>
  214. <div class="form-group" style="display:<?php echo $am101;?>">
  215. <label>Charge Point Vendor</label>
  216. <input type="text" name="chargePointVendor" id="chargePointVendor" class="form-control" value="<?php echo $obj->{'chargePointVendor'};?>">
  217. </div>
  218. <div class="form-group" style="display:<?php echo $am101;?>">
  219. <label>Ocpp Security Profile</label>
  220. <select class="form-control" id="OcppSecurityProfile" name="OcppSecurityProfile" onchange="OcppSecurityProfile_changed()">
  221. <option value="0" <?php echo $obj->{'OcppSecurityProfile'}=="0"?"selected":""?>>None security</option>
  222. <option value="1" <?php echo $obj->{'OcppSecurityProfile'}=="1"?"selected":""?>>Unsecured Transport with Basic Atuentication</option>
  223. <option value="2" <?php echo $obj->{'OcppSecurityProfile'}=="2"?"selected":""?>>TLS with Basic Authentication</option>
  224. <option value="3" <?php echo $obj->{'OcppSecurityProfile'}=="3"?"selected":""?>>TLS with Client Side Certificates</option>
  225. </select>
  226. </div>
  227. <div id="OcppSecurityPasswordDiv" class="form-group" style="display:<?php echo $am101;?>">
  228. <label>Ocpp Security Password</label>
  229. <input type="text" name="OcppSecurityPassword" id="OcppSecurityPassword" class="form-control" value="<?php echo $obj->{'OcppSecurityPassword'};?>">
  230. </div>
  231. <?php if(substr($ModelName,0,2)=="AX"){?>
  232. <div class="form-group" style="display:block">
  233. <label>Local Loading Balance</label>
  234. <select class="form-control" id="isEnableLocalPowerSharging" name="isEnableLocalPowerSharging" onChange="isEnableLocalPowerSharging_changed()">
  235. <option value="0" <?php echo $obj->{'isEnableLocalPowerSharging'}=="0"?"selected":""?>>disable</option>
  236. <option value="1" <?php echo $obj->{'isEnableLocalPowerSharging'}=="1"?"selected":""?>>enable</option>
  237. </select>
  238. </div>
  239. <?php } ?>
  240. </section>
  241. </article>
  242. <?php if(substr($ModelName,0,1)=="D" && substr($ModelName,3,1)=="C"){ ?>
  243. <!--TTIA-->
  244. <article class="envor-sorting-item css">
  245. <header>TTIA<i class="fa fa-plus"></i></header>
  246. <section>
  247. <div class="form-group" style="display:<?php echo $am101;?>">
  248. <label>TTIA</label>
  249. <label class="toggle-switchy" for="isEnableTTIA" data-size="" data-style="rounded">
  250. <input type="checkbox" id="isEnableTTIA" <?php echo $obj->{'isEnableTTIA'}==1?"checked":"";?> onclick="isEnableTTIAChecked()">
  251. <span class="toggle">
  252. <span class="switch"></span>
  253. </span>
  254. </label>
  255. </div>
  256. <div id="server_addrDiv" class="form-group">
  257. <label>Server Address</label>
  258. <input type="text" name="server_addr" id="server_addr" class="form-control" value="<?php echo $obj->{'server_addr'};?>">
  259. </div>
  260. <div id="server_portDiv" class="form-group">
  261. <label>Server Port</label>
  262. <input type="text" name="server_port" id="server_port" class="form-control" value="<?php echo $obj->{'server_port'};?>">
  263. </div>
  264. <div id="busVenderIdDiv" class="form-group">
  265. <label>Bus Vender Id</label>
  266. <input type="text" name="busVenderId" id="busVenderId" class="form-control" value="<?php echo $obj->{'busVenderId'};?>">
  267. </div>
  268. <div id="EquipmentProviderDiv" class="form-group">
  269. <label>Equipment Provider</label>
  270. <input type="text" name="EquipmentProvider" id="EquipmentProvider" class="form-control" value="<?php echo $obj->{'EquipmentProvider'};?>">
  271. </div>
  272. <div id="TransportationCompanyNoDiv" class="form-group">
  273. <label>TransportationCompanyNo</label>
  274. <input type="text" name="TransportationCompanyNo" id="TransportationCompanyNo" class="form-control" value="<?php echo $obj->{'TransportationCompanyNo'};?>">
  275. </div>
  276. <div id="ChargeBoxIdDiv" class="form-group">
  277. <label>Charge Box Id</label>
  278. <input type="text" name="TTIAChargeBoxId" id="TTIAChargeBoxId" class="form-control" value="<?php echo $obj->{'TTIAChargeBoxId'};?>">
  279. </div>
  280. <div id="evseStationDiv" class="form-group">
  281. <label>EVSE Station</label>
  282. <input type="text" name="evseStation" id="evseStation" class="form-control" value="<?php echo $obj->{'evseStation'};?>">
  283. </div>
  284. </section>
  285. </article>
  286. <?php } ?>
  287. <article class="envor-sorting-item css">
  288. <div align="center"><button id="save"><?php echo $lang->showWord("set")?></button></div>
  289. </article>
  290. </div>
  291. </div>
  292. </div>
  293. </div>
  294. </div>
  295. </section>
  296. </div>
  297. <?php
  298. include 'foot.php';
  299. ?>
  300. <script type="text/JavaScript">
  301. <?php if(substr($ModelName,0,2)=="AX"){?>
  302. $(document).ready(function(){
  303. isEnableLocalPowerSharging_changed();
  304. });
  305. <?php } ?>
  306. <?php if(substr($ModelName,0,1)=="D" && substr($ModelName,3,1)=="C"){?>
  307. $(document).ready(function(){
  308. isEnableTTIAChecked();
  309. });
  310. <?php } ?>
  311. OcppSecurityProfile_changed();
  312. document.getElementById("save").onclick = function() {
  313. if(formCheck())
  314. {
  315. window.location="#loadinghref";
  316. document.getElementById("loading").style.display="block";
  317. // 發送 Ajax 查詢請求並處理
  318. var request = new XMLHttpRequest();
  319. request.open("POST", "set_backend_action.php");
  320. // POST 參數須使用 send() 發送
  321. var data = "BackendConnTimeout=" + document.getElementById("BackendConnTimeout").value +
  322. "&OfflinePolicy=" + document.getElementById("OfflinePolicy").value +
  323. "&OfflineMaxChargeEnergy=" + document.getElementById("OfflineMaxChargeEnergy").value+
  324. "&OfflineMaxChargeDuration=" + document.getElementById("OfflineMaxChargeDuration").value+
  325. // "&OcppConnStatus=" + document.getElementById("OcppConnStatus").value+
  326. "&OcppServerURL=" + escape(document.getElementById("OcppServerURL").value)+
  327. "&ChargeBoxId=" + escape(document.getElementById("ChargeBoxId").value)+
  328. "&chargePointVendor=" + escape(document.getElementById("chargePointVendor").value)+
  329. "&OcppSecurityProfile=" + document.getElementById("OcppSecurityProfile").value+
  330. "&OcppSecurityPassword=" + escape(document.getElementById("OcppSecurityPassword").value);
  331. <?php if(substr($ModelName,0,2)=="AX"){?>
  332. data += "&isEnableLocalPowerSharging=" + document.getElementById("isEnableLocalPowerSharging").value;
  333. <?php } ?>
  334. <?php if(substr($ModelName,0,1)=="D" && substr($ModelName,3,1)=="C"){?>
  335. data += "&isEnableTTIA=" + (document.getElementById("isEnableTTIA").checked?"1":"0")+
  336. "&server_addr=" + document.getElementById("server_addr").value+
  337. "&server_port=" + document.getElementById("server_port").value+
  338. "&busVenderId=" + document.getElementById("busVenderId").value+
  339. "&EquipmentProvider=" + document.getElementById("EquipmentProvider").value+
  340. "&TransportationCompanyNo=" + document.getElementById("TransportationCompanyNo").value+
  341. "&TTIAChargeBoxId=" + document.getElementById("TTIAChargeBoxId").value+
  342. "&evseStation=" + document.getElementById("evseStation").value;
  343. <?php } ?>
  344. // POST 請求必須設置表頭在 open() 下面,send() 上面
  345. request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  346. request.send(data);
  347. request.onreadystatechange = function() {
  348. // 伺服器請求完成
  349. if (request.readyState == 4) {
  350. document.getElementById("loading").style.display="none";
  351. // 伺服器回應成功
  352. if (request.status == 200 && JSON.parse(request.responseText).result=="Success") {
  353. alert("<?php echo $lang->showWord("done")?>");
  354. location.href="set_backend.php";
  355. } else {
  356. alert(JSON.parse(request.responseText).message);
  357. }
  358. request = null;
  359. }
  360. }
  361. }
  362. }
  363. function formCheck()
  364. {
  365. var OcppServerURL = document.getElementById("OcppServerURL").value;
  366. var ChargeBoxId = document.getElementById("ChargeBoxId").value;
  367. var chargePointVendor = document.getElementById("chargePointVendor").value;
  368. var tests=/^(ws|wss):\/\/((([0-9]{1,3}\.){3}[0-9]{1,3})|(([a-zA-Z0-9]+(([\-]?[a-zA-Z0-9]+)*\.)+)*[a-zA-Z]{2,}))+/;
  369. if(OcppServerURL!=""){
  370. if(OcppServerURL.match(tests)==null){
  371. alert("OcppServerURL format error!");
  372. document.getElementById("OcppServerURL").focus();
  373. return false;
  374. }
  375. }
  376. if(ChargeBoxId!=""){
  377. if(ChargeBoxId.length>25){
  378. alert("Length of ChargeBoxId should be less than 25!");
  379. document.getElementById("ChargeBoxId").focus();
  380. return false;
  381. }
  382. }
  383. if(chargePointVendor!=""){
  384. if(chargePointVendor.length>20){
  385. alert("Length of chargePointVendor should be less than 20!");
  386. document.getElementById("chargePointVendor").focus();
  387. return false;
  388. }
  389. }
  390. <?php if(substr($ModelName,0,1)=="D" && substr($ModelName,3,1)=="C"){?>
  391. var server_port = document.getElementById("server_port").value;
  392. if(server_port!=""){
  393. if(server_port>65535){
  394. alert("Value of Server Port should be less than 65535!");
  395. document.getElementById("server_port").focus();
  396. return false;
  397. }
  398. }
  399. var busVenderId = document.getElementById("busVenderId").value;
  400. if(busVenderId!=""){
  401. if(busVenderId>65535){
  402. alert("Value of Bus Vender Id should be less than 65535!");
  403. document.getElementById("busVenderId").focus();
  404. return false;
  405. }
  406. }
  407. var EquipmentProvider = document.getElementById("EquipmentProvider").value;
  408. if(EquipmentProvider!=""){
  409. if(UTF8Length(EquipmentProvider)>15){
  410. alert("Length of Equipment Provider should be less than 15(Chinese 5 words)!");
  411. document.getElementById("EquipmentProvider").focus();
  412. return false;
  413. }
  414. }
  415. var evseStation = document.getElementById("evseStation").value;
  416. if(evseStation!=""){
  417. if(UTF8Length(evseStation)>15){
  418. alert("Length of EVSE Station should be less than 15(Chinese 5 words)!");
  419. document.getElementById("evseStation").focus();
  420. return false;
  421. }
  422. }
  423. var TransportationCompanyNo = document.getElementById("TransportationCompanyNo").value;
  424. if(TransportationCompanyNo!=""){
  425. if(TransportationCompanyNo>255){
  426. alert("Value of Transportation Company No should be less than 255!");
  427. document.getElementById("TransportationCompanyNo").focus();
  428. return false;
  429. }
  430. }
  431. var TTIAChargeBoxId = document.getElementById("TTIAChargeBoxId").value;
  432. if(TTIAChargeBoxId!=""){
  433. if(TTIAChargeBoxId>255){
  434. alert("Value of Charge Box Id should be less than 255!");
  435. document.getElementById("TTIAChargeBoxId").focus();
  436. return false;
  437. }
  438. }
  439. <?php } ?>
  440. return true;
  441. }
  442. function OcppSecurityProfile_changed(){
  443. if(document.getElementById("OcppSecurityProfile").value == "1" || document.getElementById("OcppSecurityProfile").value == "2"){
  444. document.getElementById("OcppSecurityPasswordDiv").style.display="block";
  445. }
  446. else{
  447. document.getElementById("OcppSecurityPasswordDiv").style.display="none";
  448. }
  449. }
  450. <?php if(substr($ModelName,0,2)=="AX"){?>
  451. function isEnableLocalPowerSharging_changed(){
  452. if(document.getElementById("isEnableLocalPowerSharging").selectedIndex==1){
  453. document.getElementById("OcppServerURL").setAttribute("readOnly","true");
  454. document.getElementById("ChargeBoxId").setAttribute("readOnly","true");
  455. document.getElementById("chargePointVendor").setAttribute("readOnly","true");
  456. }
  457. else{
  458. document.getElementById("OcppServerURL").removeAttribute("readOnly");
  459. document.getElementById("ChargeBoxId").removeAttribute("readOnly");
  460. document.getElementById("chargePointVendor").removeAttribute("readOnly");
  461. }
  462. }
  463. <?php } ?>
  464. <?php if(substr($ModelName,0,1)=="D" && substr($ModelName,3,1)=="C"){?>
  465. function isEnableTTIAChecked(){
  466. if(document.getElementById("isEnableTTIA").checked){
  467. document.getElementById("server_addrDiv").style.display="block";
  468. document.getElementById("server_portDiv").style.display="block";
  469. document.getElementById("busVenderIdDiv").style.display="block";
  470. document.getElementById("EquipmentProviderDiv").style.display="block";
  471. document.getElementById("TransportationCompanyNoDiv").style.display="block";
  472. document.getElementById("ChargeBoxIdDiv").style.display="block";
  473. document.getElementById("evseStationDiv").style.display="block";
  474. }
  475. else{
  476. document.getElementById("server_addrDiv").style.display="none";
  477. document.getElementById("server_portDiv").style.display="none";
  478. document.getElementById("busVenderIdDiv").style.display="none";
  479. document.getElementById("EquipmentProviderDiv").style.display="none";
  480. document.getElementById("TransportationCompanyNoDiv").style.display="none";
  481. document.getElementById("ChargeBoxIdDiv").style.display="none";
  482. document.getElementById("evseStationDiv").style.display="none";
  483. }
  484. }
  485. <?php } ?>
  486. function isNumberKey(evt)
  487. {
  488. var charCode = (evt.which) ? evt.which : event.keyCode
  489. if (charCode > 31 && (charCode < 48 || charCode > 57) && (charCode != 46))
  490. return false;
  491. return true;
  492. }
  493. function UTF8Length(tx){
  494. var str = encodeURIComponent(tx);
  495. len = str.replace(/%[A-F\d]{2}/g, 'U').length;
  496. return len;
  497. }
  498. </script>
  499. </html>