Smart and Autonomous parking.
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.

162 lines
7.0 KiB

5 years ago
<!--
5 years ago
#Authors: Oulis Evangelos, Oulis Nikolaos, Katsibras Drosos
5 years ago
#===================================================================
-->
<!DOCTYPE html>
<html>
<meta charset="UTF-8">
<head>
<title>Smart Parking</title>
<link rel="stylesheet" type="text/css" href="parking.css">
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.4.1.min.js">
</script>
<script>
$(document).ready(function(){
5 years ago
$("#approve").click(function() {
server_ip = $("#server_ip").val();
server_port = $("#server_port").val();
5 years ago
server_protocol = $("#server_protocol").val();
alert(server_protocol + "://" + server_ip + " " + server_port + ". Started!!!")
5 years ago
$("#msg").empty();
5 years ago
if (server_ip !== "" && server_ip !== null && server_port !== "" && server_port !== null && server_protocol !== "" && server_protocol != null) {
5 years ago
$("#msg").html("<font color='red'>ok!</font>");
5 years ago
5 years ago
$("#approve").prop("disabled", true);
jQuery.ajax({
url: server_protocol + "://" + server_ip + ":" + server_port + "/",
type: "GET",
contentType: "application/json; charset=utf-8",
success: function(resultData) {
row = 1, pos = "r";
$("talbe#tab2").append("<tr id=\"row0\"></tr>");
5 years ago
$("tr#row0").append("<td width=\"30%\" bgcolor=\"lightgrey\"><div class=\"road\"></div></td>");
$("tr#row0").append("<td width=\"20%\" bgcolor=\"lightgrey\"><div class=\"road\"></div></td>");
$("tr#row0").append("<td width=\"20%\" bgcolor=\"lightgrey\"><div class=\"road\"></div></td>");
$("tr#row0").append("<td width=\"30%\" bgcolor=\"lightgrey\"><div class=\"road\"></div></td>");
$.each(resultData, function(key, val) {
console.log("Key " + key + ", val: " + val);
content = "";
if (val == 0) {
if (pos == "l") {
content = "<td id=\"park" + key + "\" width=\"30%\">No" + key + "<div id=\"" + key + "\" class=\"full left\"></div></td>";
} else {
content = "<td id=\"park" + key + "\" width=\"30%\">No" + key + "<div id=\"" + key + "\" class=\"full\"></div></td>";
}
} else {
if (pos == "l") {
content = "<td id=\"park" + key + "\" width=\"30%\">No" + key + "<div id=\"" + key + "\" class=\"empty left\"></div></td>";
}
else {
content = "<td id=\"park" + key + "\" width=\"30%\">No" + key + "<div id=\"" + key + "\" class=\"empty\"></div></td>";
}
}
if (pos == "r") {
$("table#tab2").append("<tr id=\"row" + row + "\"></tr>");
$("tr#row" + row).append(content);
$("tr#row" + row).append("<td width=\"20%\" bgcolor=\"lightgrey\"><div class=\"road\"></div></td>");
pos = "l";
} else if (pos == "l") {
$("tr#row" + row).append("<td width=\"20%\" bgcolor=\"lightgrey\"><div class=\"road\"></div></td>");
$("tr#row" + row).append(content);
row++;
pos = "r";
}
});
},
error: function(jqXHR, testStatus, errorThrown) {
},
timeout: 120000,
});
5 years ago
setInterval(function () {
jQuery.ajax({
5 years ago
url: server_protocol + "://" + server_ip + ":" + server_port + "/",
5 years ago
type: "GET",
contentType: "application/json; charset=utf-8",
success: function(resultData) {
$.each(resultData, function(key, val) {
console.log(key + " -> " + val);
if (val == "1")
5 years ago
$("div#" + key).removeClass("full").addClass("empty");
5 years ago
else if (val == "0")
5 years ago
$("div#" + key).removeClass("empty").addClass("full");
5 years ago
});
},
error: function(jqXHR, testStatus, errorThrown) {
},
5 years ago
timeout: 120000,
5 years ago
});
}, 1000);
5 years ago
} else {
$("#msg").html("<font color='red'>Something went wrong. Try again</font>");
}
});
});
5 years ago
</script>
<script>
</script>
</head>
<body>
<h1>Parking</h1>
5 years ago
<h3>Server Settings</h3>
5 years ago
<form autocomplete="on">
<table id="tab1">
5 years ago
<tr>
<td>Server Protocol:</td>
<td><select type="text" id="server_protocol">
<option value="https">https</option>
5 years ago
<option value="http">http</option>
5 years ago
<td>
</tr>
5 years ago
<tr>
<td>Server IP:</td>
5 years ago
<td><input type="text" id="server_ip" placeholder="xxx.xxx.xxx.xxx" value="iot-smart-parking.herokuapp.com"/></td>
5 years ago
</tr>
<tr>
<td>Server PORT:</td>
5 years ago
<td><input type="text" id="server_port" placeholder="xxxx" value="443" /></td>
5 years ago
</tr>
<tr>
<td><div id="msg"></div></td>
<td><input type="button" id="approve" value="ok"/></td>
</tr>
</table>
5 years ago
</form>
5 years ago
<h3>Parking Diagram</h3>
5 years ago
<table width="100%" id="tab2">
<!--<tr>
<td id="park4" width="30%">No4<div id="4" class="full"></div></td>
<td width="20%" bgcolor="lightgrey"><div class="road"></div></td>
<td width="20%" bgcolor="lightgrey"><div class="road"></div></td>
<td id="park5" width="30%">No5<div id="5" class="full left"></div></td>
</tr>
<tr>
<td id="park3" width="30%">No3<div id="3" class="full"></div></td>
<td width="20%" bgcolor="lightgrey"><div class="road"></div></td>
<td width="20%" bgcolor="lightgrey"><div class="road"></div></td>
<td id="park6" width="30%">No6<div id="6" class="full left"></div></td>
</tr>
<tr>
<td id="park2" width="30%">No2<div id="2" class="full"></div></td>
<td width="20%" bgcolor="lightgrey"><div class="road"></div></td>
<td width="20%" bgcolor="lightgrey"><div class="road"></div></td>
<td id="park7" width="30%">No7<div id="7" class="full left"></div></td>
</tr>
<tr>
<td id="park1" width="30%">No1<div id="1" class="full"></div></td>
<td width="20%" bgcolor="lightgrey"><div class="road"></div></td>
<td width="20%" bgcolor="lightgrey"><div class="road"></div></td>
<td id="park8" width="30%">No8<div id="8" class="full left"></div></td>
5 years ago
</tr>-->
</table>
</body>
</html>