3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js">/*
\r
11 This plug in automatically gets all the cookies for this site and adds them to the post_params.
\r
12 Cookies are loaded only on initialization. The refreshCookies function can be called to update the post_params.
\r
13 The cookies will override any other post params with the same name.
\r
17 if (typeof(SWFUpload) === "function") {
\r
18 SWFUpload.prototype.initSettings = function (oldInitSettings) {
\r
19 return function () {
\r
20 if (typeof(oldInitSettings) === "function") {
\r
21 oldInitSettings.call(this);
\r
24 this.refreshCookies(false); // The false parameter must be sent since SWFUpload has not initialzed at this point
\r
26 }(SWFUpload.prototype.initSettings);
\r
28 // refreshes the post_params and updates SWFUpload. The sendToFlash parameters is optional and defaults to True
\r
29 SWFUpload.prototype.refreshCookies = function (sendToFlash) {
\r
30 if (sendToFlash === undefined) {
\r
33 sendToFlash = !!sendToFlash;
\r
35 // Get the post_params object
\r
36 var postParams = this.settings.post_params;
\r
39 var i, cookieArray = document.cookie.split(';'), caLength = cookieArray.length, c, eqIndex, name, value;
\r
40 for (i = 0; i < caLength; i++) {
\r
44 while (c.charAt(0) === " ") {
\r
45 c = c.substring(1, c.length);
\r
47 eqIndex = c.indexOf("=");
\r
49 name = c.substring(0, eqIndex);
\r
50 value = c.substring(eqIndex + 1);
\r
51 postParams[name] = value;
\r
56 this.setPostParams(postParams);
\r