CenterServer.js 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. MWF.xDesktop.requireApp("Setting", "servers.DataServers", null, false);
  2. MWF.xApplication.Setting.servers = MWF.xApplication.Setting.servers || {};
  3. MWF.xApplication.Setting.servers.CenterServer = new Class({
  4. Extends: MWF.xApplication.Setting.servers.DataServer.Document,
  5. Implements: [Events],
  6. initialize: function(explorer){
  7. this.explorer = explorer;
  8. this.app = this.explorer.app;
  9. this.container = this.explorer.centerServerContent;
  10. this.css = this.explorer.app.css;
  11. this.load();
  12. },
  13. load: function(){
  14. this.app.actions.getCenterServer(function(json){
  15. this.json = json.data;
  16. this.node = new Element("div", {"styles": this.css.centerServerDocumentNode}).inject(this.container);
  17. this.createForm();
  18. }.bind(this));
  19. },
  20. createActions: function(){
  21. this.actionNode = new Element("div", {"styles": this.css.applicationServerDocumentActionNode}).inject(this.node);
  22. this.saveAction = new Element("div", {"styles": this.css.applicationServerDocumentSaveNode}).inject(this.actionNode);
  23. //this.closeAction = new Element("div", {"styles": this.css.applicationServerDocumentCloseNode}).inject(this.actionNode);
  24. this.saveAction.addEvents({
  25. "mouseover": function(){this.saveAction.setStyles(this.css.applicationServerDocumentSaveNode_over);}.bind(this),
  26. "mouseout": function(){this.saveAction.setStyles(this.css.applicationServerDocumentSaveNode);}.bind(this),
  27. "mousedown": function(){this.saveAction.setStyles(this.css.applicationServerDocumentSaveNode_down);}.bind(this),
  28. "mouseup": function(){this.saveAction.setStyles(this.css.applicationServerDocumentSaveNode_over);}.bind(this),
  29. "click": function(e){this.saveDocument();}.bind(this)
  30. });
  31. },
  32. createBaseInfo: function(){
  33. this.inforAreaNode = new Element("div", {"styles": this.css.applicationServerDocumentInforAreaNode}).inject(this.node);
  34. this.inforNode = new Element("div", {"styles": this.css.dataServerDocumentInforNode}).inject(this.inforAreaNode);
  35. var html = "<table cellSpacing='8px' width='90%' align='center'>" +
  36. "<tr><td width='160px'>host</td><td><input value='"+(this.json.host || "")+"'/></td></tr>" +
  37. "<tr><td>port</td><td><input value='"+(this.json.port || "")+"'/></td></tr>" +
  38. "<tr><td>cipher</td><td><input value='"+(this.json.cipher || "")+"'/></td></tr>" +
  39. "<tr><td>proxyHost</td><td><input value='"+(this.json.proxyHost || "")+"'/></td></tr>" +
  40. "<tr><td>proxyPort</td><td><input value='"+(this.json.proxyPort || "")+"'/></td></tr>" +
  41. "</table>";
  42. this.inforNode.set("html", html);
  43. var tds = this.inforNode.getElements("td");
  44. var inputs = this.inforNode.getElements("input");
  45. tds.setStyles(this.css.applicationServerDocumentTdNode);
  46. inputs.setStyles(this.css.applicationServerDocumentInputNode);
  47. },
  48. saveDocument: function(){
  49. var inputs = this.inforNode.getElements("input");
  50. this.json.host = inputs[0].get("value");
  51. this.json.port = inputs[1].get("value");
  52. this.json.cipher = inputs[2].get("value");
  53. this.json.proxyHost = inputs[3].get("value");
  54. this.json.proxyPort = inputs[4].get("value");
  55. this.app.actions.updateCenterServer(this.json, function(){
  56. this.app.notice(this.app.lp.centerSaveInfor, "success");
  57. }.bind(this));
  58. },
  59. destroy: function(){
  60. if (this.node) this.node.destroy();
  61. MWF.release(this);
  62. },
  63. });