94 lines
2.9 KiB
HTML
94 lines
2.9 KiB
HTML
{% include "templates/header.html" %}
|
|
|
|
<script type="text/javascript">
|
|
<!--
|
|
function toggle_visibility(id) {
|
|
var e = document.getElementById(id);
|
|
if(e.style.display == 'none')
|
|
e.style.display = 'block';
|
|
else
|
|
e.style.display = 'none';
|
|
}
|
|
//-->
|
|
</script>
|
|
|
|
|
|
<section id="intro">
|
|
<header>
|
|
<h2>Sprinklers!</h2>
|
|
</header>
|
|
<p>Blah blah blah watering. Blah blah rain.</p>
|
|
<img src="/static/images/introimage.png" alt="lime" />
|
|
</section>
|
|
|
|
<div id="content">
|
|
|
|
<form action="">
|
|
<h2><a href="#" onclick="toggle_visibility('sprinklers');">Sprinklers</a></h2>
|
|
<div id="sprinklers">
|
|
{% if sprinklers %}
|
|
{% for sprinkler in sprinklers %}
|
|
<article class="articlecontent" id="sprinkler_{{sprinkler.id}}">
|
|
<header><h3>{{sprinkler.id}}</h3></header>
|
|
<p>
|
|
<strong>Name:</strong> <input type="text" {{sprinkler.id}}_name value="{{ sprinkler.name }}"><br/>
|
|
<strong>Enabled: </strong><input type="checkbox" name="{{sprinkler.id}}_enabled" value="{{sprinkler.enabled}}" {% if sprinkler.enabled %}checked{% endif %}><br/>
|
|
<strong>Master valve: </strong><input type="checkbox" name="{{sprinkler.id}}_master" value="{{sprinkler.isMaster}}"> (Will turn on when any other sprinkler is on)
|
|
</p>
|
|
</article>
|
|
{% endfor %}
|
|
{% else %}
|
|
<p>No active sprinklers were found.</p>
|
|
{% endif %}
|
|
</div>
|
|
</form>
|
|
<article class="articlecontent">
|
|
<p id="demo">Finding location...</p>
|
|
</article>
|
|
<article class="articlecontent">
|
|
<p id="demo2"></p>
|
|
</article>
|
|
</div>
|
|
|
|
<script>
|
|
var x=document.getElementById("demo");
|
|
if (navigator.geolocation)
|
|
{
|
|
navigator.geolocation.getCurrentPosition(showPosition);
|
|
|
|
}
|
|
else{x.innerHTML="Geolocation is not supported by this browser.";}
|
|
|
|
function showPosition(position)
|
|
{
|
|
x.innerHTML="Latitude: " + position.coords.latitude +
|
|
"<br>Longitude: " + position.coords.longitude;
|
|
|
|
var xmlhttp;
|
|
if (window.XMLHttpRequest)
|
|
{// code for IE7+, Firefox, Chrome, Opera, Safari
|
|
xmlhttp=new XMLHttpRequest();
|
|
}
|
|
else
|
|
{// code for IE6, IE5
|
|
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
|
|
}
|
|
xmlhttp.onreadystatechange=function()
|
|
{
|
|
if (xmlhttp.readyState==4 && xmlhttp.status==200)
|
|
{
|
|
document.getElementById("demo2").innerHTML=xmlhttp.responseText;
|
|
}
|
|
}
|
|
document.getElementById("demo2").innerHTML= "Retrieving weather...";
|
|
xmlhttp.open("GET","/weather/ajax?lat=" + position.coords.latitude + "&lon=" + position.coords.longitude,true);
|
|
xmlhttp.send();
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
</body>
|
|
</html>
|