Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / docs / source / swfupload.cookies.html
diff --git a/docs/source/swfupload.cookies.html b/docs/source/swfupload.cookies.html
new file mode 100644 (file)
index 0000000..dbc6e05
--- /dev/null
@@ -0,0 +1,63 @@
+<html>\r
+<head>\r
+  <title>The source code</title>\r
+    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
+    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
+</head>\r
+<body  onload="prettyPrint();">\r
+    <pre class="prettyprint lang-js">/*\r
+       Cookie Plug-in\r
+       \r
+       This plug in automatically gets all the cookies for this site and adds them to the post_params.\r
+       Cookies are loaded only on initialization.  The refreshCookies function can be called to update the post_params.\r
+       The cookies will override any other post params with the same name.\r
+*/\r
+\r
+var SWFUpload;\r
+if (typeof(SWFUpload) === "function") {\r
+       SWFUpload.prototype.initSettings = function (oldInitSettings) {\r
+               return function () {\r
+                       if (typeof(oldInitSettings) === "function") {\r
+                               oldInitSettings.call(this);\r
+                       }\r
+                       \r
+                       this.refreshCookies(false);     // The false parameter must be sent since SWFUpload has not initialzed at this point\r
+               };\r
+       }(SWFUpload.prototype.initSettings);\r
+       \r
+       // refreshes the post_params and updates SWFUpload.  The sendToFlash parameters is optional and defaults to True\r
+       SWFUpload.prototype.refreshCookies = function (sendToFlash) {\r
+               if (sendToFlash === undefined) {\r
+                       sendToFlash = true;\r
+               }\r
+               sendToFlash = !!sendToFlash;\r
+               \r
+               // Get the post_params object\r
+               var postParams = this.settings.post_params;\r
+               \r
+               // Get the cookies\r
+               var i, cookieArray = document.cookie.split(';'), caLength = cookieArray.length, c, eqIndex, name, value;\r
+               for (i = 0; i < caLength; i++) {\r
+                       c = cookieArray[i];\r
+                       \r
+                       // Left Trim spaces\r
+                       while (c.charAt(0) === " ") {\r
+                               c = c.substring(1, c.length);\r
+                       }\r
+                       eqIndex = c.indexOf("=");\r
+                       if (eqIndex > 0) {\r
+                               name = c.substring(0, eqIndex);\r
+                               value = c.substring(eqIndex + 1);\r
+                               postParams[name] = value;\r
+                       }\r
+               }\r
+               \r
+               if (sendToFlash) {\r
+                       this.setPostParams(postParams);\r
+               }\r
+       };\r
+\r
+}\r
+</pre>    \r
+</body>\r
+</html>
\ No newline at end of file