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.

105 lines
4.4 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.Cookies"></div>/**
  16. * @class Ext.util.Cookies
  17. * Utility class for managing and interacting with cookies.
  18. * @singleton
  19. */
  20. Ext.util.Cookies = {
  21. <div id="method-Ext.util.Cookies-set"></div>/**
  22. * Create a cookie with the specified name and value. Additional settings
  23. * for the cookie may be optionally specified (for example: expiration,
  24. * access restriction, SSL).
  25. * @param {String} name The name of the cookie to set.
  26. * @param {Mixed} value The value to set for the cookie.
  27. * @param {Object} expires (Optional) Specify an expiration date the
  28. * cookie is to persist until. Note that the specified Date object will
  29. * be converted to Greenwich Mean Time (GMT).
  30. * @param {String} path (Optional) Setting a path on the cookie restricts
  31. * access to pages that match that path. Defaults to all pages (<tt>'/'</tt>).
  32. * @param {String} domain (Optional) Setting a domain restricts access to
  33. * pages on a given domain (typically used to allow cookie access across
  34. * subdomains). For example, "extjs.com" will create a cookie that can be
  35. * accessed from any subdomain of extjs.com, including www.extjs.com,
  36. * support.extjs.com, etc.
  37. * @param {Boolean} secure (Optional) Specify true to indicate that the cookie
  38. * should only be accessible via SSL on a page using the HTTPS protocol.
  39. * Defaults to <tt>false</tt>. Note that this will only work if the page
  40. * calling this code uses the HTTPS protocol, otherwise the cookie will be
  41. * created with default options.
  42. */
  43. set : function(name, value){
  44. var argv = arguments;
  45. var argc = arguments.length;
  46. var expires = (argc > 2) ? argv[2] : null;
  47. var path = (argc > 3) ? argv[3] : '/';
  48. var domain = (argc > 4) ? argv[4] : null;
  49. var secure = (argc > 5) ? argv[5] : false;
  50. document.cookie = name + "=" + escape(value) + ((expires === null) ? "" : ("; expires=" + expires.toGMTString())) + ((path === null) ? "" : ("; path=" + path)) + ((domain === null) ? "" : ("; domain=" + domain)) + ((secure === true) ? "; secure" : "");
  51. },
  52. <div id="method-Ext.util.Cookies-get"></div>/**
  53. * Retrieves cookies that are accessible by the current page. If a cookie
  54. * does not exist, <code>get()</code> returns <tt>null</tt>. The following
  55. * example retrieves the cookie called "valid" and stores the String value
  56. * in the variable <tt>validStatus</tt>.
  57. * <pre><code>
  58. * var validStatus = Ext.util.Cookies.get("valid");
  59. * </code></pre>
  60. * @param {String} name The name of the cookie to get
  61. * @return {Mixed} Returns the cookie value for the specified name;
  62. * null if the cookie name does not exist.
  63. */
  64. get : function(name){
  65. var arg = name + "=";
  66. var alen = arg.length;
  67. var clen = document.cookie.length;
  68. var i = 0;
  69. var j = 0;
  70. while(i < clen){
  71. j = i + alen;
  72. if(document.cookie.substring(i, j) == arg){
  73. return Ext.util.Cookies.getCookieVal(j);
  74. }
  75. i = document.cookie.indexOf(" ", i) + 1;
  76. if(i === 0){
  77. break;
  78. }
  79. }
  80. return null;
  81. },
  82. <div id="method-Ext.util.Cookies-clear"></div>/**
  83. * Removes a cookie with the provided name from the browser
  84. * if found by setting its expiration date to sometime in the past.
  85. * @param {String} name The name of the cookie to remove
  86. */
  87. clear : function(name){
  88. if(Ext.util.Cookies.get(name)){
  89. document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  90. }
  91. },
  92. /**
  93. * @private
  94. */
  95. getCookieVal : function(offset){
  96. var endstr = document.cookie.indexOf(";", offset);
  97. if(endstr == -1){
  98. endstr = document.cookie.length;
  99. }
  100. return unescape(document.cookie.substring(offset, endstr));
  101. }
  102. };</pre>
  103. </body>
  104. </html>