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.

164 lines
5.2 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.state.Provider"></div>/**
  16. * @class Ext.state.Provider
  17. * Abstract base class for state provider implementations. This class provides methods
  18. * for encoding and decoding <b>typed</b> variables including dates and defines the
  19. * Provider interface.
  20. */
  21. Ext.state.Provider = Ext.extend(Ext.util.Observable, {
  22. constructor : function(){
  23. <div id="event-Ext.state.Provider-statechange"></div>/**
  24. * @event statechange
  25. * Fires when a state change occurs.
  26. * @param {Provider} this This state provider
  27. * @param {String} key The state key which was changed
  28. * @param {String} value The encoded value for the state
  29. */
  30. this.addEvents("statechange");
  31. this.state = {};
  32. Ext.state.Provider.superclass.constructor.call(this);
  33. },
  34. <div id="method-Ext.state.Provider-get"></div>/**
  35. * Returns the current value for a key
  36. * @param {String} name The key name
  37. * @param {Mixed} defaultValue A default value to return if the key's value is not found
  38. * @return {Mixed} The state data
  39. */
  40. get : function(name, defaultValue){
  41. return typeof this.state[name] == "undefined" ?
  42. defaultValue : this.state[name];
  43. },
  44. <div id="method-Ext.state.Provider-clear"></div>/**
  45. * Clears a value from the state
  46. * @param {String} name The key name
  47. */
  48. clear : function(name){
  49. delete this.state[name];
  50. this.fireEvent("statechange", this, name, null);
  51. },
  52. <div id="method-Ext.state.Provider-set"></div>/**
  53. * Sets the value for a key
  54. * @param {String} name The key name
  55. * @param {Mixed} value The value to set
  56. */
  57. set : function(name, value){
  58. this.state[name] = value;
  59. this.fireEvent("statechange", this, name, value);
  60. },
  61. <div id="method-Ext.state.Provider-decodeValue"></div>/**
  62. * Decodes a string previously encoded with {@link #encodeValue}.
  63. * @param {String} value The value to decode
  64. * @return {Mixed} The decoded value
  65. */
  66. decodeValue : function(cookie){
  67. <div id="prop-Ext.state.Provider-var"></div>/**
  68. * a -> Array
  69. * n -> Number
  70. * d -> Date
  71. * b -> Boolean
  72. * s -> String
  73. * o -> Object
  74. * -> Empty (null)
  75. */
  76. var re = /^(a|n|d|b|s|o|e)\:(.*)$/,
  77. matches = re.exec(unescape(cookie)),
  78. all,
  79. type,
  80. v,
  81. kv;
  82. if(!matches || !matches[1]){
  83. return; // non state cookie
  84. }
  85. type = matches[1];
  86. v = matches[2];
  87. switch(type){
  88. case 'e':
  89. return null;
  90. case 'n':
  91. return parseFloat(v);
  92. case 'd':
  93. return new Date(Date.parse(v));
  94. case 'b':
  95. return (v == '1');
  96. case 'a':
  97. all = [];
  98. if(v != ''){
  99. Ext.each(v.split('^'), function(val){
  100. all.push(this.decodeValue(val));
  101. }, this);
  102. }
  103. return all;
  104. case 'o':
  105. all = {};
  106. if(v != ''){
  107. Ext.each(v.split('^'), function(val){
  108. kv = val.split('=');
  109. all[kv[0]] = this.decodeValue(kv[1]);
  110. }, this);
  111. }
  112. return all;
  113. default:
  114. return v;
  115. }
  116. },
  117. <div id="method-Ext.state.Provider-encodeValue"></div>/**
  118. * Encodes a value including type information. Decode with {@link #decodeValue}.
  119. * @param {Mixed} value The value to encode
  120. * @return {String} The encoded value
  121. */
  122. encodeValue : function(v){
  123. var enc,
  124. flat = '',
  125. i = 0,
  126. len,
  127. key;
  128. if(v == null){
  129. return 'e:1';
  130. }else if(typeof v == 'number'){
  131. enc = 'n:' + v;
  132. }else if(typeof v == 'boolean'){
  133. enc = 'b:' + (v ? '1' : '0');
  134. }else if(Ext.isDate(v)){
  135. enc = 'd:' + v.toGMTString();
  136. }else if(Ext.isArray(v)){
  137. for(len = v.length; i < len; i++){
  138. flat += this.encodeValue(v[i]);
  139. if(i != len - 1){
  140. flat += '^';
  141. }
  142. }
  143. enc = 'a:' + flat;
  144. }else if(typeof v == 'object'){
  145. for(key in v){
  146. if(typeof v[key] != 'function' && v[key] !== undefined){
  147. flat += key + '=' + this.encodeValue(v[key]) + '^';
  148. }
  149. }
  150. enc = 'o:' + flat.substring(0, flat.length-1);
  151. }else{
  152. enc = 's:' + v;
  153. }
  154. return escape(enc);
  155. }
  156. });
  157. </pre>
  158. </body>
  159. </html>