summaryrefslogtreecommitdiff
path: root/chimere/static
diff options
context:
space:
mode:
Diffstat (limited to 'chimere/static')
-rw-r--r--chimere/static/base.js22
-rw-r--r--chimere/static/main_map.js12
2 files changed, 23 insertions, 11 deletions
diff --git a/chimere/static/base.js b/chimere/static/base.js
index 3c7c575..449cc0f 100644
--- a/chimere/static/base.js
+++ b/chimere/static/base.js
@@ -1,5 +1,5 @@
/* base function shared by some pages */
-/* Copyright (C) 2009 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
+/* Copyright (C) 2009-2010 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -17,6 +17,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
See the file COPYING for details.
*/
+var default_area;
+var area_name;
+
/* show a block panel */
function show(id){
document.getElementById(id).style.display = 'block';
@@ -30,7 +33,9 @@ function hide(id){
function saveExtent() {
/* save the current extent in a cookie */
if(!map) return;
- document.cookie = "MAP_EXTENT=" + map.getExtent().toArray().join('_')
+ var extent_key = 'MAP_EXTENT';
+ if (area_name){ extent_key = extent_key + '_' + area_name; }
+ document.cookie = extent_key + "=" + map.getExtent().toArray().join('_')
+ ';path="/"';
}
@@ -38,10 +43,12 @@ function getExtent() {
/* get the current extent from a cookie */
var cookies = document.cookie.split(';');
var map_extent;
+ var extent_key = 'MAP_EXTENT';
+ if (area_name){ extent_key = extent_key + '_' + area_name; }
for (i in cookies){
var items = cookies[i].split('=');
key = items[0].split(' ').join('');
- if (key == 'MAP_EXTENT'){
+ if (key == extent_key){
map_extent = items[1].split('_');
}
}
@@ -51,13 +58,18 @@ function getExtent() {
function zoomToCurrentExtent(map){
/* zoom to current extent */
var current_extent = getExtent();
+ var extent;
if (OpenLayers && current_extent && current_extent.length == 4){
extent = new OpenLayers.Bounds(current_extent[0], current_extent[1],
current_extent[2], current_extent[3]);
- map.zoomToExtent(extent, true);
- return true;
+ }
+ else if (OpenLayers && default_area && default_area.length == 4){
+ extent = new OpenLayers.Bounds(default_area[1], default_area[0],
+ default_area[3], default_area[2]);
}
else{
return;
}
+ map.zoomToExtent(extent, true);
+ return true;
}
diff --git a/chimere/static/main_map.js b/chimere/static/main_map.js
index 52d694f..8137b03 100644
--- a/chimere/static/main_map.js
+++ b/chimere/static/main_map.js
@@ -50,7 +50,7 @@ function toggleCategory(item){
/* reopen the current opened categories when a redraw occurs */
function reOpenCurrent(){
- if (current_cat){
+ if (current_cat && current_cat != -1){
document.getElementById('maincategory_' + current_cat).style.display = 'block';
img = document.getElementById('maincategory_img_' + current_cat);
img.src = media_path + "icons/minus.png";
@@ -188,7 +188,7 @@ function zoomToCategory(category_id){
/* zoom to desired sub categories */
function zoomToSubCategory(subcategory_ids){
/* 0 stand for all categories */
- var uri = "/" + extra_url + "getGeoObjects/" + subcategory_ids;
+ var uri = extra_url + "getGeoObjects/" + subcategory_ids;
if (display_submited) uri += "/A_S";
OpenLayers.loadURL(uri, '', this, zoomToCategoryExtent);
}
@@ -223,7 +223,7 @@ function loadCategories(){
current_extent = current_extent.toArray().join('_')
current_extent = current_extent.replace(/\./g, 'D');
current_extent = current_extent.replace(/-/g, 'M');
- var uri = "/" + extra_url + "getAvailableCategories/" + current_extent;
+ var uri = extra_url + "getAvailableCategories/" + current_extent;
if (display_submited) uri += "/A_S";
OpenLayers.loadURL(uri, '', this, updateCategories);
}
@@ -242,7 +242,7 @@ function loadGeoObjects(){
updateCheckedCategories();
/* 0 stand for all categories */
if (!checked_categories) checked_categories = '0';
- var uri = "/" + extra_url + "getGeoObjects/" + checked_categories;
+ var uri = extra_url + "getGeoObjects/" + checked_categories;
if (display_submited) uri += "/A_S";
OpenLayers.loadURL(uri, '', this, setGeoObjects);
}
@@ -370,7 +370,7 @@ var refreshMapItems = function (evt) {
/* update current detail panel with an AJAX request */
function updateDetail(pk){
- var uri = "/" + extra_url + "getDetail/" + pk;
+ var uri = extra_url + "getDetail/" + pk;
OpenLayers.loadURL(uri, '', this, setDetail);
}
@@ -384,7 +384,7 @@ function setDetail(response){
/* show the detail of a category */
function displayCategoryDetail(category_id) {
- var uri = "/" + extra_url + "getDescriptionDetail/" + category_id;
+ var uri = extra_url + "getDescriptionDetail/" + category_id;
OpenLayers.loadURL(uri, '', this, setCategoryDetail);
}