Web UI for ARGUS server
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.

250 lines
10 KiB

6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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.util.Functions"></div>/**
  16. * @class Ext.util.Functions
  17. * @singleton
  18. */
  19. Ext.util.Functions = {
  20. <div id="method-Ext.util.Functions-createInterceptor"></div>/**
  21. * Creates an interceptor function. The passed function is called before the original one. If it returns false,
  22. * the original one is not called. The resulting function returns the results of the original function.
  23. * The passed function is called with the parameters of the original function. Example usage:
  24. * <pre><code>
  25. var sayHi = function(name){
  26. alert('Hi, ' + name);
  27. }
  28. sayHi('Fred'); // alerts "Hi, Fred"
  29. // create a new function that validates input without
  30. // directly modifying the original function:
  31. var sayHiToFriend = Ext.createInterceptor(sayHi, function(name){
  32. return name == 'Brian';
  33. });
  34. sayHiToFriend('Fred'); // no alert
  35. sayHiToFriend('Brian'); // alerts "Hi, Brian"
  36. </code></pre>
  37. * @param {Function} origFn The original function.
  38. * @param {Function} newFn The function to call before the original
  39. * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the passed function is executed.
  40. * <b>If omitted, defaults to the scope in which the original function is called or the browser window.</b>
  41. * @return {Function} The new function
  42. */
  43. createInterceptor: function(origFn, newFn, scope) {
  44. var method = origFn;
  45. if (!Ext.isFunction(newFn)) {
  46. return origFn;
  47. }
  48. else {
  49. return function() {
  50. var me = this,
  51. args = arguments;
  52. newFn.target = me;
  53. newFn.method = origFn;
  54. return (newFn.apply(scope || me || window, args) !== false) ?
  55. origFn.apply(me || window, args) :
  56. null;
  57. };
  58. }
  59. },
  60. <div id="method-Ext.util.Functions-createDelegate"></div>/**
  61. * Creates a delegate (callback) that sets the scope to obj.
  62. * Call directly on any function. Example: <code>Ext.createDelegate(this.myFunction, this, [arg1, arg2])</code>
  63. * Will create a function that is automatically scoped to obj so that the <tt>this</tt> variable inside the
  64. * callback points to obj. Example usage:
  65. * <pre><code>
  66. var sayHi = function(name){
  67. // Note this use of "this.text" here. This function expects to
  68. // execute within a scope that contains a text property. In this
  69. // example, the "this" variable is pointing to the btn object that
  70. // was passed in createDelegate below.
  71. alert('Hi, ' + name + '. You clicked the "' + this.text + '" button.');
  72. }
  73. var btn = new Ext.Button({
  74. text: 'Say Hi',
  75. renderTo: Ext.getBody()
  76. });
  77. // This callback will execute in the scope of the
  78. // button instance. Clicking the button alerts
  79. // "Hi, Fred. You clicked the "Say Hi" button."
  80. btn.on('click', Ext.createDelegate(sayHi, btn, ['Fred']));
  81. </code></pre>
  82. * @param {Function} fn The function to delegate.
  83. * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the function is executed.
  84. * <b>If omitted, defaults to the browser window.</b>
  85. * @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
  86. * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
  87. * if a number the args are inserted at the specified position
  88. * @return {Function} The new function
  89. */
  90. createDelegate: function(fn, obj, args, appendArgs) {
  91. if (!Ext.isFunction(fn)) {
  92. return fn;
  93. }
  94. return function() {
  95. var callArgs = args || arguments;
  96. if (appendArgs === true) {
  97. callArgs = Array.prototype.slice.call(arguments, 0);
  98. callArgs = callArgs.concat(args);
  99. }
  100. else if (Ext.isNumber(appendArgs)) {
  101. callArgs = Array.prototype.slice.call(arguments, 0);
  102. // copy arguments first
  103. var applyArgs = [appendArgs, 0].concat(args);
  104. // create method call params
  105. Array.prototype.splice.apply(callArgs, applyArgs);
  106. // splice them in
  107. }
  108. return fn.apply(obj || window, callArgs);
  109. };
  110. },
  111. <div id="method-Ext.util.Functions-defer"></div>/**
  112. * Calls this function after the number of millseconds specified, optionally in a specific scope. Example usage:
  113. * <pre><code>
  114. var sayHi = function(name){
  115. alert('Hi, ' + name);
  116. }
  117. // executes immediately:
  118. sayHi('Fred');
  119. // executes after 2 seconds:
  120. Ext.defer(sayHi, 2000, this, ['Fred']);
  121. // this syntax is sometimes useful for deferring
  122. // execution of an anonymous function:
  123. Ext.defer(function(){
  124. alert('Anonymous');
  125. }, 100);
  126. </code></pre>
  127. * @param {Function} fn The function to defer.
  128. * @param {Number} millis The number of milliseconds for the setTimeout call (if less than or equal to 0 the function is executed immediately)
  129. * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the function is executed.
  130. * <b>If omitted, defaults to the browser window.</b>
  131. * @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
  132. * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
  133. * if a number the args are inserted at the specified position
  134. * @return {Number} The timeout id that can be used with clearTimeout
  135. */
  136. defer: function(fn, millis, obj, args, appendArgs) {
  137. fn = Ext.util.Functions.createDelegate(fn, obj, args, appendArgs);
  138. if (millis > 0) {
  139. return setTimeout(fn, millis);
  140. }
  141. fn();
  142. return 0;
  143. },
  144. <div id="method-Ext.util.Functions-createSequence"></div>/**
  145. * Create a combined function call sequence of the original function + the passed function.
  146. * The resulting function returns the results of the original function.
  147. * The passed fcn is called with the parameters of the original function. Example usage:
  148. *
  149. var sayHi = function(name){
  150. alert('Hi, ' + name);
  151. }
  152. sayHi('Fred'); // alerts "Hi, Fred"
  153. var sayGoodbye = Ext.createSequence(sayHi, function(name){
  154. alert('Bye, ' + name);
  155. });
  156. sayGoodbye('Fred'); // both alerts show
  157. * @param {Function} origFn The original function.
  158. * @param {Function} newFn The function to sequence
  159. * @param {Object} scope (optional) The scope (this reference) in which the passed function is executed.
  160. * If omitted, defaults to the scope in which the original function is called or the browser window.
  161. * @return {Function} The new function
  162. */
  163. createSequence: function(origFn, newFn, scope) {
  164. if (!Ext.isFunction(newFn)) {
  165. return origFn;
  166. }
  167. else {
  168. return function() {
  169. var retval = origFn.apply(this || window, arguments);
  170. newFn.apply(scope || this || window, arguments);
  171. return retval;
  172. };
  173. }
  174. }
  175. };
  176. /**
  177. * Shorthand for {@link Ext.util.Functions#defer}
  178. * @param {Function} fn The function to defer.
  179. * @param {Number} millis The number of milliseconds for the setTimeout call (if less than or equal to 0 the function is executed immediately)
  180. * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the function is executed.
  181. * <b>If omitted, defaults to the browser window.</b>
  182. * @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
  183. * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
  184. * if a number the args are inserted at the specified position
  185. * @return {Number} The timeout id that can be used with clearTimeout
  186. * @member Ext
  187. * @method defer
  188. */
  189. Ext.defer = Ext.util.Functions.defer;
  190. /**
  191. * Shorthand for {@link Ext.util.Functions#createInterceptor}
  192. * @param {Function} origFn The original function.
  193. * @param {Function} newFn The function to call before the original
  194. * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the passed function is executed.
  195. * <b>If omitted, defaults to the scope in which the original function is called or the browser window.</b>
  196. * @return {Function} The new function
  197. * @member Ext
  198. * @method defer
  199. */
  200. Ext.createInterceptor = Ext.util.Functions.createInterceptor;
  201. /**
  202. * Shorthand for {@link Ext.util.Functions#createSequence}
  203. * @param {Function} origFn The original function.
  204. * @param {Function} newFn The function to sequence
  205. * @param {Object} scope (optional) The scope (this reference) in which the passed function is executed.
  206. * If omitted, defaults to the scope in which the original function is called or the browser window.
  207. * @return {Function} The new function
  208. * @member Ext
  209. * @method defer
  210. */
  211. Ext.createSequence = Ext.util.Functions.createSequence;
  212. <div id="method-Ext-defer"></div>/**
  213. * Shorthand for {@link Ext.util.Functions#createDelegate}
  214. * @param {Function} fn The function to delegate.
  215. * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the function is executed.
  216. * <b>If omitted, defaults to the browser window.</b>
  217. * @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
  218. * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
  219. * if a number the args are inserted at the specified position
  220. * @return {Function} The new function
  221. * @member Ext
  222. * @method defer
  223. */
  224. Ext.createDelegate = Ext.util.Functions.createDelegate;
  225. </pre>
  226. </body>
  227. </html>