luci2: remove dead code from LuCI2.cbi.Map()
[project/luci2/ui.git] / luci2 / htdocs / luci2 / luci2.js
index 94bd4b0..ffa58ea 100644 (file)
@@ -387,7 +387,7 @@ function LuCI2()
        };
 
        this.globals = {
        };
 
        this.globals = {
-               timeout:  3000,
+               timeout:  15000,
                resource: '/luci2',
                sid:      '00000000000000000000000000000000'
        };
                resource: '/luci2',
                sid:      '00000000000000000000000000000000'
        };
@@ -977,6 +977,42 @@ function LuCI2()
                        method: 'switch_status',
                        params: [ 'switch' ],
                        expect: { ports: [ ] }
                        method: 'switch_status',
                        params: [ 'switch' ],
                        expect: { ports: [ ] }
+               }),
+
+
+               runPing: _luci2.rpc.declare({
+                       object: 'luci2.network',
+                       method: 'ping',
+                       params: [ 'data' ],
+                       expect: { '': { code: -1 } }
+               }),
+
+               runPing6: _luci2.rpc.declare({
+                       object: 'luci2.network',
+                       method: 'ping6',
+                       params: [ 'data' ],
+                       expect: { '': { code: -1 } }
+               }),
+
+               runTraceroute: _luci2.rpc.declare({
+                       object: 'luci2.network',
+                       method: 'traceroute',
+                       params: [ 'data' ],
+                       expect: { '': { code: -1 } }
+               }),
+
+               runTraceroute6: _luci2.rpc.declare({
+                       object: 'luci2.network',
+                       method: 'traceroute6',
+                       params: [ 'data' ],
+                       expect: { '': { code: -1 } }
+               }),
+
+               runNslookup: _luci2.rpc.declare({
+                       object: 'luci2.network',
+                       method: 'nslookup',
+                       params: [ 'data' ],
+                       expect: { '': { code: -1 } }
                })
        };
 
                })
        };
 
@@ -2068,6 +2104,9 @@ function LuCI2()
                {
                        var name = node.view.split(/\//).join('.');
 
                {
                        var name = node.view.split(/\//).join('.');
 
+                       if (_luci2.globals.currentView)
+                               _luci2.globals.currentView.finish();
+
                        _luci2.ui.renderViewMenu();
 
                        if (!_luci2._views)
                        _luci2.ui.renderViewMenu();
 
                        if (!_luci2._views)
@@ -2076,7 +2115,10 @@ function LuCI2()
                        _luci2.setHash('view', node.view);
 
                        if (_luci2._views[name] instanceof _luci2.ui.view)
                        _luci2.setHash('view', node.view);
 
                        if (_luci2._views[name] instanceof _luci2.ui.view)
+                       {
+                               _luci2.globals.currentView = _luci2._views[name];
                                return _luci2._views[name].render();
                                return _luci2._views[name].render();
+                       }
 
                        var url = _luci2.globals.resource + '/view/' + name + '.js';
 
 
                        var url = _luci2.globals.resource + '/view/' + name + '.js';
 
@@ -2100,6 +2142,7 @@ function LuCI2()
                                                acls: node.write || { }
                                        });
 
                                                acls: node.write || { }
                                        });
 
+                                       _luci2.globals.currentView = _luci2._views[name];
                                        return _luci2._views[name].render();
                                }
                                catch(e) {
                                        return _luci2._views[name].render();
                                }
                                catch(e) {
@@ -2280,6 +2323,42 @@ function LuCI2()
                        return this._fetch_template().then(function() {
                                return _luci2.deferrable(self.execute());
                        });
                        return this._fetch_template().then(function() {
                                return _luci2.deferrable(self.execute());
                        });
+               },
+
+               repeat: function(func, interval)
+               {
+                       var self = this;
+
+                       if (!self._timeouts)
+                               self._timeouts = [ ];
+
+                       var index = self._timeouts.length;
+
+                       if (typeof(interval) != 'number')
+                               interval = 5000;
+
+                       var setTimer, runTimer;
+
+                       setTimer = function() {
+                               self._timeouts[index] = window.setTimeout(runTimer, interval);
+                       };
+
+                       runTimer = function() {
+                               _luci2.deferrable(func.call(self)).then(setTimer);
+                       };
+
+                       runTimer();
+               },
+
+               finish: function()
+               {
+                       if ($.isArray(this._timeouts))
+                       {
+                               for (var i = 0; i < this._timeouts.length; i++)
+                                       window.clearTimeout(this._timeouts[i]);
+
+                               delete this._timeouts;
+                       }
                }
        });
 
                }
        });
 
@@ -2333,7 +2412,10 @@ function LuCI2()
                                var child = this.firstChildView(nodes[i]);
                                if (child)
                                {
                                var child = this.firstChildView(nodes[i]);
                                if (child)
                                {
-                                       $.extend(node, child);
+                                       for (var key in child)
+                                               if (!node.hasOwnProperty(key) && child.hasOwnProperty(key))
+                                                       node[key] = child[key];
+
                                        return node;
                                }
                        }
                                        return node;
                                }
                        }
@@ -2618,7 +2700,9 @@ function LuCI2()
        this.ui.devicebadge = AbstractWidget.extend({
                render: function()
                {
        this.ui.devicebadge = AbstractWidget.extend({
                render: function()
                {
-                       var dev = this.options.l3_device || this.options.device || '?';
+                       var l2dev = this.options.l2_device || this.options.device;
+                       var l3dev = this.options.l3_device;
+                       var dev = l3dev || l2dev || '?';
 
                        var span = document.createElement('span');
                                span.className = 'ifacebadge';
 
                        var span = document.createElement('span');
                                span.className = 'ifacebadge';
@@ -2659,7 +2743,7 @@ function LuCI2()
                                var type = 'ethernet';
                                var desc = _luci2.tr('Ethernet device');
 
                                var type = 'ethernet';
                                var desc = _luci2.tr('Ethernet device');
 
-                               if (this.options.l3_device != this.options.device)
+                               if (l3dev != l2dev)
                                {
                                        type = 'tunnel';
                                        desc = _luci2.tr('Tunnel interface');
                                {
                                        type = 'tunnel';
                                        desc = _luci2.tr('Tunnel interface');
@@ -2909,6 +2993,7 @@ function LuCI2()
                                }
                        }
 
                                }
                        }
 
+                       validation.i18n('Must be a valid IPv6 address');
                        return false;
                },
 
                        return false;
                },
 
@@ -5558,33 +5643,6 @@ function LuCI2()
                        });
                },
 
                        });
                },
 
-               dialog: function(id)
-               {
-                       var d = $('<div />');
-                       var p = $('<p />');
-
-                       $('<img />')
-                               .attr('src', _luci2.globals.resource + '/icons/loading.gif')
-                               .css('vertical-align', 'middle')
-                               .css('padding-right', '10px')
-                               .appendTo(p);
-
-                       p.append(_luci2.tr('Loading data...'));
-
-                       p.appendTo(d);
-                       d.appendTo(id);
-
-                       return d.dialog({
-                               modal: true,
-                               draggable: false,
-                               resizable: false,
-                               height: 90,
-                               open: function() {
-                                       $(this).parent().children('.ui-dialog-titlebar').hide();
-                               }
-                       });
-               },
-
                insertInto: function(id)
                {
                        var self = this;
                insertInto: function(id)
                {
                        var self = this;