1 | /*! |
---|
2 | * Ext JS Library 3.0.0 |
---|
3 | * Copyright(c) 2006-2009 Ext JS, LLC |
---|
4 | * licensing@extjs.com |
---|
5 | * http://www.extjs.com/license |
---|
6 | */ |
---|
7 | /* |
---|
8 | Cookie Plug-in |
---|
9 | |
---|
10 | This plug in automatically gets all the cookies for this site and adds them to the post_params. |
---|
11 | Cookies are loaded only on initialization. The refreshCookies function can be called to update the post_params. |
---|
12 | The cookies will override any other post params with the same name. |
---|
13 | */ |
---|
14 | |
---|
15 | var SWFUpload; |
---|
16 | if (typeof(SWFUpload) === "function") { |
---|
17 | SWFUpload.prototype.initSettings = function (oldInitSettings) { |
---|
18 | return function () { |
---|
19 | if (typeof(oldInitSettings) === "function") { |
---|
20 | oldInitSettings.call(this); |
---|
21 | } |
---|
22 | |
---|
23 | this.refreshCookies(false); // The false parameter must be sent since SWFUpload has not initialzed at this point |
---|
24 | }; |
---|
25 | }(SWFUpload.prototype.initSettings); |
---|
26 | |
---|
27 | // refreshes the post_params and updates SWFUpload. The sendToFlash parameters is optional and defaults to True |
---|
28 | SWFUpload.prototype.refreshCookies = function (sendToFlash) { |
---|
29 | if (sendToFlash === undefined) { |
---|
30 | sendToFlash = true; |
---|
31 | } |
---|
32 | sendToFlash = !!sendToFlash; |
---|
33 | |
---|
34 | // Get the post_params object |
---|
35 | var postParams = this.settings.post_params; |
---|
36 | |
---|
37 | // Get the cookies |
---|
38 | var i, cookieArray = document.cookie.split(';'), caLength = cookieArray.length, c, eqIndex, name, value; |
---|
39 | for (i = 0; i < caLength; i++) { |
---|
40 | c = cookieArray[i]; |
---|
41 | |
---|
42 | // Left Trim spaces |
---|
43 | while (c.charAt(0) === " ") { |
---|
44 | c = c.substring(1, c.length); |
---|
45 | } |
---|
46 | eqIndex = c.indexOf("="); |
---|
47 | if (eqIndex > 0) { |
---|
48 | name = c.substring(0, eqIndex); |
---|
49 | value = c.substring(eqIndex + 1); |
---|
50 | postParams[name] = value; |
---|
51 | } |
---|
52 | } |
---|
53 | |
---|
54 | if (sendToFlash) { |
---|
55 | this.setPostParams(postParams); |
---|
56 | } |
---|
57 | }; |
---|
58 | |
---|
59 | } |
---|