register_number2.html 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Aisky-Sixth</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  7. <!-- 新 Bootstrap4 核心 CSS 文件 -->
  8. <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.1.0/css/bootstrap.min.css">
  9. <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
  10. <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
  11. <!-- popper.min.js 用于弹窗、提示、下拉菜单 -->
  12. <script src="https://cdn.bootcss.com/popper.js/1.12.5/umd/popper.min.js"></script>
  13. <!-- 最新的 Bootstrap4 核心 JavaScript 文件 -->
  14. <script src="https://cdn.bootcss.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
  15. <!--可用來建立使用者小圖示-->
  16. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  17. <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js"></script>
  18. <!--<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">-->
  19. <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
  20. <!--<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>-->
  21. <!--<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>-->
  22. <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
  23. <style>
  24. body {
  25. margin:0;
  26. <!--background-color: #4d4d4d;-->
  27. }
  28. .navbar-dark .navbar-nav .nav-link {
  29. color: white;
  30. cursor: pointer;
  31. text-decoration:none;
  32. width: 110px;
  33. height: 46px;
  34. }
  35. .nav-top {
  36. line-height:40px;
  37. background-color: #C4C4C4;
  38. }
  39. .website_title{
  40. font-family: Roboto;
  41. font-style: normal;
  42. font-weight: normal;
  43. font-size: 30px;
  44. color: #000000;
  45. }
  46. .navbar-nav > li{
  47. float: none;
  48. display: inline-block;
  49. width: 110px;
  50. margin: 0 auto;
  51. text-align: center;
  52. }
  53. .navbar-nav > li a{
  54. font-size: 20px;
  55. }
  56. .main-page {
  57. margin-top: 200px;
  58. }
  59. .page-title {
  60. font-family: Roboto;
  61. font-style: normal;
  62. font-weight: bold;
  63. font-size: 36px;
  64. }
  65. .flex {
  66. display: flex;
  67. flex-direction: row;
  68. flex-wrap: wrap;
  69. justify-content: center;
  70. }
  71. .node {
  72. height: auto;
  73. border: 2px solid #E5E5E5;
  74. border-radius: 5px;
  75. margin-top:35px;
  76. }
  77. .node-opt {
  78. font-size: 21px;
  79. }
  80. ol {
  81. list-style-type: disc;
  82. font-size: 17px;
  83. }
  84. .set-link {
  85. display: inline-block;
  86. width: 350px;
  87. height: 100px;
  88. line-height: 100px;
  89. background: #008CBA;
  90. border: 1px solid #CFCFCF;
  91. box-sizing: border-box;
  92. color: #FFFFFF;
  93. border-radius: 10px;
  94. font-size: 36px;
  95. }
  96. .fa{
  97. display: inline-block;
  98. font: normal normal normal 14px/1 FontAwesome;
  99. font-size: inherit;
  100. text-rendering: auto;
  101. -webkit-font-smoothing: antialiased;
  102. }
  103. .fa-user-o:before{
  104. content: "\f2c0";
  105. }
  106. .abc {background:lightgreen;border:1px #000 solid;cursor:move;padding:10px 5px;}
  107. .draggable {min-width:50px;height:45px;display:inline-block;font-size:.9em;z-index:1;text-align:center;}
  108. html, body, #map-canvas{
  109. width:100%;
  110. height: 100%;
  111. }
  112. @media(max-width:373px){
  113. .card {
  114. margin-right: 0px;
  115. }
  116. }
  117. @media(max-width:577px){
  118. }
  119. @media(min-width:576px){
  120. }
  121. @media(min-width:768px){
  122. .navbar-nav > li {
  123. margin-left: 0px;
  124. }
  125. .navbar-nav .li-block {
  126. display:none;
  127. }
  128. }
  129. @media(min-width:991px){
  130. .navbar-nav > li {
  131. margin-left: 20px;
  132. }
  133. .navbar-nav .li-block {
  134. display:none;
  135. }
  136. }
  137. @media(min-width:1200px){
  138. .navbar-nav > li {
  139. margin-left: 50px;
  140. }
  141. .navbar-nav .li-block {
  142. display: inline-block;
  143. width: 20px;
  144. }
  145. }
  146. @media(min-width:1400px){
  147. .navbar-nav .li-block {
  148. display: inline-block;
  149. width: 100px;
  150. }
  151. }
  152. @media(min-width:1689px) {
  153. .navbar-nav > li {
  154. margin-left: 50px;
  155. }
  156. .navbar-nav .li-block {
  157. display: inline-block;
  158. width: 450px;
  159. }
  160. }
  161. </style>
  162. <script>
  163. var img_id = 0;
  164. $(function(){
  165. //動態添加感測點圖片文件input
  166. var node_img = document.getElementById('node_img');
  167. var html = '';
  168. for(var s=1; s<={{params.monitor_num}}; s++){
  169. if(s < 10){
  170. s = "0" + s
  171. };
  172. html += '<div class="col-5">';
  173. html += 'Nr.' + s + ' : <input type="file" style="margin-bottom:20px;width:85%;color:white;background-color:red;" name="filename" class="filename" onchange="" accept="image/gif, image/jpeg, image/png">';
  174. html += '</div>';
  175. //html += '<br>';
  176. };
  177. node_img.innerHTML = html;
  178. //判斷用戶如果是上傳圖片
  179. {% if params.path %}
  180. var path = '..' + '{{params.path}}'.substring(3);
  181. $("#farm_img").attr('src', path);
  182. $("#map-canvas").css('display', 'none');
  183. img_id = "#farm_img";
  184. var node_div = document.getElementById('node-list');
  185. for(var i=1; i<={{params.monitor_num}}; i++){
  186. if(i < 10){
  187. i = "0" + i
  188. };
  189. var div = document.createElement('div');
  190. var html = '';
  191. html += '<p style="font-weight: bold;">Nr.' + i + '</p>';
  192. html += '<input type="hidden" name="lat' + i + '" id="a' + i + '-1" value="0"></input>';
  193. html += '<input type="hidden" name="lng' + i + '" id="a' + i + '-2" value="0"></input>';
  194. div.innerHTML = html;
  195. div.setAttribute('id', 'a' + i);
  196. div.setAttribute('class', 'draggable abc');
  197. node_div.appendChild(div);
  198. <!--$('#a' + i).draggable({-->
  199. <!--disabled: false,-->
  200. <!--containment: '' + img_id,-->
  201. <!--grid: [ 1, 1 ],-->
  202. <!--snap: true,-->
  203. <!--snapMode: 'outter',-->
  204. <!--snapTolerance: 5,-->
  205. <!--scroll: false-->
  206. <!--}).mousemove(function(){-->
  207. <!--var coord = $(this).position();-->
  208. <!--document.getElementById('a' + i + '-1').value = Math.floor(coord.left);-->
  209. <!--document.getElementById('a' + i + '-2').value = Math.floor(coord.top);-->
  210. <!--});-->
  211. //使用eval()函數執行字串
  212. eval("$('#a" + i + "').draggable({disabled:false,containment:'" + img_id + "',grid:[1,1],snap:true,snapMode:'outter',snapTolerance:5,scroll:false}).mousemove(function(){var coord = $(this).position();document.getElementById('a" + i + "-1').value = Math.floor(coord.left);document.getElementById('a" + i + "-2').value = Math.floor(coord.top);});");
  213. };
  214. //判斷用戶如果是輸入地址
  215. {% else %}
  216. img_id = "#map-canvas";
  217. {% endif %}
  218. });
  219. function img_error() {
  220. //this.src='./inimage/psfi.jpg';
  221. document.getElementById("" + img_id).src="../static/img/psfi.jpg";
  222. $('#a01').draggable('option','disabled', true);
  223. $('#a01').css('background-color', 'red');
  224. $('#a02').draggable('option','disabled', true);
  225. $('#a02').css('background-color', 'red');
  226. $('#a03').draggable('option','disabled', true);
  227. $('#a03').css('background-color', 'red');
  228. $('#a04').draggable('option','disabled', true);
  229. $('#a04').css('background-color', 'red');
  230. $('#a05').draggable('option','disabled', true);
  231. $('#a05').css('background-color', 'red');
  232. $('#a06').draggable('option','disabled', true);
  233. $('#a06').css('background-color', 'red');
  234. }
  235. //------------------------------
  236. function readURL(input) {
  237. if (input.files && input.files[0]) {
  238. var reader = new FileReader();
  239. reader.onload = function (e) {
  240. $('' + img_id).attr('src', e.target.result);
  241. $('' + img_id).css("width", "1100px");
  242. $('' + img_id).css("height", "650px");
  243. $('#a01').draggable('option','disabled', false);
  244. $('#a01').css('background-color', 'lightgreen');
  245. $('#a02').draggable('option','disabled', false);
  246. $('#a02').css('background-color', 'lightgreen');
  247. $('#a03').draggable('option','disabled', false);
  248. $('#a03').css('background-color', 'lightgreen');
  249. $('#a04').draggable('option','disabled', false);
  250. $('#a04').css('background-color', 'lightgreen');
  251. $('#a05').draggable('option','disabled', false);
  252. $('#a05').css('background-color', 'lightgreen');
  253. $('#a06').draggable('option','disabled', false);
  254. $('#a06').css('background-color', 'lightgreen');
  255. //$('' + img_id).css("max-height", 800);
  256. }
  257. reader.readAsDataURL(input.files[0]);
  258. }
  259. //-------------------------------------------------------
  260. var inputVal = document.getElementById("filename");
  261. var OK = document.getElementById("OK");
  262. if (inputVal.value == "") {
  263. inputVal.style.backgroundColor = "#e67300";
  264. document.getElementById("" + img_id).src="";
  265. }
  266. else{
  267. inputVal.style.backgroundColor = "";
  268. }
  269. }
  270. //---------------------------------------------------------
  271. function refreshPage(){
  272. //window.location.reload(true); //error in safari
  273. $('#rq').submit();
  274. }
  275. </script>
  276. </head>
  277. <body>
  278. <nav class="fixed-top">
  279. <nav class="navbar navbar-expand-md nav-top justify-content-center">
  280. <div>
  281. <span class="website_title">序號登記2</span>
  282. </div>
  283. </nav>
  284. <nav class="navbar navbar-expand-md bg-dark navbar-dark nav-bottom">
  285. <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
  286. <span class="navbar-toggler-icon"></span>
  287. </button>
  288. <div class="collapse navbar-collapse" id="collapsibleNavbar">
  289. <ul class="navbar-nav">
  290. <li class="nav-item">
  291. <a class="nav-link" href="/">序號登記</a>
  292. </li>
  293. <li class="nav-item">
  294. <a class="nav-link" href="#">排程設定</a>
  295. </li>
  296. <li class="nav-item">
  297. <a class="nav-link" href="#">報表輸出</a>
  298. </li>
  299. <li class="nav-item">
  300. <a class="nav-link" href="#">RMA</a>
  301. </li>
  302. <li class="nav-item">
  303. <a class="nav-link" href="#">故障紀錄</a>
  304. </li>
  305. <li class="nav-item">
  306. <a class="nav-link" href="#">求助</a>
  307. </li>
  308. <li class="li-block"></li>
  309. <li class="nav-item">
  310. <a class="nav-link" href="#"><i class="fa fa-user-o"></i> {{params.username}}</a>
  311. </li>
  312. <li class="nav-item">
  313. <a class="nav-link" href="/logout">Logout</a>
  314. </li>
  315. </ul>
  316. </div>
  317. </nav>
  318. </nav>
  319. <div class="main-page">
  320. <form method="post" action="/register_number2" enctype="multipart/form-data">
  321. <div class="container">
  322. <div class="row">
  323. <div class="col flex" style="margin: auto; ">
  324. <div class="col-12" style="margin-top:30px;">
  325. <h1>Step3:</h1>
  326. </div>
  327. <div class="col-2"></div>
  328. <div class="col-10">
  329. <label style="color:black;font-size:20px;">Please place the sensor and upload photos/請將感測器置於案場後並上傳相對應圖片:</label>
  330. </div>
  331. <div class="col-2"></div>
  332. <div id="node_img" class="col-10 row">
  333. <!--Nr.01 : <input type="file" style="width:40%;color:white;background-color:red;" name="filename" id="filename" onchange="" accept="image/gif, image/jpeg, image/png">-->
  334. </div>
  335. <div class="col-12" style="background-color:black;height:2px;margin:20px auto 20px;"></div>
  336. <div class="col-12" style="margin-top:30px;">
  337. <h1>Step4:</h1>
  338. </div>
  339. <div class="col-2"></div>
  340. <div class="col-10">
  341. <label style="color:black;font-size:20px;">Please drag sensor point to the right position/請把感測點拖到農場相對位置上</label>
  342. </div>
  343. <div id="node-list" class="col-12" style="width:100%;">
  344. <!--<div id='a01' class='draggable abc' style=''>-->
  345. <!--<p style='font-weight: bold;'>Nr.1</p>-->
  346. <!--<input type='hidden' name='l1' id='a01-1' value='0'></input>-->
  347. <!--<input type='hidden' name='t1' id='a01-2' value='0'></input>-->
  348. <!--</div>-->
  349. <!--<div id='a02' class='draggable abc' style=''>-->
  350. <!--<p style='font-weight: bold;'>Nr.2</p>-->
  351. <!--<input type='hidden' name='l2' id='a02-1' value='0'></input>-->
  352. <!--<input type='hidden' name='t2' id='a02-2' value='0'></input>-->
  353. <!--</div>-->
  354. <!--<div id='a03' class='draggable abc' style=''>-->
  355. <!--<p style='font-weight: bold;'>Nr.3</p>-->
  356. <!--<input type='hidden' name='l3' id='a03-1' value='0'></input>-->
  357. <!--<input type='hidden' name='t3' id='a03-2' value='0'></input>-->
  358. <!--</div>-->
  359. <!--<div id='a04' class='draggable abc' style=''>-->
  360. <!--<p style='font-weight: bold;'>Nr.4</p>-->
  361. <!--<input type='hidden' name='l4' id='a04-1' value='0'></input>-->
  362. <!--<input type='hidden' name='t4' id='a04-2' value='0'></input>-->
  363. <!--</div>-->
  364. <!--<div id='a05' class='draggable abc' style=''>-->
  365. <!--<p style='font-weight: bold;'>Nr.5</p>-->
  366. <!--<input type='hidden' name='l5' id='a05-1' value='0'></input>-->
  367. <!--<input type='hidden' name='t5' id='a05-2' value='0'></input>-->
  368. <!--</div>-->
  369. <!--<div id='a06' class='draggable abc' style=''>-->
  370. <!--<p style='font-weight: bold;'>Nr.6</p>-->
  371. <!--<input type='hidden' name='l6' id='a06-1' value='0'></input>-->
  372. <!--<input type='hidden' name='t6' id='a06-2' value='0'></input>-->
  373. <!--</div>-->
  374. </div>
  375. <div class="col-12">
  376. <img id="farm_img" src="" style='width:1080px;height:650px;' onError="img_error()" ondragstart="return false;">
  377. </div>
  378. <div class="col-12">
  379. <div id="map-canvas" class="col-12" style="text-align:center;background-color:#f2f2f2;padding:280px;border:1px;border-radius: 35px;"></div>
  380. </div>
  381. <div class="col-12" style="background-color:black;height:2px;margin-bottom:20px;margin-top:50px;"></div>
  382. <div class="col-xs-2 col-xs-offset-2">
  383. <input type="reset" class="btn btn-secondary" style="margin:0 20px;font-weight:bold;" data-dismiss="modal" value="Reset/重設">
  384. </div>
  385. <div class="col-xs-2 col-xs-offset-3">
  386. <input type="submit" class="btn btn-success" style="margin:0 20px;font-weight:bold;color:black;" data-toggle="modal" data-target="#123" value="Save changes/設定完成">
  387. </div>
  388. <div class="col-12" style="height:70px;"></div>
  389. </div>
  390. </div>
  391. </div>
  392. </form>
  393. </div>
  394. </body>
  395. <script>
  396. {% if params.lat %}
  397. $("#farm_img").css('display', 'none');
  398. function initialize() {
  399. var lat = {{params.lat}};
  400. var lng = {{params.lng}};
  401. var a = -1;
  402. var mapOptions = {
  403. center: { lat: lat, lng: lng},
  404. <!--center: { lat: 22.707340, lng: 120.531000},-->
  405. zoom: 19,
  406. mapTypeId: 'satellite',
  407. };
  408. var map = new google.maps.Map(
  409. document.getElementById('map-canvas'),
  410. mapOptions);
  411. var node_div = document.getElementById('node-list');
  412. for(var i=1; i<={{params.monitor_num}}; i++){
  413. if(i < 10){
  414. i = "0" + i
  415. };
  416. var div = document.createElement('div');
  417. var html = '';
  418. html += '<input type="hidden" name="lat' + i + '" id="a' + i + '-1" value="0"></input>';
  419. html += '<input type="hidden" name="lng' + i + '" id="a' + i + '-2" value="0"></input>';
  420. div.innerHTML = html;
  421. node_div.appendChild(div);
  422. lng = lng + 0.00008;
  423. var defineStr = "var position" + i.toString();
  424. var defineStr2 = "var marker" + i.toString();
  425. //使用eval()函數執行字串
  426. eval(defineStr);
  427. eval(defineStr2);
  428. //為position賦值
  429. eval("position" + i.toString() + " = " + "{lat:" + lat + ",lng:" + lng + "};");
  430. //為marker賦值
  431. eval("marker" + i.toString() + " = " + "new google.maps.Marker({position:" + ("position" + i.toString()) + ",map:map,label:'" + i + "',draggable:true});");
  432. //監聽marker拖曳結束事件
  433. eval("marker" + i.toString() + ".addListener('dragend',function(){var s = marker" + i.toString() + ".getPosition();var lat = s.lat().toString();var lng = s.lng().toString();document.getElementById('a" + i + "-1').value = lat;document.getElementById('a" + i + "-2').value = lng;});");
  434. };
  435. };
  436. <!--google.maps.event.addDomListener(-->
  437. <!--window, 'load', initialize);-->
  438. {% endif %}
  439. </script>
  440. <script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDKVm-6LBJqxrDJLEzJujGjZLVTfK0RiAE&callback=initialize"></script>
  441. </html>