station.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Untitled Document</title>
  6. <style>
  7. #tb {
  8. font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
  9. width: 100%;
  10. border-collapse: collapse;
  11. }
  12. #tb td,
  13. #tb th {
  14. font-size: 1em;
  15. border: 1px solid #98bf21;
  16. padding: 3px 7px 2px 7px;
  17. }
  18. #tb th {
  19. font-size: 1.1em;
  20. text-align: left;
  21. padding-top: 5px;
  22. padding-bottom: 4px;
  23. background-color: #A7C942;
  24. color: #ffffff;
  25. }
  26. #tb tr.alt td {
  27. color: #000000;
  28. background-color: #EAF2D3;
  29. }
  30. #tb tr.undefined td {
  31. color: #000000;
  32. background-color: rgb(187, 187, 187);
  33. }
  34. #tb tr.exceed td {
  35. color: #000000;
  36. background-color: rgb(255, 226, 209);
  37. }
  38. </style>
  39. <style>
  40. </style>
  41. <link href="mystyle.css" rel="stylesheet" type="text/css" />
  42. <style>
  43. #mycanvas{
  44. position: absolute;
  45. display:none;
  46. width:400px;
  47. height:300px;
  48. left:20%;
  49. z-index:20;
  50. }
  51. #popBox{
  52. position: absolute;
  53. display:none;
  54. width:400px;
  55. height:300px;
  56. left:15%;
  57. top:5%;
  58. z-index:11;
  59. background:rgb(255, 255, 255);
  60. }
  61. #popLayer{
  62. width:100%;
  63. height:100%;
  64. position: absolute;
  65. display:none;
  66. left:0;
  67. top:0;
  68. z-index:10;
  69. background:#DCDBDC;
  70. -moz-opacity: 0.8;
  71. opacity:.80;
  72. filter: alpha(opacity=80);/* 只支持IE6、7、8、9 */
  73. line-height:56px;
  74. }
  75. #si,#sn
  76. {
  77. margin-left: 12%;
  78. }
  79. #ok
  80. {
  81. margin-left: 30%;
  82. }
  83. #cancel
  84. {
  85. margin-left: 10%;
  86. }
  87. </style>
  88. </head>
  89. <body style="background-color: rgb(255, 255, 255)" onload="get_()">
  90. <form method="POST">
  91. 油站标识:
  92. <input type="text" name="stationid" id="stationid">
  93. 油站名称:
  94. <input type="text" name="stationname" id="stationname">
  95. <input type="button" class="query" id="query" value="查询" onclick="get_()">
  96. <input type="button" class="add" id="add" value="新增" onclick="add_box('/api/addstation')">
  97. <input type="button" class="update" id="update" value="更新" onclick="update_('/dbinterface/stationinfo')">
  98. <input type="button" class="delete" id="delete" value="删除" onclick="delete_('/dbinterface/stationinfo')">
  99. </form>
  100. <table>
  101. <tr>
  102. <td style="background-color:#ffffff;height:200px;width:3000px;" valign="top">
  103. <table class="table" id="tb" border="1">
  104. <thead>
  105. <tr>
  106. <th>index</th>
  107. <th>油站名称</th>
  108. <th>油站id</th>
  109. </tr>
  110. </thead>
  111. <tbody id="tbMain"></tbody>
  112. </table>
  113. </td>
  114. </tr>
  115. </table>
  116. <div id="popLayer">
  117. </div>
  118. <div id="popBox">
  119. <div style="text-align:center; color: slateblue">新增站点</div>
  120. <br>
  121. <br>
  122. <!--<form method="POST" class="add">-->
  123. <p name="si" id="si">油站标识: <input type="text" name="stationid_a" id="stationid_a"></p>
  124. <p name="sn" id="sn">油站名称: <input type="text" name="stationname_a" id="stationname_a"></p>
  125. <br>
  126. <br>
  127. <input input type="submit" class="ok" id="ok" value="确定" onclick="add_('/api/addstation')">
  128. <input type="button" class="cancel" id="cancel" value="取消" onclick="closeBox()">
  129. <!--</form>-->
  130. <!--
  131. <div style="text-align:right"><a href="javascript:void(0)" onclick="closeBox()">关闭</a></div>
  132. -->
  133. </div>
  134. <div>
  135. <canvas id='mycanvas'></canvas>
  136. </div>
  137. <div id='waiting'>
  138. <div class="spinner">
  139. <div class="bounce1"></div>
  140. <div class="bounce2"></div>
  141. <div class="bounce3"></div>
  142. </div>
  143. </div>
  144. <script>
  145. function check() {
  146. // var va =document.getElementById("stationid_a");
  147. // va.setCustomValidity("油站标识不能为空!");
  148. // va =document.getElementById("stationname_a");
  149. // va.setCustomValidity("用户名不能为空!");
  150. var Control = document.querySelector("#stationid_a");
  151. Control.setCustomValidity("油站标识不能为空!");
  152. Control = document.querySelector("#stationname_a");
  153. Control.setCustomValidity("用户名不能为空!");
  154. }
  155. </script>
  156. <script>
  157. function ftest() {
  158. // document.getElementById("update").type = "hidden";
  159. var xmlhttp;
  160. if (window.XMLHttpRequest) {
  161. // IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
  162. xmlhttp = new XMLHttpRequest();
  163. }
  164. else {
  165. // IE6, IE5 浏览器执行代码
  166. xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  167. }
  168. xmlhttp.onreadystatechange = function () {
  169. if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
  170. var user = xmlhttp.responseText;
  171. if (user != "admin") {
  172. document.getElementById("add").type = "hidden";
  173. document.getElementById("update").type = "hidden";
  174. document.getElementById("delete").type = "hidden";
  175. }
  176. //var data = JSON.parse(xmlhttp.responseText);
  177. }
  178. }
  179. xmlhttp.open("POST", "/getuser", true);
  180. xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  181. xmlhttp.send('');
  182. }
  183. </script>
  184. <script>
  185. // if (window.showModalDialog == undefined) {
  186. // //alert("初始化的时候,判断window.showModalDialog是否存在")
  187. // window.showModalDialog = function (url, mixedVar, features) {
  188. // window.hasOpenWindow = true;
  189. // if (mixedVar) var mixedVar = mixedVar;
  190. // if (features) var features = features.replace(/(dialog)|(px)/ig, "").replace(/;/g, ',').replace(/\:/g, "=");
  191. // window.myNewWindow = window.open(url, "_blank", features);
  192. // }
  193. // }
  194. </script>
  195. <script type="text/javascript">
  196. function popBox() {
  197. var popBox = document.getElementById('popBox');
  198. var popLayer = document.getElementById('popLayer');
  199. //popLayer.style.width = document.body.scrollWidth + "px";
  200. //popLayer.style.height = document.body.scrollHeight + "px";
  201. popLayer.style.display = "block";
  202. popBox.style.display = "block";
  203. }//end func popBox()
  204. function closeBox() {
  205. var popBox = document.getElementById('popBox');
  206. var popLayer = document.getElementById('popLayer');
  207. popLayer.style.display = "none";
  208. popBox.style.display = "none";
  209. }//end func closeBox()
  210. </script>
  211. <script>
  212. function get_() {
  213. // document.getElementById("update").type = "hidden";
  214. var xmlhttp;
  215. if (window.XMLHttpRequest) {
  216. // IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
  217. xmlhttp = new XMLHttpRequest();
  218. }
  219. else {
  220. // IE6, IE5 浏览器执行代码
  221. xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  222. }
  223. xmlhttp.onreadystatechange = function () {
  224. if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
  225. var rtn = xmlhttp.responseText;
  226. var json = JSON.parse(xmlhttp.responseText);
  227. var data = json.data;
  228. var s = '';
  229. for (var i = 0; i < data.length; i++) {
  230. s += '<td>' + (i + 1) + '</td>'
  231. + '<td>' + data[i]['name'] + '</td>'
  232. + '<td>' + data[i]['id'] + '</td>'
  233. + '</tr>'
  234. }
  235. var t = document.getElementById("tbMain");
  236. t.innerHTML = s;
  237. var w = document.getElementById('waiting');
  238. w.style.display = "none";
  239. //w = document.getElementById('mycanvas');
  240. //w.style.display = "none";
  241. // $(waiting)
  242. }
  243. }
  244. // alert(document.getElementById('stationid').innerHTML)
  245. var Control = document.querySelector("#stationid");
  246. var id = Control.value;
  247. var url;
  248. if (id == '') {
  249. url = '/api/getallstation';
  250. }
  251. else {
  252. url = '/api/getstation/' + id;
  253. }
  254. xmlhttp.open("POST", url, true);
  255. xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  256. //xmlhttp.setRequestHeader("Content-Type","application/json");
  257. var json = {};
  258. var data = JSON.stringify(json);
  259. xmlhttp.send(data);
  260. var t = document.getElementById("tbMain");
  261. t.innerHTML = '';
  262. var w = document.getElementById('waiting');
  263. w.style.display = "block";
  264. // w = document.getElementById('mycanvas');
  265. // w.style.display = "block";
  266. }
  267. function AddIfNotExisted(id, pxmlhttp, pjson) {
  268. // document.getElementById("update").type = "hidden";
  269. var xmlhttp;
  270. if (window.XMLHttpRequest) {
  271. // IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
  272. xmlhttp = new XMLHttpRequest();
  273. }
  274. else {
  275. // IE6, IE5 浏览器执行代码
  276. xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  277. }
  278. xmlhttp.onreadystatechange = function () {
  279. if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
  280. var rtn = xmlhttp.responseText;
  281. // alert(xmlhttp.responseText);
  282. var json = JSON.parse(xmlhttp.responseText);
  283. var len = json.data.length;
  284. if (len >= 1) {
  285. alert("用户标识已存在!")
  286. } else {
  287. pxmlhttp.send(pjson);
  288. }
  289. }
  290. }
  291. url = '/api/getstation/' + id;
  292. xmlhttp.open("POST", url, true);
  293. xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  294. var json = {};
  295. var data = JSON.stringify(json);
  296. xmlhttp.send(data);
  297. }
  298. function add_box(url) {
  299. popBox();
  300. }
  301. function add_(url) {
  302. // document.getElementById("update").type = "hidden";
  303. //check();
  304. var xmlhttp;
  305. if (window.XMLHttpRequest) {
  306. // IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
  307. xmlhttp = new XMLHttpRequest();
  308. }
  309. else {
  310. // IE6, IE5 浏览器执行代码
  311. xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  312. }
  313. xmlhttp.onreadystatechange = function () {
  314. if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
  315. var rtn = xmlhttp.responseText;
  316. if (JSON.parse(rtn).success == 'true') {
  317. alert('添加用户成功!')
  318. }
  319. //var data = JSON.parse(xmlhttp.responseText);
  320. }
  321. }
  322. xmlhttp.open("POST", url, true);
  323. xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  324. //xmlhttp.setRequestHeader("Content-Type","application/json");
  325. var Control = document.querySelector("#stationid_a");
  326. var id = Control.value.trim();
  327. if (id == '') {
  328. alert("油站标识不能为空!")
  329. return false;
  330. }
  331. Control = document.querySelector("#stationname_a");
  332. var name = Control.value.trim();
  333. if (name == '') {
  334. alert("油站名称不能为空!")
  335. return false;
  336. }
  337. var json = {};
  338. var data = {};
  339. data['name'] = name
  340. data['id'] = id;
  341. json['data'] = data;
  342. json = JSON.stringify(json);
  343. //xmlhttp.send(json);
  344. AddIfNotExisted(id, xmlhttp, json);
  345. }
  346. </script>
  347. <script>
  348. var $ = {};
  349. $.Particle = function (opt) {
  350. this.radius = 7;
  351. this.x = opt.x;
  352. this.y = opt.y;
  353. this.angle = opt.angle;
  354. this.speed = opt.speed;
  355. this.accel = opt.accel;
  356. this.decay = 0.01;
  357. this.life = 1;
  358. };
  359. $.Particle.prototype.step = function (i) {
  360. this.speed += this.accel;
  361. this.x += Math.cos(this.angle) * this.speed;
  362. this.y += Math.sin(this.angle) * this.speed;
  363. this.angle += $.PI / 64;
  364. this.accel *= 1.01;
  365. this.life -= this.decay;
  366. if (this.life <= 0) {
  367. $.particles.splice(i, 1);
  368. }
  369. };
  370. $.Particle.prototype.draw = function (i) {
  371. $.ctx.fillStyle = $.ctx.strokeStyle = 'hsla(' + ($.tick + (this.life * 120)) + ', 100%, 60%, ' + this.life + ')';
  372. $.ctx.beginPath();
  373. if ($.particles[i - 1]) {
  374. $.ctx.moveTo(this.x, this.y);
  375. $.ctx.lineTo($.particles[i - 1].x, $.particles[i - 1].y);
  376. }
  377. $.ctx.stroke();
  378. $.ctx.beginPath();
  379. $.ctx.arc(this.x, this.y, Math.max(0.001, this.life * this.radius), 0, $.TWO_PI);
  380. $.ctx.fill();
  381. var size = Math.random() * 1.25;
  382. $.ctx.fillRect(~~(this.x + ((Math.random() - 0.5) * 35) * this.life), ~~(this.y + ((Math.random() - 0.5) * 35) * this.life), size, size);
  383. }
  384. $.step = function () {
  385. $.particles.push(new $.Particle({
  386. x: $.width / 2 + Math.cos($.tick / 20) * $.min / 2,
  387. y: $.height / 2 + Math.sin($.tick / 20) * $.min / 2,
  388. angle: $.globalRotation + $.globalAngle,
  389. speed: 0,
  390. accel: 0.01
  391. }));
  392. $.particles.forEach(function (elem, index) {
  393. elem.step(index);
  394. });
  395. $.globalRotation += $.PI / 6;
  396. $.globalAngle += $.PI / 6;
  397. };
  398. $.draw = function () {
  399. $.ctx.clearRect(0, 0, $.width, $.height);
  400. $.particles.forEach(function (elem, index) {
  401. elem.draw(index);
  402. });
  403. };
  404. $.init = function () {
  405. //var Control = document.querySelector("#canvas");
  406. $.canvas = document.getElementById('mycanvas');
  407. // $.canvas.style.zIndex = 20;
  408. //$.canvas.style.position = 'absolute';
  409. //$.canvas = document.createElement('canvas');
  410. //document.createAttribute("id:'waiting");
  411. // $.canvas.setAttribute("id","waiting");
  412. // $.canvas = document.getElementById('canvas');
  413. // $.canvas.id = 'waiting';
  414. //$.canvas.style = '{ position: absolute; display:none; width:400px;height:300px;left:20%; z-index:20;}';
  415. $.ctx = $.canvas.getContext('2d');
  416. $.ctx.globalCompositeOperation = 'source-over';
  417. $.width = 200;
  418. $.height = 200;
  419. $.canvas.width = $.width * window.devicePixelRatio;
  420. $.canvas.height = $.height * window.devicePixelRatio;
  421. $.canvas.style.width = $.width + 'px';
  422. $.canvas.style.height = $.height + 'px';
  423. $.ctx.scale(window.devicePixelRatio, window.devicePixelRatio);
  424. $.min = $.width * 0.5;
  425. $.particles = [];
  426. $.globalAngle = 0;
  427. $.globalRotation = 0;
  428. $.tick = 0;
  429. $.PI = Math.PI;
  430. $.TWO_PI = $.PI * 2;
  431. $.ctx.globalCompositeOperation = 'lighter';
  432. document.body.appendChild($.canvas);
  433. $.loop();
  434. };
  435. $.loop = function () {
  436. requestAnimationFrame($.loop);
  437. $.step();
  438. $.draw();
  439. $.tick++;
  440. };
  441. $.init();
  442. </script>
  443. </body>
  444. </html>