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

📄 core.js.svn-base

📁 嵌入式无线路由系统openwrt的web配置工具
💻 SVN-BASE
📖 第 1 页 / 共 2 页
字号:
  Arguments:    moduleId - (string) module-action id  */  loadFinished: function(moduleId) {    // remove module from loading modules cache    this.loadingModules.erase(moduleId);    // block was set by this module - remove it    if (this.loadBlock === moduleId) {      this.loadBlock = '';    }  },  /*  Function: initMenu    Initialize drop-down menu with modules / sections  Arguments:    container - (element or id) drop-down menu container  */  initMenu: function(container) {    var menuUl = new Element('ul').inject($(container));    // add all sections    for (section in this.menu) {      var modules = this.menu[ section ];      var menuLi = new Element('li').inject(menuUl);      new Element('a', {        'text': this.translate(section),        'href': '#',        'events': {          'click': $lambda(false)        }      }).inject(menuLi);      // create submenu list and cache container      var subMenuUl = new Element('ul').inject(menuLi);      this.menuSections[ section ] = subMenuUl;      // go through array of modules, add only core modules      for (module in modules) {        if (modules[ module ] === true || modules[ module ].core) {          this.addMenuItem(section, module);        }      }    }    // load extra modules    this.loadMenuExtra();  },  /*  Function: loadMenuExtra    Load currently installed module list  */  loadMenuExtra: function() {    this.load({      'module': 'utils',      'action': 'extramodules'    });  },  /*  Function: initMenuExtra    Add/remove menu items marked as 'extra'  Arguments:    extraModules - (object) list of currently available modules  */  initMenuExtra: function(extraModules) {    this.extraModules = extraModules;    // check modules in every section    for (section in this.menu) {      var modules = this.menu[ section ];      // check every module      for (module in modules) {        // module requires extra check        var moduleCheck = modules[ module ], moduleName = module;        if ($type(moduleCheck) == 'string') {          moduleName = moduleCheck;          moduleCheck = false;        }        if (moduleCheck === false) {          // is installed, add new menu item if required          if (this.extraModules[ moduleName ] === true) {            this.addMenuItem(section, module);          }          // not installed or removed, make sure menu item is gone          else {            this.removeMenuItem(module);          }        }      }    }  },  /*  Function: isInstalled    Checks if given module is installed  Arguments:    moduleName - (string) name of the module to check  */  isInstalled: function(moduleName) {    return (this.extraModules[ moduleName ] === true);  },  /*  Function: addMenuItem    Add new menu item  Arguments:    section - (string) section name    module - (string or object) module to be added  */  addMenuItem: function(section, moduleName) {    var subMenuUl = this.menuSections[ section ];    // non-existing section specified    if (!subMenuUl) {      return;    }    var module = this.menu[ section ][ moduleName ];    // menu item's already there    if (this.menuItems[ moduleName ]) {      return;    }    var subMenuLi = new Element('li').inject(subMenuUl), clickFn = null;    // object passed - check extra options    if ($type(module) == 'object') {      moduleName = module.name ? module.name : moduleName;      // custom function to execute      if (module.exec) {        clickFn = module.exec;      }      // default load action      else {        clickFn = this.load.bind(this, $merge({'module': module.name, 'retFalse': true}, module.params));      }    }    // string passed - only module name    else {      clickFn = this.load.bind(this, {'module': moduleName, 'retFalse': true});    }    new Element('a', {      'text': this.translate(moduleName),      'href': '#',      'events': {        'click': clickFn      }    }).inject(subMenuLi);    // cache menu item    this.menuItems[ moduleName ] = subMenuLi;  },  /*  Function: removeMenuItem    Removes menu item if exists  Arguments:    item - (string) menu item name  */  removeMenuItem: function(item) {    var menuItem = this.menuItems[ item ];    if (menuItem) {      menuItem.destroy();      delete this.menuItems[ item ];    }  },  /*  Function: endSession    End current user session, block all requests  */  endSession: function() {    this.blockAll = true;    MochaUI.Modal.fade('in');  },  /*  Function: initChanges    Add 'apply changes' button to given container  Arguments:    container - (element or id) button container  */  initChanges: function(container) {    this.changesButton = new Element('div', {      'text': $TR('apply_changes'),      'id': 'FSApplyChanges',      'class': 'Hidden',      'events': {        'click': this.applyChangesStart.bind(this)      }    }).inject($(container));  },  /*  Function: addChange    Add item to 'apply changes' queue if not added before  Arguments:    params - (object) parameters to add  */  addChange: function(params) {    // special case: one of the modules requires reboot    if (params.reboot || this.changes.reboot) {      this.changes.reboot = true;      this.changesButton.removeClass('Hidden');      return;    }    // build complex object to keep track on duplicate entries    var module = params.module, action = params.action, id = (params.id || 'all');    if (!module || !action) {      return;    }    if (!this.changes[ module ]) {      this.changes[ module ] = {};    }    if (!this.changes[ module ][ action ]) {      this.changes[ module ][ action ] = {};    }    this.changes[ module ][ action ][ id ] = params;    // show 'apply changes' button    this.changesButton.removeClass('Hidden');  },  /*  Function: applyChangesStart    Start 'apply changes' queue process  */  applyChangesStart: function() {    this.blockAll = true;    // reboot required for changes to be applied    if (this.changes.reboot) {      // confirm that system can be rebooted      if (confirm($TR('reboot_required'))) {        new Request({          'url': this.requestUrl({            module: 'reboot',            action: 'reboot'          })        }).send();        this.endSession();      }      // remove global block      else {        this.blockAll = false;      }      return;    }    // compile 'apply changes' queue    var queue = [];    for (var module in this.changes) {      var modules = this.changes[ module ];      for (var action in modules) {        var actions = modules[ action ];        for (var id in actions) {          queue.push( actions[ id ] );        }      }    }    FlashSYS.Fader.storage = {      steps: queue.length,      step: 0    };    var ajaxQueue = new FlashSYS.Queue(queue, {      urlCb: this.requestUrl.bind(this),      stepCb: function() {        FlashSYS.Fader.storage.step++;        FlashSYS.Fader.step(FlashSYS.Fader.storage.step.toString() + '/' + FlashSYS.Fader.storage.steps.toString());      },      endCb: this.applyChangesEnd.bind(this)    });    FlashSYS.Fader.start({      title: $TR('apply_changes_title'),      ticker: FlashSYS.Fader.storage.step.toString() + '/' + FlashSYS.Fader.storage.steps.toString(),      tickerPrefix: $TR('apply_changes_ticker')    });  },  /*  Function: applyChangesEnd    Executed when 'apply changes' queue finished loading  */  applyChangesEnd: function() {    // empty changes queue    this.changes = {};    this.changesButton.addClass('Hidden');    FlashSYS.Fader.stop();    // release loading lock    this.blockAll = false;  }};/*Function: $TR  Alias for <FlashSYS.translate>*/var $TR = FlashSYS.translate.bind(FlashSYS);/*Function: $load  Alias for <FlashSYS.load>*/var $load = FlashSYS.load.bind(FlashSYS);/*Function: $notify  Alias for <FlashSYS.notifyWindow>*/var $notify = FlashSYS.notifyWindow.bind(FlashSYS);/*Function: $compare  Compare two objects by their keys / valuesArguments:  objA - (object) first object  objB - (object) second objectReturns:    (null or array) null if object are identical, array of keys with different values otherwise*/function $compare(objA, objB) {  var diff = [], prop = '';  // check first object keys / values  for (prop in objA) {    if (objA[ prop ] != objB[ prop ]) {      diff.include(prop);    }  }  // check second object keys / values  for (prop in objB) {    if (objB[ prop ] != objA[ prop ]) {      diff.include(prop);    }  }  return diff.length ? diff : null;}String.prototype.nl2br = function() {  return this.replace(/\n/g, '<br />');}

⌨️ 快捷键说明

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