-
Notifications
You must be signed in to change notification settings - Fork 1
/
visor.php
153 lines (122 loc) · 3.93 KB
/
visor.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?php
$file = file_get_contents("http://10.30.61.100");
file_put_contents("seed.txt", $file);
?>
<!DOCTYPE html>
<!-- Template by quackit.com -->
<html>
<?php include "head.php"; ?>
<body>
<header id="header">
<h1>MeM</h1>
<p class="tagline">Modular Emergency Mesh Project</p>
</header>
<nav id="nav">
<h2>Portal Access</h2>
<ul>
<li><a href="#">Sensors</a></li>
<li><a href="#">Chat</a></li>
<li><a href="#">Node</a></li>
<li><a href="#">Notice</a></li>
</ul>
<h2>Node Access</h2>
<ul>
<li><a href="http://10.30.235.1">Node 1</a></li>
<li><a href="http://10.30.42.1">Node 2</a></li>
<li><a href="http://10.30.165.1/">Node 3</a></li>
<li><a href="http://10.30.235.100">Sensor 1</a></li>
<li><a href="http://10.30.165.100">Sensor 2</a></li>
</ul>
</nav>
<div id="main">
<?php
include "db-connection.php";
$fh = fopen('seed.txt','r');
$cleanquery = "DELETE FROM mesh_redport.sensores WHERE DATE_FORMAT(STR_TO_DATE(fecha, '%d/%m/%Y'), '%Y-%m-%d') < DATE_SUB(NOW(), INTERVAL 10 DAY)";
$resultado = mysql_query($cleanquery, $enlace);
while ($lines = fgets($fh)) {
// <... Do your work with the line ...>
$line = explode(" ", $lines);
foreach ($line as &$valor) {
echo $valor."<br>";
$valores = explode(":", $valor);
$sqltemp = 'INSERT INTO sensores (tipo, valor, fecha) VALUES("'.$valores[0].'","'.$valores[1].'","'.date("d/m/Y H:i:s").'")';
$resultado = mysql_query($sqltemp, $enlace);
}
}
fclose($fh);
?>
<div id="lights" class='cf'>
<h2>Node 1: Light Control</h2>
<dir id="module-1">
<div class="led-control">
<label>Blink rate</label>
<input type="range" id="rangered" min="0" max="255" value="0">
</div>
<div class="led-control">
<label>Light 1</label>
<input type="range" id="rangegreen" min="0" max="255" value="0">
</div>
<div class="led-control">
<label>Light 2</label>
<input type="range" id="rangeblue" min="0" max="255" value="0">
</div>
</div>
<script>
$("#main").click(function () {
/*$("#main").load(location.href + " #lights");
alert("hi");*/
});
</script>
<!--<button id="mod1-send">send</button>-->
</dir>
</div>
</div>
<footer id="footer">
<div class="innertube">
<p>fabAcademy 2016 - Fablab Santiago - Modular Emergency Mesh MeM</p>
</div>
</footer>
</body>
<script type="text/javascript">
var red = 0;
var green = 0;
var blue = 0;
//Bindeo los elementos range.
// RED
$('#rangered').change(function(){
red = $(this).val();
//console.log(red);
updateColor();
});
// GREEN
$('#rangegreen').change(function(){
green = $(this).val();
//console.log(green);
updateColor();
});
// BLUE
$('#rangeblue').change(function(){
blue = $(this).val();
//console.log(blue);
updateColor();
});
function updateColor(){
alert("paso1");
var rgbColor = "rgb("+red.toString()+","+green.toString()+","+blue.toString()+")";
alert("paso2");
//console.log("rgbColor = "+rgbColor);
$('#mod1-light').css("background-color",rgbColor);
alert("paso3");
var colorURL = "rgb="+("00" + red).slice(-3)+("00" + green).slice(-3)+("00" + blue).slice(-3);
alert("paso4");
//console.log("colorURL="+colorURL);
var lightIP = "http://10.30.61.201/";
alert("paso5");
$.get(lightIP+colorURL);
$("#main").load(location.href + " #lights");
alert("paso6");
//console.log(lightIP+colorURL);
}
</script>
</html>