[Mapbender-commits] r3281 - branches/beck_dev/http/javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Tue Dec 9 06:32:38 EST 2008
Author: beck
Date: 2008-12-09 06:32:38 -0500 (Tue, 09 Dec 2008)
New Revision: 3281
Added:
branches/beck_dev/http/javascripts/mod_mapCookie.php
Log:
Added: branches/beck_dev/http/javascripts/mod_mapCookie.php
===================================================================
--- branches/beck_dev/http/javascripts/mod_mapCookie.php (rev 0)
+++ branches/beck_dev/http/javascripts/mod_mapCookie.php 2008-12-09 11:32:38 UTC (rev 3281)
@@ -0,0 +1,56 @@
+<?php
+# $Id: mod_mapCookie.php 264 2008-12-09 12:10:19Z beck
+# http://www.mapbender.org/index.php/mod_savewmc.php
+# Copyright (C) 2002 CCGIS
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__)."/../php/mb_validatePermission.php");
+
+echo "var mod_mapCookie_target = '".$e_target[0]."';";
+?>
+
+eventInit.register(restoreMapState);
+eventInit.register(triggerUnload);
+
+function restoreMapState() {
+ if(!document.cookie) {
+ return;
+ }
+}
+
+function storeMapState() {
+ var mapIndex = getMapObjIndexByName(mod_wmsByCookie_target);
+ var cookieData = {}
+ var cookieExpires = new Date();
+
+ cookieExpires.setTime(cookieExpires.getTime() + (24 * 60 * 60 * 1000));
+
+ cookieData.extent = $.toJSON(mb_mapObj[getMapObjIndexByName(mod_wmsByCookie_target)].extent);
+
+ document.cookie = 'stored_map_state=' + $.toJSON(cookieData) + ';expires=' + cookieExpires.toGMTString();
+}
+
+function triggerUnload() {
+ if(ie) {
+ document.getElementById('body').onunload = function() {
+ var trigger = new Function ('','storeMapState()');
+ trigger();
+ };
+ }
+ else {
+ document.getElementById('body').setAttribute('onunload','storeMapState();');
+ }
+}
\ No newline at end of file
More information about the Mapbender_commits
mailing list