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.

200 lines
6.8 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.JSON"></div>/**
  16. * @class Ext.util.JSON
  17. * Modified version of Douglas Crockford"s json.js that doesn"t
  18. * mess with the Object prototype
  19. * http://www.json.org/js.html
  20. * @singleton
  21. */
  22. Ext.util.JSON = new (function(){
  23. var useHasOwn = !!{}.hasOwnProperty,
  24. isNative = function() {
  25. var useNative = null;
  26. return function() {
  27. if (useNative === null) {
  28. useNative = Ext.USE_NATIVE_JSON && window.JSON && JSON.toString() == '[object JSON]';
  29. }
  30. return useNative;
  31. };
  32. }(),
  33. pad = function(n) {
  34. return n < 10 ? "0" + n : n;
  35. },
  36. doDecode = function(json){
  37. return eval("(" + json + ")");
  38. },
  39. doEncode = function(o){
  40. if(!Ext.isDefined(o) || o === null){
  41. return "null";
  42. }else if(Ext.isArray(o)){
  43. return encodeArray(o);
  44. }else if(Ext.isDate(o)){
  45. return Ext.util.JSON.encodeDate(o);
  46. }else if(Ext.isString(o)){
  47. return encodeString(o);
  48. }else if(typeof o == "number"){
  49. //don't use isNumber here, since finite checks happen inside isNumber
  50. return isFinite(o) ? String(o) : "null";
  51. }else if(Ext.isBoolean(o)){
  52. return String(o);
  53. }else {
  54. var a = ["{"], b, i, v;
  55. for (i in o) {
  56. // don't encode DOM objects
  57. if(!o.getElementsByTagName){
  58. if(!useHasOwn || o.hasOwnProperty(i)) {
  59. v = o[i];
  60. switch (typeof v) {
  61. case "undefined":
  62. case "function":
  63. case "unknown":
  64. break;
  65. default:
  66. if(b){
  67. a.push(',');
  68. }
  69. a.push(doEncode(i), ":",
  70. v === null ? "null" : doEncode(v));
  71. b = true;
  72. }
  73. }
  74. }
  75. }
  76. a.push("}");
  77. return a.join("");
  78. }
  79. },
  80. m = {
  81. "\b": '\\b',
  82. "\t": '\\t',
  83. "\n": '\\n',
  84. "\f": '\\f',
  85. "\r": '\\r',
  86. '"' : '\\"',
  87. "\\": '\\\\'
  88. },
  89. encodeString = function(s){
  90. if (/["\\\x00-\x1f]/.test(s)) {
  91. return '"' + s.replace(/([\x00-\x1f\\"])/g, function(a, b) {
  92. var c = m[b];
  93. if(c){
  94. return c;
  95. }
  96. c = b.charCodeAt();
  97. return "\\u00" +
  98. Math.floor(c / 16).toString(16) +
  99. (c % 16).toString(16);
  100. }) + '"';
  101. }
  102. return '"' + s + '"';
  103. },
  104. encodeArray = function(o){
  105. var a = ["["], b, i, l = o.length, v;
  106. for (i = 0; i < l; i += 1) {
  107. v = o[i];
  108. switch (typeof v) {
  109. case "undefined":
  110. case "function":
  111. case "unknown":
  112. break;
  113. default:
  114. if (b) {
  115. a.push(',');
  116. }
  117. a.push(v === null ? "null" : Ext.util.JSON.encode(v));
  118. b = true;
  119. }
  120. }
  121. a.push("]");
  122. return a.join("");
  123. };
  124. <div id="method-Ext.util.JSON-encodeDate"></div>/**
  125. * <p>Encodes a Date. This returns the actual string which is inserted into the JSON string as the literal expression.
  126. * <b>The returned value includes enclosing double quotation marks.</b></p>
  127. * <p>The default return format is "yyyy-mm-ddThh:mm:ss".</p>
  128. * <p>To override this:</p><pre><code>
  129. Ext.util.JSON.encodeDate = function(d) {
  130. return d.format('"Y-m-d"');
  131. };
  132. </code></pre>
  133. * @param {Date} d The Date to encode
  134. * @return {String} The string literal to use in a JSON string.
  135. */
  136. this.encodeDate = function(o){
  137. return '"' + o.getFullYear() + "-" +
  138. pad(o.getMonth() + 1) + "-" +
  139. pad(o.getDate()) + "T" +
  140. pad(o.getHours()) + ":" +
  141. pad(o.getMinutes()) + ":" +
  142. pad(o.getSeconds()) + '"';
  143. };
  144. <div id="method-Ext.util.JSON-encode"></div>/**
  145. * Encodes an Object, Array or other value
  146. * @param {Mixed} o The variable to encode
  147. * @return {String} The JSON string
  148. */
  149. this.encode = function() {
  150. var ec;
  151. return function(o) {
  152. if (!ec) {
  153. // setup encoding function on first access
  154. ec = isNative() ? JSON.stringify : doEncode;
  155. }
  156. return ec(o);
  157. };
  158. }();
  159. <div id="method-Ext.util.JSON-decode"></div>/**
  160. * Decodes (parses) a JSON string to an object. If the JSON is invalid, this function throws a SyntaxError unless the safe option is set.
  161. * @param {String} json The JSON string
  162. * @return {Object} The resulting object
  163. */
  164. this.decode = function() {
  165. var dc;
  166. return function(json) {
  167. if (!dc) {
  168. // setup decoding function on first access
  169. dc = isNative() ? JSON.parse : doDecode;
  170. }
  171. return dc(json);
  172. };
  173. }();
  174. })();
  175. <div id="method-Ext-encode"></div>/**
  176. * Shorthand for {@link Ext.util.JSON#encode}
  177. * @param {Mixed} o The variable to encode
  178. * @return {String} The JSON string
  179. * @member Ext
  180. * @method encode
  181. */
  182. Ext.encode = Ext.util.JSON.encode;
  183. <div id="method-Ext-decode"></div>/**
  184. * Shorthand for {@link Ext.util.JSON#decode}
  185. * @param {String} json The JSON string
  186. * @param {Boolean} safe (optional) Whether to return null or throw an exception if the JSON is invalid.
  187. * @return {Object} The resulting object
  188. * @member Ext
  189. * @method decode
  190. */
  191. Ext.decode = Ext.util.JSON.decode;
  192. </pre>
  193. </body>
  194. </html>