-
-
Save utkarsh-b690/c7ebedbfe8853083aaa2786ec2ae783a to your computer and use it in GitHub Desktop.
Codes for sublime text. To be saved in the folder "verticel"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$servername = "localhost"; | |
$username = "root"; | |
$password = ""; | |
$database = "verticel"; | |
$conn = new mysqli($servername, $username, $password, $database); | |
if ($conn->connect_error) { | |
die("Could not connect"); | |
} | |
$stmt = "SELECT count(sl_no) FROM elevator_details;"; | |
$result = $conn->query($stmt); | |
$output = $result->fetch_assoc(); | |
echo json_encode($output); | |
$conn-> close(); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$servername = "localhost"; | |
$username = "root"; | |
$password = ""; | |
$database = "verticel"; | |
$conn = new mysqli($servername, $username, $password, $database); | |
if ($conn->connect_error) { | |
die("Could not connect"); | |
} | |
$stmt = $conn-> prepare ("SELECT sl_no FROM elevator_details WHERE lift_name = 'null';"); | |
$stmt-> execute(); | |
$result = $stmt-> get_result(); | |
$output = $result-> fetch_all(MYSQLI_ASSOC); | |
echo json_encode($output); | |
$conn-> close(); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var record_count, old_count = localStorage.getItem("total_records"); | |
if(old_count === null) { | |
old_count = 0; | |
} | |
var xmlhttp = new XMLHttpRequest(); | |
xmlhttp.onreadystatechange = function() { | |
if(this.readyState == 4 && this.status == 200) { | |
var response = JSON.parse(this.responseText); | |
record_count = response["count(sl_no)"]; | |
if (parseInt(old_count,10) < parseInt(record_count,10)) { | |
var xmlhttp2 = new XMLHttpRequest(); | |
xmlhttp2.onreadystatechange = function() { | |
if(this.readyState == 4 && this.status == 200) { | |
var elevators = JSON.parse(this.responseText); | |
while (parseInt(old_count,10) < parseInt(record_count,10)) { | |
var building_name = elevators[old_count].building_name + " - " + elevators[old_count].lift_name; | |
localStorage.setItem("building" + elevators[old_count].sl_no, building_name); | |
localStorage.setItem("floors_up-" + building_name, elevators[old_count].floors_up); | |
localStorage.setItem("floors_ground-" + building_name, elevators[old_count].floors_ground); | |
localStorage.setItem("floors_down-" + building_name, elevators[old_count].floors_down); | |
localStorage.setItem("total_records", elevators[old_count].sl_no); | |
old_count++; | |
} | |
} | |
}; | |
xmlhttp2.open("post", "retrieve_buildings.php", 1); | |
xmlhttp2.send(); | |
} | |
} | |
var xmlhttp3 = new XMLHttpRequest(); | |
xmlhttp3.onreadystatechange = function() { | |
if (this.readyState == 4 && this.status == 200) { | |
var removed_lifts = JSON.parse(this.responseText); | |
for (r in removed_lifts) { | |
var sl_no = removed_lifts[r].sl_no, building_name = localStorage.getItem("building" + sl_no); | |
localStorage.removeItem("floors_up-" + building_name); | |
localStorage.removeItem("floors_down-" + building_name); | |
localStorage.removeItem("floors_ground" + building_name); | |
localStorage.removeItem("building" + sl_no); | |
} | |
} | |
}; | |
xmlhttp3.open("post", "check_removed_lifts.php", 1); | |
xmlhttp3.send(); | |
}; | |
xmlhttp.open("post", "check_record_count.php", 1); | |
xmlhttp.send(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$servername = "localhost"; | |
$username = "root"; | |
$password = ""; | |
$database = "verticel"; | |
$conn = new mysqli($servername, $username, $password, $database); | |
if ($conn->connect_error) { | |
die("Could not connect"); | |
} | |
$stmt = $conn-> prepare('SELECT * FROM elevator_details;'); | |
$stmt-> execute(); | |
$result = $stmt-> get_result(); | |
$output = $result-> fetch_all(MYSQLI_ASSOC); | |
echo json_encode($output); | |
$conn-> close(); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$servername = "localhost"; | |
$username = "root"; | |
$password = ""; | |
$database = "verticel"; | |
$conn = new mysqli($servername, $username, $password, $database); | |
if($conn->connect_error) { | |
die("Could not connect"); | |
} | |
$lift_id = $_GET['buildingName']; | |
$lift_code = $_GET['liftCode']; | |
$stmt = "SELECT api_key, device_name FROM elevator_config WHERE building_name = '".$lift_id."' AND lift_code = '".$lift_code."';"; | |
$result = $conn-> query($stmt); | |
$output = $result-> fetch_assoc(); | |
echo json_encode($output); | |
$conn-> close(); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>VerticEl Elevator Remote</title> | |
<style type="text/css"> | |
* {box-sizing: border-box;} | |
.unscrollable { | |
position: fixed; | |
margin: 0; | |
top: 0; | |
left: 0; | |
right: 0; | |
padding-left: 20px; | |
padding-right: 40px; | |
padding-top: 10px; | |
background-color: #eeeeee; | |
} | |
.scrollable { | |
margin-top: 120px; | |
margin-bottom: 80px; | |
overflow: auto; | |
overscroll-behaviour: contain; | |
} | |
.text{ | |
color: black; | |
font-size: 15px; | |
font-family: "Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif; | |
text-align: left; | |
text-transform: uppercase; | |
} | |
.b_name { | |
width: 100%; | |
margin-bottom: 10px; | |
text-align: left; | |
font-size: 30px; | |
font-family: "Lucida Sans Unicode", "Lucida Grande", Arial, Helvetica, sans-serif; | |
font-weight: bold; | |
border-style: outset; | |
border-color: black; | |
outline: none; | |
border-radius: 15px; | |
padding: 10px; | |
} | |
input[type=button] { | |
width: 100%; | |
text-align: left; | |
font-size: 20px; | |
font-family: "Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif; | |
color: white; | |
background-color: #509dba; | |
border-style: solid; | |
border-color: white; | |
outline: none; | |
padding: 10px; | |
} | |
input[type=button]:hover { | |
width: 100%; | |
text-align: left; | |
font-size: 20px; | |
font-family: "Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif; | |
color: #509dba; | |
background-color: white; | |
border-style: solid; | |
border-color: #509dba; | |
outline: none; | |
padding: 10px; | |
} | |
.r_button { | |
width: 100%; | |
text-align: center; | |
font-size: 15px; | |
font-family: "Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif; | |
color: white; | |
background-color: #9f9f9f; | |
border-style: solid; | |
border-color: #eeeeee; | |
outline: none; | |
padding: 10px; | |
} | |
.r_button:hover { | |
width: 100%; | |
text-align: center; | |
font-size: 15px; | |
font-family: "Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif; | |
color: #656565; | |
background-color: white; | |
border-style: solid; | |
border-color: #656565; | |
outline: none; | |
padding: 10px; | |
} | |
.footer { | |
position: fixed; | |
bottom: 0; | |
left: 0; | |
right: 0; | |
padding: 0; | |
background-color: #eeeeee; | |
} | |
.footer_text{ | |
color: black; | |
font-size: 10px; | |
font-family: "Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif; | |
text-align: center; | |
text-transform: uppercase; | |
} | |
</style> | |
</head> | |
<body> | |
<script type="text/javascript" src="check_updates.js"></script> | |
<form id="building_selection"> | |
<div class="unscrollable"> | |
<label class="text">Type the lift name in the style (Building name - Lift name): </label> | |
<input type="text" class="b_name" id="building" size=50 onkeyup="showBuildings();" autofocus autocomplete="off"> | |
</div> | |
<div class="scrollable" id="building_options"></div> | |
</form> | |
<div class="footer"> | |
<button class="r_button" onclick="location.reload();">Cannot see your building listed? Click here to reload</button> | |
<p class="footer_text">v1.0 BETA, Developed by Utkarsh B</p> | |
</div> | |
<script type="text/javascript" defer> | |
var building_options = document.getElementById("building_options"), search_string, counter, total = parseInt(localStorage.getItem("total_records")); | |
sessionStorage.clear(); | |
function showBuildings() { | |
search_string = String(document.forms["building_selection"]["building"].value); | |
building_options.innerHTML=""; | |
counter = 1; | |
for (counter; counter <= total; counter++) { | |
var current_building = String(localStorage.getItem("building" + counter)); | |
if (current_building != null && search_string !="") { | |
if (current_building.search(RegExp(search_string, "i")) != -1) { | |
building_options.innerHTML += "<input type='button' value='" + current_building + "' onclick=\"buildingSelect(" + counter + ");\">"; | |
} | |
} | |
} | |
} | |
function buildingSelect(value) { | |
sessionStorage.setItem("building_selection", localStorage.getItem("building" + value)); | |
window.open('verticel_page2.php', '_self'); | |
} | |
</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>VerticEl Elevator Remote</title> | |
<style type="text/css"> | |
* {box-sizing: border-box;} | |
.unscrollable { | |
position: fixed; | |
overflow: hidden; | |
margin: 0; | |
top: 0; | |
left: 0; | |
right: 0; | |
padding-left: 20px; | |
padding-right: 40px; | |
padding-top: 10px; | |
background-color: #eeeeee; | |
} | |
.text{ | |
color: black; | |
font-size: 15px; | |
font-family: "Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif; | |
text-align: left; | |
text-transform: uppercase; | |
} | |
.b_button { | |
width: 100%; | |
text-align: center; | |
font-size: 15px; | |
font-family: "Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif; | |
color: white; | |
background-color: #9f9f9f; | |
border-style: solid; | |
border-color: #eeeeee; | |
outline: none; | |
padding: 10px; | |
} | |
.b_button:hover { | |
width: 100%; | |
text-align: center; | |
font-size: 15px; | |
font-family: "Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif; | |
color: #656565; | |
background-color: white; | |
border-style: solid; | |
border-color: #656565; | |
outline: none; | |
padding: 10px; | |
} | |
.column { | |
width: 50%; | |
margin-top: 160px; | |
float: left; | |
padding: 5px; | |
} | |
select { | |
width: 90%; | |
background-color: #509dba; | |
font-size: 20px; | |
font-family: "Lucida Sans Unicode", "Lucida Grande", Arial, Helvetica, sans-serif; | |
font-weight: bold; | |
color: white; | |
text-transform: uppercase; | |
overflow: auto; | |
overflow-x: hidden; | |
} | |
option:hover { | |
width: 100%; | |
background-color: white; | |
font-size: 20px; | |
font-family: "Lucida Sans Unicode", "Lucida Grande", Arial, Helvetica, sans-serif; | |
font-weight: bold; | |
color: #509dba; | |
text-transform: uppercase; | |
overflow: auto; | |
} | |
.code_text { | |
width: 100%; | |
margin-bottom: 10px; | |
text-align: center; | |
font-size: 25px; | |
font-family: "Lucida Sans Unicode", "Lucida Grande", Arial, Helvetica, sans-serif; | |
font-weight: bold; | |
border-style: outset; | |
border-color: black; | |
outline: none; | |
border-radius: 15px; | |
padding: 10px; | |
} | |
.submit_button { | |
width: 100%; | |
text-align: center; | |
font-size: 20px; | |
font-family: "Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif; | |
color: white; | |
background-color: #509dba; | |
border-style: solid; | |
border-color: white; | |
outline: none; | |
padding: 10px; | |
} | |
.submit_button:hover { | |
width: 100%; | |
text-align: center; | |
font-size: 20px; | |
font-family: "Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif; | |
color: #509dba; | |
background-color: white; | |
border-style: solid; | |
border-color: #509dba; | |
outline: none; | |
padding: 10px; | |
} | |
.response { | |
color: black; | |
font-size: 15px; | |
font-family: "Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif; | |
text-align: center; | |
} | |
.footer { | |
position: fixed; | |
bottom: 0; | |
left: 0; | |
right: 0; | |
background-color: #eeeeee; | |
} | |
.footer_text{ | |
color: black; | |
font-size: 10px; | |
font-family: "Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif; | |
text-align: center; | |
text-transform: uppercase; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="unscrollable"> | |
<p class="text" id="building"></p> | |
<button class="b_button" onclick='window.open("verticel.php", "_self");'>Change building details</button><br><br> | |
<p id="floor_from"></p> | |
</div> | |
<form method='post' name='floor_selection'> | |
<div class="column"> | |
<label class="text">Select from floor: </label><br> | |
<label id="from_floor_select"></label><br><br> | |
</div> | |
<div class="column"> | |
<label class="text">Select to floor:</label><br> | |
<label id="to_floor_select"></label><br><br> | |
</div> | |
<div> | |
<label class="text">Enter the code displayed in the floor indicator: </label><br> | |
<input type="number" class="code_text" name="lift_code" min=0 max=999999 required autocomplete="off"> | |
<input type="button" class="submit_button" value="Send command to elevator" onclick="callElevator();"><br><br> | |
</div> | |
</form> | |
<p class="response" id="response"></p><br> | |
<p class="response" id="response2"></p> | |
<div class="footer"> | |
<p class="footer_text">Developed by Utkarsh B</p> | |
</div> | |
<script type="text/javascript" src="https://cloud.boltiot.com/static/js/boltCommands.js"></script> | |
<script type="text/javascript"> | |
var floors_up, floors_ground, floors_down, total_floors, floor_id, building, counter, floor_text = ""; | |
building = sessionStorage.getItem("building_selection"); | |
floors_up = parseInt(localStorage.getItem("floors_up-My First Dummy Building - A1"),10); | |
floors_ground = parseInt(localStorage.getItem("floors_ground-" + building),10); | |
floors_down = parseInt(localStorage.getItem("floors_down-" + building),10); | |
total_floors = floors_up + floors_ground + floors_down; | |
floor_id = total_floors - 1; | |
document.getElementById("building").innerHTML = "The building selected is: " + building; | |
for (counter = floors_up; counter > 0; counter--) { | |
floor_text += "<option value = '" + floor_id-- + "'>" + counter + "</option>"; | |
} | |
switch (floors_ground) { | |
case 0: | |
break; | |
case 1: | |
floor_text += "<option value = '" + floor_id-- + "'>G</option>"; | |
break; | |
case 2: | |
floor_text += "<option value = '" + floor_id-- + "'>UG</option>"; | |
floor_text += "<option value = '" + floor_id-- + "'>LG</option>"; | |
break; | |
default: | |
} | |
for (counter = 1; counter <= floors_down; counter++) { | |
floor_text += "<option value = '" + floor_id-- + "'>B" + counter + "</option>"; | |
} | |
document.getElementById("from_floor_select").innerHTML = "<select name='from_floor' class='selection'>" + floor_text + "</select>"; | |
document.getElementById("to_floor_select").innerHTML = "<select name='to_floor' class='selection'>" + floor_text + "</select>"; | |
</script> | |
<script type="text/javascript"> | |
var response = document.getElementById("response"); | |
var response2 = document.getElementById("response2"); | |
function callElevator() { | |
var from_floor = document.forms["floor_selection"]["from_floor"].value; | |
var to_floor = document.forms["floor_selection"]["to_floor"].value; | |
var lift_code = document.forms["floor_selection"]["lift_code"].value; | |
sessionStorage.setItem("lift_code", lift_code); | |
var xmlhttp = new XMLHttpRequest(); | |
xmlhttp.onreadystatechange = function() { | |
if (this.readyState == 4 && this.status == 200 && this.responseText != "null" && from_floor != to_floor){ | |
var device = JSON.parse(this.responseText); | |
var api_key = device.api_key; | |
var device_name = device.device_name; | |
sessionStorage.setItem("api_key", api_key); | |
sessionStorage.setItem("device_name", device_name); | |
response.innerHTML = ""; | |
data = "C," + from_floor + "," + to_floor; | |
serialWrite(api_key,device_name,data); | |
} | |
else if(from_floor == to_floor) { | |
response.innerHTML = "Please ensure that from floor and to floor are different"; | |
} | |
else if(this.responseText == "null") { | |
response.innerHTML = "Please ensure that lift code matches the displayed code"; | |
} | |
}; | |
xmlhttp.open("post", "search_elevator_device.php?buildingName=" + building + "&liftCode=" + lift_code, 1); | |
xmlhttp.send(); | |
} | |
function serialWrite(api_key,d_name,serialdata) { | |
var xmlhttp = new XMLHttpRequest(); | |
xmlhttp.onreadystatechange = function() { | |
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { | |
var obj = JSON.parse(xmlhttp.responseText); | |
if(obj.success=="1"){ | |
response2.innerHTML = "Command sent successfully"; | |
window.open("verticel_page3.php", "_self"); | |
} | |
else{ | |
response2.innerHTML = "Unable to send command. Device connection failed. Please try again."; | |
} | |
} | |
}; | |
xmlhttp.open("GET",base_url+api_key+"/serialWrite?data="+serialdata+"&deviceName=BOLT"+d_name,true); | |
xmlhttp.send(); | |
} | |
</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Verticel Elevator Remote</title> | |
<style type="text/css"> | |
* {box-sizing: border-box;} | |
.unscrollable { | |
position: fixed; | |
overflow: hidden; | |
margin: 0; | |
top: 0; | |
left: 0; | |
right: 0; | |
padding-left: 20px; | |
padding-right: 40px; | |
padding-top: 10px; | |
background-color: #eeeeee; | |
} | |
.text{ | |
color: black; | |
font-size: 20px; | |
font-family: "Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif; | |
text-align: left; | |
text-transform: uppercase; | |
} | |
.scrollable { | |
margin-top: 180px; | |
margin-bottom: 80px; | |
overflow: auto; | |
overscroll-behaviour: contain; | |
} | |
.button { | |
width: 100%; | |
text-align: center; | |
font-size: 25px; | |
font-family: "Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif; | |
color: white; | |
background-color: #509dba; | |
border-style: solid; | |
border-color: white; | |
outline: none; | |
padding: 10px; | |
} | |
.button:hover { | |
width: 100%; | |
text-align: center; | |
font-size: 25px; | |
font-family: "Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif; | |
color: #509dba; | |
background-color: white; | |
border-style: solid; | |
border-color: #509dba; | |
outline: none; | |
padding: 10px; | |
} | |
.response{ | |
color: black; | |
font-size: 25px; | |
font-weight: normal; | |
font-family: "Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif; | |
text-align: center; | |
} | |
.footer { | |
position: fixed; | |
bottom: 0; | |
left: 0; | |
right: 0; | |
background-color: #eeeeee; | |
} | |
.footer_text{ | |
color: black; | |
font-size: 10px; | |
font-family: "Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif; | |
text-align: center; | |
text-transform: uppercase; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="unscrollable"> | |
<p>The elevator currently connected is:</p> | |
<p class="text" id="elevator_connected"></p><br><br> | |
</div> | |
<form> | |
<div class="scrollable"> | |
<input type="button" class="button" onclick="holdElevator();" value="Hold door"><br><br> | |
<input type="button" class="button" onclick="goToMainPage();" value="Go to main page"><br><br> | |
</div> | |
</form> | |
<p class="response" id="response"></p> | |
<p class="response" id="remaining_attempts"></p> | |
<div class="footer"> | |
<p class="footer_text">Developed by Utkarsh B</p> | |
</div> | |
<script type="text/javascript" src="https://cloud.boltiot.com/static/js/boltCommands.js"></script> | |
<script type="text/javascript"> | |
var api_key = sessionStorage.getItem("api_key"), device_name = sessionStorage.getItem("device_name"), attempts = 3, counter=0; | |
var elevator_connected = document.getElementById("elevator_connected"); | |
var response = document.getElementById("response"); | |
var attempts_text = document.getElementById("remaining_attempts"); | |
var base_url = "https://cloud.boltiot.com/remote/"; | |
elevator_connected.innerHTML += sessionStorage.getItem("building_selection"); | |
function holdElevator(){ | |
if (attempts > 1) { | |
attempts--; | |
attempts_text.innerHTML = "Door hold command sent " + attempts + " attempts remaining"; | |
var data = "H"; | |
serialWrite(api_key,device_name,data); | |
} | |
else { | |
goToMainPage(); | |
} | |
} | |
function goToMainPage() { | |
window.open("verticel.php", "_self"); | |
sessionStorage.clear(); | |
} | |
function serialWrite(api_key,d_name,serialdata) { | |
var xmlhttp = new XMLHttpRequest(); | |
xmlhttp.onreadystatechange = function() { | |
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { | |
var obj = JSON.parse(xmlhttp.responseText); | |
if(obj.success=="1"){ | |
response.innerHTML = "Command sent successfully"; | |
} | |
else{ | |
response.innerHTML = "Unable to send command. Device connection failed. Please try again."; | |
} | |
} | |
}; | |
xmlhttp.open("GET",base_url+api_key+"/serialWrite?data="+serialdata+"&deviceName=BOLT"+d_name,true); | |
xmlhttp.send(); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment