CheckOnline.js 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. MWF.xApplication.Setting.mobile = MWF.xApplication.Setting.mobile || {};
  2. MWF.require("MWF.widget.Mask", null, false);
  3. MWF.xApplication.Setting.mobile.CheckOnline = new Class({
  4. Implements: [Options, Events],
  5. initialize: function(explorer){
  6. this.explorer = explorer;
  7. this.app = this.explorer.app;
  8. this.actions = this.app.actions;
  9. this.css = this.app.css;
  10. this.content = this.explorer.checkOnlineContent;
  11. this.page = this.app.mobilePage;
  12. this.load();
  13. },
  14. load: function(){
  15. this.inforNode = new Element("div", {"styles": this.css.mobileCheckInforNode}).inject(this.content);
  16. this.actionNode = new Element("div", {"styles": this.css.mobileCheckActionNode}).inject(this.content);
  17. this.centerOnlineNode = new Element("div", {"styles": this.css.mobileCenterOnlineNode}).inject(this.inforNode);
  18. this.centerIconNode = new Element("div", {"styles": this.css.mobileCenterIconNode}).inject(this.centerOnlineNode);
  19. this.centerOnlineLineNode = new Element("div", {"styles": this.css.mobileCenterOnlineLineNode}).inject(this.centerOnlineNode);
  20. this.server1IconNode = new Element("div", {"styles": this.css.mobileServer1IconNode}).inject(this.centerOnlineNode);
  21. this.centerOnlineStatusNode = new Element("div", {"styles": this.css.mobileCenterOnlineStatusNode}).inject(this.centerOnlineNode);
  22. this.centerOnlineTextNode = new Element("div", {"styles": this.css.mobileCenterOnlineTextNode}).inject(this.centerOnlineNode);
  23. this.computerOnlineNode = new Element("div", {"styles": this.css.mobileComputerOnlineNode}).inject(this.inforNode);
  24. this.computerIconNode = new Element("div", {"styles": this.css.mobileComputerIconNode}).inject(this.computerOnlineNode);
  25. this.computerOnlineLineNode = new Element("div", {"styles": this.css.mobileComputerOnlineLineNode}).inject(this.computerOnlineNode);
  26. this.server2IconNode = new Element("div", {"styles": this.css.mobileServer2IconNode}).inject(this.computerOnlineNode);
  27. this.computerOnlineStatusNode = new Element("div", {"styles": this.css.mobileComputerOnlineStatusNode}).inject(this.computerOnlineNode);
  28. this.computerOnlineTextNode = new Element("div", {"styles": this.css.mobileComputerOnlineTextNode}).inject(this.computerOnlineNode);
  29. this.centerOnlineTextNode.set("text", this.app.lp.checkCenterToCollect);
  30. this.computerOnlineTextNode.set("text", this.app.lp.checkComputerToCollect);
  31. this.checkAction = new Element("div", {"styles": this.css.mobileReCheckActionNode}).inject(this.actionNode);
  32. this.checkAction.set("text", this.app.lp.reCheck);
  33. this.checkAction.addEvent("click", this.check.bind(this));
  34. //this.nextAction = new Element("div", {"styles": this.css.mobileNextActionNode}).inject(this.actionNode);
  35. //this.nextAction.set("text", this.app.lp.next);
  36. //this.nextAction.addEvent("click", this.nextStep.bind(this));
  37. this.check();
  38. },
  39. check: function(){
  40. this.mask = new MWF.widget.Mask({"style": "desktop"});
  41. this.mask.loadNode(this.explorer.contentAreaNode);
  42. this.checkCenterConnectFailure();
  43. this.checkComputerConnectFailure();
  44. this.actions.checkConnect(function(json){
  45. if (json.data.value){
  46. this.checkCenterConnectSuccess();
  47. }else{
  48. this.checkCenterConnectFailure();
  49. }
  50. }.bind(this), function(){
  51. this.checkCenterConnectFailure();
  52. }.bind(this));
  53. this.actions.connectCollect(function(json){
  54. if (json.data.servletContextName=="o2_collect"){
  55. this.checkComputerConnectSuccess();
  56. }else{
  57. this.checkComputerConnectFailure();
  58. }
  59. }.bind(this), function(){
  60. this.checkComputerConnectFailure();
  61. }.bind(this));
  62. },
  63. nextStep: function(){
  64. },
  65. checkCenterConnectReset: function(){
  66. this.centerOnlineStatusNode.set("text", "");
  67. this.centerOnlineStatusNode.setStyle("background", "url(/x_component_Setting/$Main/"+this.app.options.style+"/mobile/failure.png) no-repeat left center");
  68. this.centerIconNode.setStyle("background", "url(/x_component_Setting/$Main/"+this.app.options.style+"/mobile/center.png) no-repeat center center");
  69. this.centerOnlineLineNode.setStyle("background", "url(/x_component_Setting/$Main/"+this.app.options.style+"/mobile/line.png) no-repeat center center");
  70. this.server1IconNode.setStyle("background", "url(/x_component_Setting/$Main/"+this.app.options.style+"/mobile/server.png) no-repeat center center");
  71. this.centerOnlineStatusNode.setStyle("color", "#666");
  72. this.centerOnline = false;
  73. this.centerCheck = true;
  74. },
  75. checkComputerConnectReset: function(){
  76. this.computerOnlineStatusNode.set("text", "");
  77. this.computerOnlineStatusNode.setStyle("background", "url(/x_component_Setting/$Main/"+this.app.options.style+"/mobile/failure.png) no-repeat left center");
  78. this.computerIconNode.setStyle("background", "url(/x_component_Setting/$Main/"+this.app.options.style+"/mobile/computer.png) no-repeat center center");
  79. this.computerOnlineLineNode.setStyle("background", "url(/x_component_Setting/$Main/"+this.app.options.style+"/mobile/line.png) no-repeat center center");
  80. this.server2IconNode.setStyle("background", "url(/x_component_Setting/$Main/"+this.app.options.style+"/mobile/server.png) no-repeat center center");
  81. this.computerOnlineStatusNode.setStyle("color", "#666");
  82. this.computerOnline = false;
  83. this.computerCheck = true;
  84. },
  85. checkCenterConnectSuccess: function(){
  86. this.centerOnlineStatusNode.set("text", this.app.lp.success);
  87. this.centerOnlineStatusNode.setStyle("background", "url(/x_component_Setting/$Main/"+this.app.options.style+"/mobile/success.png) no-repeat left center");
  88. this.centerIconNode.setStyle("background", "url(/x_component_Setting/$Main/"+this.app.options.style+"/mobile/center_ok.png) no-repeat center center");
  89. this.centerOnlineLineNode.setStyle("background", "url(/x_component_Setting/$Main/"+this.app.options.style+"/mobile/line_ok.png) no-repeat center center");
  90. this.server1IconNode.setStyle("background", "url(/x_component_Setting/$Main/"+this.app.options.style+"/mobile/server_ok.png) no-repeat center center");
  91. this.centerOnlineStatusNode.setStyle("color", "#3498db");
  92. this.centerOnline = true;
  93. this.centerCheck = true;
  94. this.checkCompleted();
  95. },
  96. checkCenterConnectFailure: function(){
  97. this.centerOnlineStatusNode.set("text", this.app.lp.failure);
  98. this.centerOnlineStatusNode.setStyle("background", "url(/x_component_Setting/$Main/"+this.app.options.style+"/mobile/failure.png) no-repeat left center");
  99. this.centerIconNode.setStyle("background", "url(/x_component_Setting/$Main/"+this.app.options.style+"/mobile/center.png) no-repeat center center");
  100. this.centerOnlineLineNode.setStyle("background", "url(/x_component_Setting/$Main/"+this.app.options.style+"/mobile/line.png) no-repeat center center");
  101. this.server1IconNode.setStyle("background", "url(/x_component_Setting/$Main/"+this.app.options.style+"/mobile/server.png) no-repeat center center");
  102. this.centerOnlineStatusNode.setStyle("color", "#666");
  103. this.centerOnline = false;
  104. this.centerCheck = true;
  105. this.checkCompleted();
  106. },
  107. checkComputerConnectSuccess: function(){
  108. this.computerOnlineStatusNode.set("text", this.app.lp.success);
  109. this.computerOnlineStatusNode.setStyle("background", "url(/x_component_Setting/$Main/"+this.app.options.style+"/mobile/success.png) no-repeat left center");
  110. this.computerIconNode.setStyle("background", "url(/x_component_Setting/$Main/"+this.app.options.style+"/mobile/computer_ok.png) no-repeat center center");
  111. this.computerOnlineLineNode.setStyle("background", "url(/x_component_Setting/$Main/"+this.app.options.style+"/mobile/line_ok.png) no-repeat center center");
  112. this.server2IconNode.setStyle("background", "url(/x_component_Setting/$Main/"+this.app.options.style+"/mobile/server_ok.png) no-repeat center center");
  113. this.computerOnlineStatusNode.setStyle("color", "#3498db");
  114. this.computerOnline = true;
  115. this.computerCheck = true;
  116. this.checkCompleted();
  117. },
  118. checkComputerConnectFailure: function(){
  119. this.computerOnlineStatusNode.set("text", this.app.lp.failure);
  120. this.computerOnlineStatusNode.setStyle("background", "url(/x_component_Setting/$Main/"+this.app.options.style+"/mobile/failure.png) no-repeat left center");
  121. this.computerIconNode.setStyle("background", "url(/x_component_Setting/$Main/"+this.app.options.style+"/mobile/computer.png) no-repeat center center");
  122. this.computerOnlineLineNode.setStyle("background", "url(/x_component_Setting/$Main/"+this.app.options.style+"/mobile/line.png) no-repeat center center");
  123. this.server2IconNode.setStyle("background", "url(/x_component_Setting/$Main/"+this.app.options.style+"/mobile/server.png) no-repeat center center");
  124. this.computerOnlineStatusNode.setStyle("color", "#666");
  125. this.computerOnline = false;
  126. this.computerCheck = true;
  127. this.checkCompleted();
  128. },
  129. checkCompleted: function(){
  130. if (this.centerCheck && this.computerCheck){
  131. if (this.centerOnline && this.computerOnline){
  132. this.checkConnectSuccess();
  133. }else{
  134. this.checkConnectFailure();
  135. }
  136. if (this.mask) this.mask.hide();
  137. }
  138. },
  139. destroy: function(){
  140. this.content.destroy();
  141. MWF.release(this);
  142. },
  143. checkConnectSuccess: function(){
  144. this.checkConnectStatus = true;
  145. },
  146. checkConnectFailure: function(){
  147. this.checkConnectStatus = false;
  148. }
  149. });