Commit 5765c805 authored by Daniel STAN's avatar Daniel STAN
Browse files

[wifimap] xhtml strict + common.js

parent 47828d72
/*
* Petite compilation de fonctions utiles
* Copyright (C) 2012 Daniel STAN
* Authors: Daniel STAN <daniel.stan@crans.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
function getElementsByClassName(obj, className) {
className = new RegExp(' *' + className + ' ?');
res = [];
function aux(html) {
if( html.nodeType != html.ELEMENT_NODE) return;
if( html.className && html.className.match(className) )
res.push(html);
for( var child=html.firstChild; child; child=child.nextSibling)
{
aux(child)
}
}
aux(obj);
return res;
}
function getInnerText(obj) {
if( obj.nodeType != obj.ELEMENT_NODE) return obj.nodeValue;
var res = '';
for(var child=obj.firstChild; child; child=child.nextSibling)
res += getInnerText(child);
return res;
}
function setInnerText(obj,txt) {
while(obj.firstChild)
obj.removeChild(obj.firstChild);
obj.appendChild(obj.ownerDocument.createTextNode(txt));
}
//Some format
var format_uptime_cases = [['seconde',60],['minute',60],['heure',24],
['jour',365],['an',Infinity]];
function format_uptime(reste) {
var str = '';
var tab = format_uptime_cases;
var i = 0;
while( reste > 0 ) {
lab = reste%tab[i][1];
reste = Math.floor(reste/tab[i][1]);
str = lab + ' ' + tab[i][0] + (lab > 1?'s':'') + ' ' + str;
i++
}
return str;
}
......@@ -19,57 +19,10 @@ var WifiMap;
window.onload = function () { WifiMap.init(); }
//General purpose
function getElementsByClassName(obj, className) {
className = new RegExp(' *' + className + ' ?');
res = [];
function aux(html) {
if( html.nodeType != html.ELEMENT_NODE) return;
if( html.className && html.className.match(className) )
res.push(html);
for( var child=html.firstChild; child; child=child.nextSibling)
{
aux(child)
}
}
aux(obj);
return res;
}
function getInnerText(obj) {
if( obj.nodeType != obj.ELEMENT_NODE) return obj.nodeValue;
var res = '';
for(var child=obj.firstChild; child; child=child.nextSibling)
res += getInnerText(child);
return res;
}
function setInnerText(obj,txt) {
while(obj.firstChild)
obj.removeChild(obj.firstChild);
obj.appendChild(obj.ownerDocument.createTextNode(txt));
}
//Some format
var format_uptime_cases = [['seconde',60],['minute',60],['heure',24],
['jour',365],['an',Infinity]];
function format_uptime(reste) {
var str = '';
var tab = format_uptime_cases;
var i = 0;
while( reste > 0 ) {
lab = reste%tab[i][1];
reste = Math.floor(reste/tab[i][1]);
str = lab + ' ' + tab[i][0] + (lab > 1?'s':'') + ' ' + str;
i++
}
return str;
}
//Wifi map !
WifiMap = {
'init': function() {
this.map = new OpenLayers.Map("map");
this.map = new OpenLayers.Map({'div': 'map','controls':[]});
this.layer = new OpenLayers.Layer.OSM("Campus de Cachan");
//connexions = new OpenLayers.Layer.Vector("Interconnexions");
......@@ -77,10 +30,14 @@ WifiMap = {
'off': new OpenLayers.Layer.Markers("En panne"),
'on': new OpenLayers.Layer.Markers("Fonctionnelle")};
var bornes = {};
this.featureLayer = new OpenLayers.Layer.Vector("Test");
//var markers = new OpenLayers.Layer.Markers("Pointeur");
this.map.addLayers([this.layer]);
this.map.addControl(new OpenLayers.Control.LayerSwitcher());
this.map.addControl(new OpenLayers.Control.Navigation());
this.map.addControl(new OpenLayers.Control.PanZoom());
for( layer in this.bornesLayers ) this.map.addLayer(this.bornesLayers[layer]);
//Placer ces lignes après l'ajout des layers (sic)
......
......@@ -3,6 +3,7 @@
{% block h1 %} <h1>Carte wifi</h1> {% endblock %}
{% block head %}
<link rel="stylesheet" type="text/css" href="/static/css/wifimap.css" />
<script type="text/javascript" src="/static/js/common.js"></script>
<script type="text/javascript" src="/static/OpenLayers/OpenLayers.js"></script>
<script type="text/javascript" src="/static/js/wifimap.js"></script>
{% endblock %}
......@@ -10,7 +11,7 @@
Dernière mise à jour il y a <label id="last_update"> </label>
<div id="toolbar">
<div id="borne_template" class="borne template">
<h3><img src="/static/img/borne.png" alt="[borne wifi]">
<h3><img src="/static/img/borne.png" alt="[borne wifi]" />
<a class="hostname"></a></h3>
<ul>
<li class="comment template">Liste commentaire</li>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment