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.

103 lines
3.8 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.CookieProvider"></div>/**
  16. * @class Ext.state.CookieProvider
  17. * @extends Ext.state.Provider
  18. * The default Provider implementation which saves state via cookies.
  19. * <br />Usage:
  20. <pre><code>
  21. var cp = new Ext.state.CookieProvider({
  22. path: "/cgi-bin/",
  23. expires: new Date(new Date().getTime()+(1000*60*60*24*30)), //30 days
  24. domain: "extjs.com"
  25. });
  26. Ext.state.Manager.setProvider(cp);
  27. </code></pre>
  28. * @cfg {String} path The path for which the cookie is active (defaults to root '/' which makes it active for all pages in the site)
  29. * @cfg {Date} expires The cookie expiration date (defaults to 7 days from now)
  30. * @cfg {String} domain The domain to save the cookie for. Note that you cannot specify a different domain than
  31. * your page is on, but you can specify a sub-domain, or simply the domain itself like 'extjs.com' to include
  32. * all sub-domains if you need to access cookies across different sub-domains (defaults to null which uses the same
  33. * domain the page is running on including the 'www' like 'www.extjs.com')
  34. * @cfg {Boolean} secure True if the site is using SSL (defaults to false)
  35. * @constructor
  36. * Create a new CookieProvider
  37. * @param {Object} config The configuration object
  38. */
  39. Ext.state.CookieProvider = Ext.extend(Ext.state.Provider, {
  40. constructor : function(config){
  41. Ext.state.CookieProvider.superclass.constructor.call(this);
  42. this.path = "/";
  43. this.expires = new Date(new Date().getTime()+(1000*60*60*24*7)); //7 days
  44. this.domain = null;
  45. this.secure = false;
  46. Ext.apply(this, config);
  47. this.state = this.readCookies();
  48. },
  49. // private
  50. set : function(name, value){
  51. if(typeof value == "undefined" || value === null){
  52. this.clear(name);
  53. return;
  54. }
  55. this.setCookie(name, value);
  56. Ext.state.CookieProvider.superclass.set.call(this, name, value);
  57. },
  58. // private
  59. clear : function(name){
  60. this.clearCookie(name);
  61. Ext.state.CookieProvider.superclass.clear.call(this, name);
  62. },
  63. // private
  64. readCookies : function(){
  65. var cookies = {},
  66. c = document.cookie + ";",
  67. re = /\s?(.*?)=(.*?);/g,
  68. matches,
  69. name,
  70. value;
  71. while((matches = re.exec(c)) != null){
  72. name = matches[1];
  73. value = matches[2];
  74. if(name && name.substring(0,3) == "ys-"){
  75. cookies[name.substr(3)] = this.decodeValue(value);
  76. }
  77. }
  78. return cookies;
  79. },
  80. // private
  81. setCookie : function(name, value){
  82. document.cookie = "ys-"+ name + "=" + this.encodeValue(value) +
  83. ((this.expires == null) ? "" : ("; expires=" + this.expires.toGMTString())) +
  84. ((this.path == null) ? "" : ("; path=" + this.path)) +
  85. ((this.domain == null) ? "" : ("; domain=" + this.domain)) +
  86. ((this.secure == true) ? "; secure" : "");
  87. },
  88. // private
  89. clearCookie : function(name){
  90. document.cookie = "ys-" + name + "=null; expires=Thu, 01-Jan-70 00:00:01 GMT" +
  91. ((this.path == null) ? "" : ("; path=" + this.path)) +
  92. ((this.domain == null) ? "" : ("; domain=" + this.domain)) +
  93. ((this.secure == true) ? "; secure" : "");
  94. }
  95. });</pre>
  96. </body>
  97. </html>