Web Interface For Lite Argus Control modules
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

225 lines
7.5 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>The source code</title>
  5. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  6. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  7. </head>
  8. <body onload="prettyPrint();">
  9. <pre class="prettyprint lang-js">/*!
  10. * Ext JS Library 3.3.1
  11. * Copyright(c) 2006-2010 Sencha Inc.
  12. * licensing@sencha.com
  13. * http://www.sencha.com/license
  14. */
  15. <div id="cls-Ext.History"></div>/**
  16. * @class Ext.History
  17. * @extends Ext.util.Observable
  18. * History management component that allows you to register arbitrary tokens that signify application
  19. * history state on navigation actions. You can then handle the history {@link #change} event in order
  20. * to reset your application UI to the appropriate state when the user navigates forward or backward through
  21. * the browser history stack.
  22. * @singleton
  23. */
  24. Ext.History = (function () {
  25. var iframe, hiddenField;
  26. var ready = false;
  27. var currentToken;
  28. function getHash() {
  29. var href = location.href, i = href.indexOf("#");
  30. return i >= 0 ? href.substr(i + 1) : null;
  31. }
  32. function doSave() {
  33. hiddenField.value = currentToken;
  34. }
  35. function handleStateChange(token) {
  36. currentToken = token;
  37. Ext.History.fireEvent('change', token);
  38. }
  39. function updateIFrame (token) {
  40. var html = ['<html><body><div id="state">',Ext.util.Format.htmlEncode(token),'</div></body></html>'].join('');
  41. try {
  42. var doc = iframe.contentWindow.document;
  43. doc.open();
  44. doc.write(html);
  45. doc.close();
  46. return true;
  47. } catch (e) {
  48. return false;
  49. }
  50. }
  51. function checkIFrame() {
  52. if (!iframe.contentWindow || !iframe.contentWindow.document) {
  53. setTimeout(checkIFrame, 10);
  54. return;
  55. }
  56. var doc = iframe.contentWindow.document;
  57. var elem = doc.getElementById("state");
  58. var token = elem ? elem.innerText : null;
  59. var hash = getHash();
  60. setInterval(function () {
  61. doc = iframe.contentWindow.document;
  62. elem = doc.getElementById("state");
  63. var newtoken = elem ? elem.innerText : null;
  64. var newHash = getHash();
  65. if (newtoken !== token) {
  66. token = newtoken;
  67. handleStateChange(token);
  68. top.location.hash = token;
  69. hash = token;
  70. doSave();
  71. } else if (newHash !== hash) {
  72. hash = newHash;
  73. updateIFrame(newHash);
  74. }
  75. }, 50);
  76. ready = true;
  77. Ext.History.fireEvent('ready', Ext.History);
  78. }
  79. function startUp() {
  80. currentToken = hiddenField.value ? hiddenField.value : getHash();
  81. if (Ext.isIE) {
  82. checkIFrame();
  83. } else {
  84. var hash = getHash();
  85. setInterval(function () {
  86. var newHash = getHash();
  87. if (newHash !== hash) {
  88. hash = newHash;
  89. handleStateChange(hash);
  90. doSave();
  91. }
  92. }, 50);
  93. ready = true;
  94. Ext.History.fireEvent('ready', Ext.History);
  95. }
  96. }
  97. return {
  98. <div id="prop-Ext.History-fieldId"></div>/**
  99. * The id of the hidden field required for storing the current history token.
  100. * @type String
  101. * @property
  102. */
  103. fieldId: 'x-history-field',
  104. <div id="prop-Ext.History-iframeId"></div>/**
  105. * The id of the iframe required by IE to manage the history stack.
  106. * @type String
  107. * @property
  108. */
  109. iframeId: 'x-history-frame',
  110. events:{},
  111. <div id="method-Ext.History-init"></div>/**
  112. * Initialize the global History instance.
  113. * @param {Boolean} onReady (optional) A callback function that will be called once the history
  114. * component is fully initialized.
  115. * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the callback is executed. Defaults to the browser window.
  116. */
  117. init: function (onReady, scope) {
  118. if(ready) {
  119. Ext.callback(onReady, scope, [this]);
  120. return;
  121. }
  122. if(!Ext.isReady){
  123. Ext.onReady(function(){
  124. Ext.History.init(onReady, scope);
  125. });
  126. return;
  127. }
  128. hiddenField = Ext.getDom(Ext.History.fieldId);
  129. if (Ext.isIE) {
  130. iframe = Ext.getDom(Ext.History.iframeId);
  131. }
  132. this.addEvents(
  133. <div id="event-Ext.History-ready"></div>/**
  134. * @event ready
  135. * Fires when the Ext.History singleton has been initialized and is ready for use.
  136. * @param {Ext.History} The Ext.History singleton.
  137. */
  138. 'ready',
  139. <div id="event-Ext.History-change"></div>/**
  140. * @event change
  141. * Fires when navigation back or forwards within the local page's history occurs.
  142. * @param {String} token An identifier associated with the page state at that point in its history.
  143. */
  144. 'change'
  145. );
  146. if(onReady){
  147. this.on('ready', onReady, scope, {single:true});
  148. }
  149. startUp();
  150. },
  151. <div id="method-Ext.History-add"></div>/**
  152. * Add a new token to the history stack. This can be any arbitrary value, although it would
  153. * commonly be the concatenation of a component id and another id marking the specifc history
  154. * state of that component. Example usage:
  155. * <pre><code>
  156. // Handle tab changes on a TabPanel
  157. tabPanel.on('tabchange', function(tabPanel, tab){
  158. Ext.History.add(tabPanel.id + ':' + tab.id);
  159. });
  160. </code></pre>
  161. * @param {String} token The value that defines a particular application-specific history state
  162. * @param {Boolean} preventDuplicates When true, if the passed token matches the current token
  163. * it will not save a new history step. Set to false if the same state can be saved more than once
  164. * at the same history stack location (defaults to true).
  165. */
  166. add: function (token, preventDup) {
  167. if(preventDup !== false){
  168. if(this.getToken() == token){
  169. return true;
  170. }
  171. }
  172. if (Ext.isIE) {
  173. return updateIFrame(token);
  174. } else {
  175. top.location.hash = token;
  176. return true;
  177. }
  178. },
  179. <div id="method-Ext.History-back"></div>/**
  180. * Programmatically steps back one step in browser history (equivalent to the user pressing the Back button).
  181. */
  182. back: function(){
  183. history.go(-1);
  184. },
  185. <div id="method-Ext.History-forward"></div>/**
  186. * Programmatically steps forward one step in browser history (equivalent to the user pressing the Forward button).
  187. */
  188. forward: function(){
  189. history.go(1);
  190. },
  191. <div id="method-Ext.History-getToken"></div>/**
  192. * Retrieves the currently-active history token.
  193. * @return {String} The token
  194. */
  195. getToken: function() {
  196. return ready ? currentToken : getHash();
  197. }
  198. };
  199. })();
  200. Ext.apply(Ext.History, new Ext.util.Observable());</pre>
  201. </body>
  202. </html>