[Mapbender-commits] r3273 - branches/beck_dev/http/javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon Dec 8 06:59:44 EST 2008


Author: beck
Date: 2008-12-08 06:59:43 -0500 (Mon, 08 Dec 2008)
New Revision: 3273

Added:
   branches/beck_dev/http/javascripts/mod_wmsByCookie.js
Log:


Added: branches/beck_dev/http/javascripts/mod_wmsByCookie.js
===================================================================
--- branches/beck_dev/http/javascripts/mod_wmsByCookie.js	                        (rev 0)
+++ branches/beck_dev/http/javascripts/mod_wmsByCookie.js	2008-12-08 11:59:43 UTC (rev 3273)
@@ -0,0 +1,37 @@
+mb_registerInitFunctions('wmsByCookie_init()');
+
+// Initialze
+function wmsByCookie_init() {
+	console.log($.toJSON(parent.wms[0]));return;
+	wmsByCookie_setCookies();
+	wmsByCookie_getCookies();
+}
+
+// Set cookie lifetime
+var cookieExpires  = new Date();
+var cookieValidity = cookieExpires.getTime() + (24 * 60 * 60 * 1000);
+cookieExpires.setTime(cookieValidity);
+
+// Set cookie for each WMS object
+function wmsByCookie_setCookies() {
+	for(var i = 0; i < parent.wms.length; i++) {
+		document.cookie = 'wms' + i + '=' + $.toJSON(parent.wms[i]) + ';expires=' + cookieExpires.toGMTString();
+	}
+}
+
+// Get stored WMS objects from cookie if available
+function wmsByCookie_getCookies() {
+	if(!document.cookie) {
+		return;
+	}
+	
+	var cookieData = document.cookie.split(';');
+	
+	for(var i = 0; i < cookieData.length; i++) {
+		if(!cookieData[i].match(/wms[0-9*]/)) {
+			continue;
+		}
+		
+		console.log(eval('(' + cookieData[i].replace(/wms[0-9*]=/,'') + ')'));
+	}
+}
\ No newline at end of file



More information about the Mapbender_commits mailing list