This fixes errors reported by LGTM.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
var $chars = 'abcdefghijklmnopqrstuvwxyz1234567890';
var maxPos = $chars.length;
var pwd = '';
- for (i = 0; i < len; i++) {
+ for (var i = 0; i < len; i++) {
pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
}
return pwd;
var newTextNode = document.getElementById("aria2rpcpath");
var auth_method = document.getElementById("cbid.aria2.main.rpc_auth_method");
var auth_port = document.getElementById("cbid.aria2.main.rpc_listen_port");
+ var auth_port_value;
if (auth_port.value == "") {
auth_port_value = "6800"
} else {
$("#server").className = '';
$("#server").onclick = null;
- button_set = document.createElement("input");
+ var button_set = document.createElement("input");
button_set.type = "button";
button_set.value = "Save";
button_set.name = "button_set";
request_data.id = ubus_counter;
request_data.method = "call";
request_data.params = [ data.ubus_rpc_session, command, argument, params ]
- request_json = JSON.stringify(request_data)
+ var request_json = JSON.stringify(request_data)
ubus_counter++;
var request = new XMLHttpRequest();
request.open("POST", ubus_url, true);
}
if(request_json.upgrades != undefined) {
info_output += "<h3>Package upgrades available</h3>"
- for (upgrade in request_json.upgrades) {
+ for (var upgrade in request_json.upgrades) {
info_output += "<b>" + upgrade + "</b>: " + request_json.upgrades[upgrade][1] + " to " + request_json.upgrades[upgrade][0] + "<br />"
}
}
var filename_split = data.sysupgrade_url.split("/")
data.filename = filename_split[filename_split.length - 1]
- info_output = 'Firmware created: <a href="' + data.sysupgrade_url + '"><b>' + data.filename + '</b></a>'
+ var info_output = 'Firmware created: <a href="' + data.sysupgrade_url + '"><b>' + data.filename + '</b></a>'
if(data.advanced_mode == 1) {
info_output += '<br /><a target="_blank" href="' + data.sysupgrade_url + '.log">Build log</a>'
}
}
function server_request(request_dict, path, callback) {
+ var request_json;
request_dict.distro = data.release.distribution;
request_dict.target = data.release.target.split("\/")[0];
request_dict.subtarget = data.release.target.split("\/")[1];
show("#server_div");
}
request.addEventListener('load', function(event) {
- request_text = request.responseText;
+ var request_text = request.responseText;
if (request.status === 200) {
callback(request_text)
} else if (request.status === 500) {
request_json = JSON.parse(request_text)
- error_box_content = "<b>Internal server error</b><br />"
+ var error_box_content = "<b>Internal server error</b><br />"
error_box_content += request_json.error
if(request_json.log != undefined) {
data.log_url = request_json.log
// called by XHR.poll and onclick_startstop
function _data2elements(data) {
// Service sections
- for( i = 1; i < data.length; i++ )
+ for( var i = 1; i < data.length; i++ )
{
var section = data[i].section // Section to handle
var cbx = document.getElementById("cbid.ddns." + section + ".enabled"); // Enabled
if (x.responseText == "_uncommitted_") {
// we need a trick to display Ampersand "&" in stead of "&" or "&"
// after translation
- txt="<%:Please [Save & Apply] your changes first%>";
+ var txt="<%:Please [Save & Apply] your changes first%>";
alert( txt.replace(new RegExp("<%:&%>", "g"), "&") );
} else {
// should have data because status changed
'<a class="cbi-button cbi-button-action important" type="button" href="' + data[0].url_up + '"><%:enable here%></a></strong>'
]);
} else {
- for( j = 1; j < data.length; j++ )
+ for(var j = 1; j < data.length; j++ )
{
rows.push([
</div>
</div>
</fieldset>
-<!-- ++ END ++ Dynamic DNS ++ system_status.htm ++ -->
\ No newline at end of file
+<!-- ++ END ++ Dynamic DNS ++ system_status.htm ++ -->
return "";
}
- x = this.n1.x*scale;
- y = this.n1.y*scale;
- dx = this.n2.x*scale - x;
- dy = this.n2.y*scale - y;
+ var x = this.n1.x*scale;
+ var y = this.n1.y*scale;
+ var dx = this.n2.x*scale - x;
+ var dy = this.n2.y*scale - y;
x += xoff*scale + 75;
y += yoff*scale + 15;
- imgtag = "<img src='/luci-static/resources/olsr-viz/dot_"
+ var imgtag = "<img src='/luci-static/resources/olsr-viz/dot_"
if (this.etx > 0 && this.etx < 2) {
imgtag += "good.gif'";
}
}
imgtag += " alt='ETX: " + this.etx + "' title='ETX: " + this.etx + "' ";
- d = Math.sqrt(dx*dx+dy*dy);
+ var d = Math.sqrt(dx*dx+dy*dy);
- for (j = 0; j < d; j += 15) {
+ for (var j = 0; j < d; j += 15) {
nh += imgtag + "style='top:"
+ parseInt(y+dy * j / d) + "px; left:"
+ parseInt(x+dx * j / d) + "px; "
function getEdgeKey(ip1,ip2)
{
- key = "";
+ var key = "";
if(ip1 > ip2) {
key = ip2 + "-" + ip1;
}
return "";
}
var igw = 0;
- for(h in this.hna) {
+ for(var h in this.hna) {
if(h == "0.0.0.0") {
igw = 1;
break;
}
function touch_node(ip) {
- n = nodes[ip];
+ var n = nodes[ip];
if(!n) {
n = new node(ip);
nodes[ip] = n;
function place_new_nodes() {
var nc = 0;
- for(i = 0;i<newnodes.length;i++){
- n = newnodes[i];
+ for(var i = 0;i<newnodes.length;i++){
+ var n = newnodes[i];
if(n.placed){continue;}
+ var sp;
if(sp = getCookie("node_"+n.ip)) {
- xy = sp.split("x");
+ var xy = sp.split("x");
debug_writeln("sp: "+sp+" xy[0]: "+xy[0]+" xy[1]: "+xy[1]);
n.x = parseFloat(xy[0]);
n.y = parseFloat(xy[1]);
}
else if(n.weight>1){
- // see if we find allredy placed nodes
- ox=0,oy=0;dx=0,dy=0;c=0;
- for(e in n.edges){
+ // see if we find already placed nodes
+ var ox=0, oy=0;
+ var dx=0, dy=0;
+ var c=0;
+ for(var e in n.edges){
if(nodes[e] && nodes[e].placed){
if(!ox && !oy) {
ox = nodes[e].x;
}
function touch_hna(node,net,mask) {
- h = node.hna[net];
+ var h = node.hna[net];
if(!h) {
h = new hna(node.ip,net,mask);
node.hna[net] = h;
edgediv=document.getElementById(edgedivid);
// autosave on exit?
+ var autosave;
if((autosave = getCookie("prefs_autosave"))) {
auto_save = parseInt(autosave);
}
viz_autosave(auto_save);
// maximum metric of surrounding nodes
+ var mmx;
if(mmx = getCookie("prefs_maxmetric")) {
set_maxmetric(mmx,true,true);
}
// scale of view
+ var savescale;
if((savescale = getCookie("prefs_scale")) &&
(savescale = parseFloat(savescale))) {
set_scale(savescale,true);
function viz_save()
{
// let cookie survive a month
- exp = new Date();
+ var exp = new Date();
exp.setTime(exp.getTime() + 2592000000);
// save node positions
- for(ip in nodes)
+ for(var ip in nodes)
{
if(nodes[ip].metric > maxmetric) {
continue;
function viz_reset()
{
deleteAllCookies();
- for(ip in nodes) {
+ for(var ip in nodes) {
delete nodes[ip];
}
- for(e in edges) {
+ for(var e in edges) {
delete edges[e];
}
viz_update();
var dclTimer = 0;
var declump_running = false;
function declump(t) {
+ var dx;
+ var dy;
+ var d;
+
// clear declump timer
if(dclTimer) {
clearTimeout(dclTimer);
declump_running = true;
// nodes
- nc = 0;
+ var nc = 0;
for (var ip1 in nodes) {
nodes[ip1].fr_x=0;
nodes[ip1].fr_y=0;
if(nodes[ip1].metric > maxmetric || nodes[ip1].pinned) {
continue;
}
- for (ip2 in nodes) {
+ for (var ip2 in nodes) {
if (nodes[ip2].metric > maxmetric || ip1 == ip2) {
continue;
}
dx = nodes[ip1].fr_x;
dy = nodes[ip1].fr_y;
d = Math.sqrt(dx*dx+dy*dy);
- md = Math.min(d,iel/nodes[ip1].weight);
+ var md = Math.min(d,iel/nodes[ip1].weight);
nodes[ip1].x_next += (dx / d) * md;
nodes[ip1].y_next += (dy / d) * md;
nc++;
}
// edges
- ec = 0;
+ var ec = 0;
for (var e in edges) {
if (!edges[e].n1 || !edges[e].n2 ||
edges[e].n1.metric > maxmetric || edges[e].n2.metric > maxmetric) {
}
// displacement
- xmin=-20;ymin=-20;xmax=20;ymax=20;dsum=0;
+ var xmin=-20;
+ var ymin=-20;
+ var xmax=20;
+ var ymax=20;
+ var dsum=0;
for (var ip in nodes) {
if(nodes[ip].metric > maxmetric || nodes[ip].pinned) {
continue;
dragx = posx - element.offsetLeft;
dragy = posy - element.offsetTop;
- n = nodes[dragip];
+ var n = nodes[dragip];
if(n) {
n.pinned = true;
}
function dragstop() {
//Wird aufgerufen, wenn ein Objekt nicht mehr bewegt werden soll.
- n = nodes[dragip];
+ var n = nodes[dragip];
if(n) {
n.pinned = false;
}
posx = document.all ? window.event.clientX : ereignis.pageX;
posy = document.all ? window.event.clientY : ereignis.pageY;
if(dragip != null) {
- n = nodes[dragip];
+ var n = nodes[dragip];
if(n) {
n.x = (posx - dragx)/scale - xoff;
n.y = (posy - dragy)/scale - yoff;
}
- e = document.getElementById('node_'+dragip);
+ var e = document.getElementById('node_'+dragip);
e.style.left = parseInt((n.x+xoff)*scale) + "px";
e.style.top = parseInt((n.y+yoff)*scale) + "px";
}
}
function deleteAllCookies() {
- cookies = document.cookie.split("; ");
- for(i=0;i<cookies.length;i++) {
+ var cookies = document.cookie.split("; ");
+ for(var i=0;i<cookies.length;i++) {
deleteCookie(cookies[i].split("=")[0]);
}
}
}
window.onload = function() {
- buttons = '<input type="button" name="show-proto-4" id="show-proto-4" class="cbi-button cbi-button-apply" style="margin-right: 5px" value="<%:Hide IPv4%>">'
+ var buttons = '<input type="button" name="show-proto-4" id="show-proto-4" class="cbi-button cbi-button-apply" style="margin-right: 5px" value="<%:Hide IPv4%>">'
buttons += '<input type="button" name="show-proto-6" id="show-proto-6" class="cbi-button cbi-button-apply" value="<%:Hide IPv6%>">'
document.getElementById('togglebuttons').innerHTML = buttons;
linkgw = '<a href="http://' + hna.gateway + '/cgi-bin-status.html">' + hna.gateway + '</a>'
}
+ var validity;
if (hna.validityTime != undefined) {
validity = hna.validityTime + 's'
} else {
validity = '-'
}
+ var hostname;
if (hna.hostname != undefined) {
hostname = ' / <a href="http://' + hna.hostname + '/cgi-bin-status.html">' + hna.hostname + '</a>'
} else {
for (var idx = 0; idx < info.length; idx++)
{
var smartgw = info[idx];
+ var linkgw;
s += '<div class="tr cbi-section-table-row cbi-rowstyle-'+(1 + (idx % 2))+' proto-' + smartgw.proto + '">'
if (smartgw.proto == '6') {
linkgw = '<a href="http://[' + smartgw.ipAddress + ']/cgi-bin-status.html">' + smartgw.ipAddress + '</a>'
cbi_dropdown_init.prototype = CBIDropdown;
function cbi_update_table(table, data, placeholder) {
- target = isElem(table) ? table : document.querySelector(table);
+ var target = isElem(table) ? table : document.querySelector(table);
if (!isElem(target))
return;
trigger: function(e) {
var lonlat = map.getLonLatFromViewPortPx(e.xy);
- lat=merc2lat(lonlat.lat);
- lon=merc2lon(lonlat.lon);
+ var lat=merc2lat(lonlat.lat);
+ var lon=merc2lon(lonlat.lon);
if(parent.document.getElementById(latfield_id)==null){
latfield=document.getElementById('osmlat');
}else{
function drawmap() {
OpenLayers.Lang.setCode('de');
- mapdiv=document.getElementById('map');
+ var mapdiv=document.getElementById('map');
mapdiv.style.height=window.innerHeight+"px";
mapdiv.style.width=window.innerWidth+"px";
map = new OpenLayers.Map('map', {
var label_rate_peak;
var label_scale;
+ var label_scale_2;
/* wait for SVG */
var nodeUrl = "";
(function(node){
+ var luciLocation;
if (node[0] == "admin"){
luciLocation = [node[1], node[2]];
}else{