}
};
+ this.firewall = {
+ getZoneColor: function(zone)
+ {
+ if ($.isPlainObject(zone))
+ zone = zone.name;
+
+ if (zone == 'lan')
+ return '#90f090';
+ else if (zone == 'wan')
+ return '#f09090';
+
+ for (var i = 0, hash = 0;
+ i < zone.length;
+ hash = zone.charCodeAt(i++) + ((hash << 5) - hash));
+
+ for (var i = 0, color = '#';
+ i < 3;
+ color += ('00' + ((hash >> i++ * 8) & 0xFF).tozoneing(16)).slice(-2));
+
+ return color;
+ },
+
+ findZoneByNetwork: function(network)
+ {
+ var self = this;
+ var zone = undefined;
+
+ return _luci2.uci.foreach('firewall', 'zone', function(z) {
+ if (!z.name || !z.network)
+ return;
+
+ if (!$.isArray(z.network))
+ z.network = z.network.split(/\s+/);
+
+ for (var i = 0; i < z.network.length; i++)
+ {
+ if (z.network[i] == network)
+ {
+ zone = z;
+ break;
+ }
+ }
+ }).then(function() {
+ if (zone)
+ zone.color = self.getZoneColor(zone);
+
+ return zone;
+ });
+ }
+ };
+
this.system = {
getSystemInfo: _luci2.rpc.declare({
object: 'system',
.append(_luci2.globals.mainMenu.render(2, 900));
},
- renderView: function(node)
+ renderView: function()
{
+ var node = arguments[0];
var name = node.view.split(/\//).join('.');
+ var args = [ ];
+
+ for (var i = 1; i < arguments.length; i++)
+ args.push(arguments[i]);
if (_luci2.globals.currentView)
_luci2.globals.currentView.finish();
if (_luci2._views[name] instanceof _luci2.ui.view)
{
_luci2.globals.currentView = _luci2._views[name];
- return _luci2._views[name].render();
+ return _luci2._views[name].render.apply(_luci2._views[name], args);
}
var url = _luci2.globals.resource + '/view/' + name + '.js';
});
_luci2.globals.currentView = _luci2._views[name];
- return _luci2._views[name].render();
+ return _luci2._views[name].render.apply(_luci2._views[name], args);
}
catch(e) {
alert('Unable to instantiate view "%s": %s'.format(url, e));
insertInto: function(id) {
return $(id).empty().append(this.render());
+ },
+
+ appendTo: function(id) {
+ return $(id).append(this.render());
}
});
container.append($('<div />').addClass('cbi-map-descr').append(this.description));
var self = this;
+ var args = [ ];
+
+ for (var i = 0; i < arguments.length; i++)
+ args.push(arguments[i]);
+
return this._fetch_template().then(function() {
- return _luci2.deferrable(self.execute());
+ return _luci2.deferrable(self.execute.apply(self, args));
});
},
var setTimer, runTimer;
setTimer = function() {
- self._timeouts[index] = window.setTimeout(runTimer, interval);
+ if (self._timeouts)
+ self._timeouts[index] = window.setTimeout(runTimer, interval);
};
runTimer = function() {
- _luci2.deferrable(func.call(self)).then(setTimer);
+ _luci2.deferrable(func.call(self)).then(setTimer, setTimer);
};
runTimer();