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