summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/wordpress-mobile-pack/frontend/sections/smart-app-banner/js/UI.Modules/Cookie.js')
-rwxr-xr-xplugins/wordpress-mobile-pack/frontend/sections/smart-app-banner/js/UI.Modules/Cookie.js60
1 files changed, 60 insertions, 0 deletions
diff --git a/plugins/wordpress-mobile-pack/frontend/sections/smart-app-banner/js/UI.Modules/Cookie.js b/plugins/wordpress-mobile-pack/frontend/sections/smart-app-banner/js/UI.Modules/Cookie.js
new file mode 100755
index 00000000..33ffa3c8
--- /dev/null
+++ b/plugins/wordpress-mobile-pack/frontend/sections/smart-app-banner/js/UI.Modules/Cookie.js
@@ -0,0 +1,60 @@
+wmpAppBanner = wmpAppBanner || {};
+
+(function () {
+
+ /**
+ * @class Cookie
+ * @constructor
+ */
+ var Cookie = function () {
+ this.initialize();
+ };
+
+ var p = Cookie.prototype;
+
+ /**
+ *
+ * Initialization method.
+ * @method initialize
+ */
+ p.initialize = function () {
+
+ };
+
+ /**
+ * Get cookie (public method)
+ *
+ * @param c_name
+ * @returns {string}
+ */
+ p.get = function (c_name) {
+
+ var i, x, y, ARRcookies = document.cookie.split(";");
+ for (i = 0; i < ARRcookies.length; i++) {
+ x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
+ y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
+ x = x.replace(/^\s+|\s+$/g, "");
+ if (x == c_name) {
+ return decodeURIComponent(y);
+ }
+ }
+ };
+
+ /**
+ * Set cookie (public method)
+ *
+ * @param c_name
+ * @param value
+ * @param expireDays
+ */
+ p.set = function (c_name, value, expireDays) {
+ var expireDate = new Date();
+ expireDate.setDate(expireDate.getDate() + expireDays);
+
+ var c_value = encodeURIComponent(value) + ((expireDays == null) ? "" : "; expires=" + expireDate.toUTCString()) + "; path=/;";
+ document.cookie = c_name + "=" + c_value;
+ };
+
+ wmpAppBanner.Cookie = Cookie;
+ }()
+); \ No newline at end of file