⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cgi.svn-base

📁 嵌入式无线路由系统openwrt的web配置工具
💻 SVN-BASE
字号:
#!/usr/bin/haserl# Copyright (C) 2008 OpenRB.comcontent-type: text/html/*  Sample module:    Shows list of system interfaces available    Notes:    Call should be wrapped into an anonymous function    This helps to avoid namespace / global variable issues        (function(){      ...    })();*/(function(){  /*    Module id consists of module name and action name    Default action - 'main' is not specified, module id will be equal to module name        Examples:      If module name is 'dchp' and action name is 'status', then module id will be 'dhcp_status'  */  var moduleId = 'interfaces';  /*    Call to FlashSYS.getCache check if there are any cached elements for given module id    If none are found, boolean false is returned    Cache is cleared when window is closed  */  var elems = FlashSYS.getCache(moduleId);  /*    Add this module to periodical reload queue  */  FlashSYS.setReloader(moduleId);  /*    Bonding module requires 'ifenslave' package  */  var hasBonding = FlashSYS.isInstalled('ifenslave');  /*    There are no cached elements, so we need to created them  */  if (!elems) {    /*      Create window with given options, please note:      - returns window content element's reference, if getWindow option is no specified      - width specifies content element's width not window's width      - width is rounded by a factor of 50 to avoid table element width calculation problems    */    var window = FlashSYS.newWindow({      id: moduleId,      title: $TR( moduleId ),      width: 600,      height: 225    });    /*      Create tabs for separate tables    */    var tabs = new FlashSYS.Tabs(window.contentEl, {      tabs: ['ethernet', 'wireless', 'bridge', 'bonding'],      trPrefix: 'interfaces_',      footerEl: window.footerEl    });    /*      Cache table options, they stay the same for now    */    var tableOptions = {      sortable: true,      trPrefix: 'interfaces_',      params: { 'module': 'interfaces', 'action': 'form' },      tableHead: {        'name': { 'width': 15 },        'mac':  { 'width': 20 },        'mtu':  { 'width': 10 },        'txbytes': { 'width': 15, 'axis': 'number', 'callback': formatSize },        'rxbytes': { 'width': 15, 'axis': 'number', 'callback': formatSize },        'errors': { 'width': 15 },        'updown': { 'width': 5, 'blank': true, 'params': { module: 'interfaces', action: 'updown', reload: 'interfaces' } },        'usage': { 'width': 5, 'blank': true, 'params': { module: 'interfaces', action: 'usage', noEncode: true } }      }    };    /*      Create tables with given options, please note:      - width is specied in percents not pixels, so try using round values if possible      - no data is inserted in this step, only table container is created    */    var ethTable = new FlashSYS.Table(tabs.getPanelByIndex(0), tableOptions);    var athTable = new FlashSYS.Table(tabs.getPanelByIndex(1), tableOptions);    var bondPanel = tabs.getPanelByIndex(3);    FlashSYS.Control.addButton(tabs.getFooterByIndex(1), {      'params': { 'module': moduleId, 'action': 'formwifiset' },      'cls': 'Settings',      'title': $TR('interfaces_wifisettings')    });     if (hasBonding) {      var bondTable = new FlashSYS.Table(bondPanel, $merge(tableOptions, {params: {action: 'formbond'}}));      FlashSYS.Control.addButton(tabs.getFooterByIndex(3), {        'params': { 'module': moduleId, 'action': 'formbondset' },        'cls': 'Settings',        'title': $TR('interfaces_bondsettings')      });    }    else {      var bondTable = null;      new Element('h4', {        'class': 'Notice',        'text': $TR('module_not_installed') + ' ifenslave'      }).inject(bondPanel);    }        tableOptions.tableHead.errors['width'] = 10;    tableOptions.tableHead['delete'] = {       'width': 5,      'blank': true,      'confirm': 'del_confirm_bridge',      'params': {        'module': moduleId,        'action': 'delete',        'reload': moduleId      }    };    var brTable = new FlashSYS.Table(tabs.getPanelByIndex(2), tableOptions);    FlashSYS.Control.addButton(tabs.getFooterByIndex(2), {      'params': { 'module': moduleId, 'action': 'form', 'data': { 'new': true, 'bridge': true } },      'cls': 'Add',      'title': $TR('add')    });    /*      Cache data and get cache object back    */    elems = FlashSYS.setCache( moduleId, {      window: window,      tabs: tabs,      ethTable: ethTable,      athTable: athTable,      brTable: brTable,      bondTable: bondTable    });  }  /*    This object will have table row data  */  var tableValues = {    eth: {},    ath: {},    br: {},    bond: {}  };  /*    Iterate through JSON decoded data object  */  var ifInfo = <? if-json -e ?>, iwInfo = <? iw-json ?>, delIcon = { 'cls': 'Icon Delete', 'title': $TR('title_delete') },      upIcon = {'cls': 'Icon UpDown', 'title': $TR('title_active') }, downIcon = {'cls': 'Icon UpDown', 'title': $TR('title_inactive') },      usageIcon = {'cls': 'Icon Usage', 'title': $TR('title_usage') };  $each(ifInfo, function(ifStats, ifName) {    /*      Interface type check, we need only 'Ethernet' ones    */    var matches = ifName.match(/^(eth|ath|br|bond)/);    if (matches === null) {      return;    }        var key = matches[0], ifCls = '';    /*      Show icons for wireless interface mode and status    */     if (key == 'ath' && iwInfo[ ifName ]) {      ifCls = 'WifiIf';      var iwItem = iwInfo[ ifName ];      if (iwItem.mode) {        ifCls += ' Wifi' + iwItem.mode + (iwItem.ap ? 'C' : 'D');      }    }    if (ifStats.up) {      var rowCls = '', statusIcon = upIcon;    }    else {      var rowCls = 'Inactive', statusIcon = downIcon;    }    /*      Convert data to table row data        */    tableValues[ key ][ ifName ] = {      'cls': rowCls,      'cells': [        {'value': ifName, 'cls': ifCls},        ifStats.hw,        ifStats.mtu,        ifStats.txbytes,        ifStats.rxbytes,        ( ifStats.txerr + ' / ' + ifStats.rxerr ),        statusIcon,        usageIcon      ]    }    if (key == 'br') {      tableValues[ key ][ ifName ].cells.push(delIcon);    }  });  /*    Move data into cached table  */  elems.ethTable.loadValues(tableValues['eth']);  elems.athTable.loadValues(tableValues['ath']);  elems.brTable.loadValues(tableValues['br']);  hasBonding ? elems.bondTable.loadValues(tableValues['bond']) : null;})();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -