You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

316 lines
12 KiB

6 years ago
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Complaints</title>
  6. <meta name="viewport" content="initial-scale=1.0">
  7. <meta charset="utf-8">
  8. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  9. <script src="socket.io/node_modules/socket.io-client/dist/socket.io.js"></script>
  10. <style>
  11. #map {
  12. height: 100%;
  13. }
  14. html, body {
  15. height: 100%;
  16. margin: 0;
  17. padding: 0;
  18. }
  19. </style>
  20. <style>
  21. #img:hover{
  22. color: #424242;
  23. -webkit-transition: all .3s ease-in;
  24. -moz-transition: all .3s ease-in;
  25. -ms-transition: all .3s ease-in;
  26. -o-transition: all .3s ease-in;
  27. transition: all .3s ease-in;
  28. opacity: 1;
  29. transform: scale(1.15);
  30. -ms-transform: scale(1.15); /* IE 9 */
  31. -webkit-transform: scale(1.15); /* Safari and Chrome */
  32. max-width: 400px;
  33. max-height: 400px;
  34. }
  35. #img-user{
  36. max-width: 150px;
  37. max-height: 150px;
  38. }
  39. .title{
  40. text-align: left;
  41. }
  42. td{
  43. padding: 20px 10px;
  44. }
  45. .popup{
  46. display: none; /* Hidden by default */
  47. position: fixed; /* Stay in place */
  48. left: 0;
  49. top: 0;
  50. width: 100%; /* Full width */
  51. height: 100%; /* Full height */
  52. overflow: auto; /* Enable scroll if needed */
  53. background-color: rgb(0,0,0); /* Fallback color */
  54. background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
  55. padding-top: 60px;
  56. }
  57. #table,#table-user{
  58. background: white;
  59. padding: 40px 60px;
  60. }
  61. #content, #user-content{
  62. display: inline-block;
  63. margin-top: 125px;
  64. background: white;
  65. }
  66. #submit{
  67. top: 50%;
  68. transform: translateY(-50%);
  69. }
  70. </style>
  71. </head>
  72. <body>
  73. <audio id="audio" src="http://www.soundjay.com/button/beep-07.wav" autoplay="false"></audio>
  74. <div id="map"></div>
  75. <!-- ANANA SOKIYIM JAVASCRIPT
  76. Sen nası gereksiz bir dilsin amk bütün bi gecemi yedin
  77. ben senenin ebeni sikiyim inşallah seni yazan programcının götüne av tüfeği girer
  78. AYNISI SOCKET.IO IÇIN DE GEÇERLİ ALLAHIM KAFAYI YİCEM ADAMLAR HERALDE "ACABA NE KADAR ÖZÜRLÜ BI FRAMERWORK YAZARIZ DUYE BAŞLAMIŞLAR IŞE"-->
  79. <div id = "popup" align = "center" class = "popup">
  80. <div id = "content">
  81. <form onsubmit="sendUpdate(this);console.log('submitting');return false;" action = "." id = "submission_form">
  82. <table border="0" cellpadding="10" cellspacing="0" id = "table" class = "modal">
  83. <tr>
  84. <td rowspan="2" colspan="7"><img src="cityscape.png" alt="img"id = "img"></td>
  85. <td colspan="2" class="title"><strong>Priority: </strong></td>
  86. <td colspan="1" id = "priority">7</td>
  87. </tr>
  88. <tr>
  89. <td colspan="2" class="title"><strong>Type: </strong></td>
  90. <td colspan="1" id = "type"> Ambulance</td>
  91. </tr>
  92. <tr>
  93. <td colspan="4" class="title"><strong>Submitter: </strong></td>
  94. <td colspan="6">
  95. <a href="#" id = "user" class = "panel" onclick=
  96. "document.getElementById('popup').style.display='none';
  97. document.getElementById('user-popup').style.display='block';
  98. setUser(this.getAttribute('userid'))"
  99. >Efe Aydın </a>
  100. </td>
  101. </tr>
  102. <tr>
  103. <td colspan="4" class="title"><strong>Message: </strong></td>
  104. <td colspan="6" id = "message">Test ambulance</td>
  105. </tr>
  106. <tr>
  107. <td colspan="4" class="title"><strong>Tags: </strong></td>
  108. <td colspan="6" id = "tags">Test tags</td>
  109. </tr>
  110. <tr>
  111. <td colspan="4" class="title"><strong>Message: </strong></td>
  112. <td colspan="6" id = "input"> <textarea name="message" rows="5" cols="30" id="response">Please enter response.</textarea>
  113. </td>
  114. </tr>
  115. <tr>
  116. <td colspan="10">
  117. <input type="submit" id = "submit">
  118. </td>
  119. </tr>
  120. </table>
  121. </form>
  122. </div>
  123. </div>
  124. <div id = "user-popup" align = "center" class="popup">
  125. <div id = "user-content">
  126. <table border="0" cellpadding="10" cellspacing="0" id = "table-user" class = "modal">
  127. <tr>
  128. <td rowspan="3" colspan="7"><img src="cityscape.png" alt="img"id = "img-user"></td>
  129. <td colspan="2" class="title"><strong>Name: </strong></td>
  130. <td colspan="1" id = "name">Efe Aydın</td>
  131. </tr>
  132. <tr>
  133. <td colspan="2" class="title"><strong>TC: </strong></td>
  134. <td colspan="1" id = "tc">111111111111</td>
  135. </tr>
  136. <tr>
  137. <td colspan="2" class="title"><strong>Trust: </strong></td>
  138. <td colspan="1" id = "trust">7</td>
  139. </tr>
  140. <tr>
  141. <td colspan="4" class="title"><strong>Phone: </strong></td>
  142. <td colspan="6" id="phone">
  143. 0 555 555 55 55
  144. </td>
  145. </tr>
  146. <tr>
  147. <td colspan="4" class="title"><strong>E-mail: </strong></td>
  148. <td colspan="6" id = "email">efeaydin@citizenview.com</td>
  149. </tr>
  150. <tr>
  151. <td colspan="4" class="title"><strong>Health: </strong></td>
  152. <td colspan="6" id = "health">Test tags</td>
  153. </tr>
  154. </table>
  155. <button onclick=
  156. "document.getElementById('popup').style.display='block';
  157. document.getElementById('user-popup').style.display='none';"
  158. style="margin-bottom: 5px;">OK</button>
  159. </div>
  160. </div>
  161. <script>
  162. function setUser(id) {
  163. if(!(id in users)) {
  164. $.get("https://" + document.domain + ":5000/users/" + id, function (dataStr, status) {
  165. data_user = $.parseJSON(dataStr)
  166. users[id]=data_user
  167. document.getElementById("name").innerHTML = users[id]["realname"];
  168. document.getElementById("tc").innerHTML = users[id]["TC"];
  169. document.getElementById("trust").innerHTML = users[id]["trustability"];
  170. document.getElementById("phone").innerHTML = users[id]["tel"];
  171. document.getElementById("email").innerHTML = users[id]["email"];
  172. document.getElementById("img-user").setAttribute("src","https://" + document.domain + ":5000"+users[id]["avatar"])
  173. });
  174. }else {
  175. document.getElementById("name").innerHTML = users[id]["realname"];
  176. document.getElementById("tc").innerHTML = users[id]["TC"];
  177. document.getElementById("trust").innerHTML = users[id]["trustability"];
  178. document.getElementById("phone").innerHTML = users[id]["tel"];
  179. document.getElementById("email").innerHTML = users[id]["email"];
  180. document.getElementById("img-user").setAttribute("src","data:image/png;base64," + users[id]["image"])
  181. }
  182. }
  183. function sendUpdate(form) {
  184. params = "?";
  185. params += "message=" + document.getElementById("response").value + "&";
  186. params += "id=" + form.getAttribute("id") + "&";
  187. params += "index=" + form.getAttribute("index");
  188. $.get("https://" + document.domain + ":5000/complaints_update" + params, function (dataStr, status) {
  189. });
  190. }
  191. </script>
  192. <script>
  193. var modal = document.getElementById('popup');
  194. window.onclick = function(event) {
  195. if (event.target == modal) {
  196. modal.style.display = "none";
  197. }
  198. }
  199. </script>
  200. <script>
  201. var map;
  202. function initMap() {
  203. map = new google.maps.Map(document.getElementById('map'), {
  204. center: {lat: 39.92, lng: 32.85},
  205. zoom: 13
  206. });
  207. }
  208. </script>
  209. <script>
  210. var sound = document.getElementById("audio");
  211. var markers = [];
  212. var socket = io.connect('http://' + document.domain + ':' + location.port + "/complaints_socket");
  213. console.log('http://' + document.domain + ":4000/complaints_socket")
  214. console.log(socket);
  215. var markers = [];
  216. var denunciation_count = markers.length;
  217. var users = {};
  218. setInterval(function () {
  219. socket.emit("check",{})
  220. },1000);
  221. var LatLng = null;
  222. socket.on("new",function (dataStr) {
  223. for (var i = 0; i < markers.length; i++) {
  224. markers.pop().setMap(null);
  225. }
  226. console.log("Update received!")
  227. data = $.parseJSON(dataStr);
  228. for(var key in data) {
  229. data[key].forEach(function (element,index) {
  230. if(element["lng"] === undefined || element["lat"] === undefined){
  231. return;
  232. }
  233. LatLng = {lat: parseFloat(element["lat"]), lng: parseFloat(element["lng"])};
  234. var marker = new google.maps.Marker({
  235. position: {lat: parseFloat(element["lat"]), lng: parseFloat(element["lng"])},
  236. map: map,
  237. label: element["response"]["priority"].toString(),
  238. title: element["datetime"]
  239. });
  240. marker.addListener('click', function () {
  241. document.getElementById('popup').style.display = 'block';
  242. document.getElementById("priority").innerHTML = element["response"]["priority"];
  243. if(element["response"]["status"]){
  244. document.getElementById("response").innerHTML = element["response"]["message"];
  245. }
  246. document.getElementById("submission_form").setAttribute("index",index);
  247. document.getElementById("submission_form").setAttribute("id",key);
  248. document.getElementById("type").innerHTML = "Road Damage";
  249. document.getElementById("message").innerHTML = element["content"];
  250. if (!(key in users)) {
  251. $.get("https://" + document.domain + ":5000/users/" + key, function (dataStr, status) {
  252. data_user = $.parseJSON(dataStr);
  253. users[key] = data_user;
  254. document.getElementById("user").innerHTML = users[key]["realname"];
  255. });
  256. } else {
  257. document.getElementById("user").innerHTML = users[key]["realname"];
  258. }
  259. document.getElementById("user").setAttribute("userid", key);
  260. document.getElementById("img").setAttribute("src", "data:image/png;base64," + element["img"])
  261. });
  262. });
  263. }
  264. map.setCenter(LatLng);
  265. if (denunciation_count < markers.length) {
  266. sound.play();
  267. }
  268. denunciation_count = markers.length;
  269. });
  270. </script>
  271. <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBuOC03IHPA_6TPnfk18b0SAgD1uge4-dk&callback=initMap" async defer></script>
  272. </body>
  273. </html>