From: <e_t...@us...> - 2007-07-31 21:35:51
|
Revision: 686 http://geonetwork.svn.sourceforge.net/geonetwork/?rev=686&view=rev Author: e_tajariol Date: 2007-07-31 14:35:52 -0700 (Tue, 31 Jul 2007) Log Message: ----------- Restruct and fixes for IE. Modified Paths: -------------- trunk/web/intermap/scripts/etj.js trunk/web/intermap/scripts/im_ajax.js trunk/web/intermap/scripts/im_bigmap.js trunk/web/intermap/scripts/im_layers.js trunk/web/intermap/scripts/im_minimap.js trunk/web/intermap/scripts/util.js Added Paths: ----------- trunk/web/intermap/scripts/im_extras.js Modified: trunk/web/intermap/scripts/etj.js =================================================================== --- trunk/web/intermap/scripts/etj.js 2007-07-31 13:51:25 UTC (rev 685) +++ trunk/web/intermap/scripts/etj.js 2007-07-31 21:35:52 UTC (rev 686) @@ -1,62 +1,99 @@ var minLayersDivWidth = 176; -function im_load() +/* +* The init procedure goes like this: +* - load minimap +* - enable the "Open Map Viewer" +* - wait for the "Open Map Viewer" command, then +* - load map viewer html skeleton +*/ +function im_init() { - imc_load(); + im_mm_initTextControls($('northBL'), $('eastBL'), $('southBL'), $('westBL')); + Event.observe('openIMBtn', 'click', function(){openIntermap()} ); + + //imc_load(); + im_mm_refreshNeeded(); // load minimap + im_mm_setTool('zoomin'); // set the default tool } -function imc_load() + +var im_1stTimeIntermap = true; + +function openIntermap() { + if(im_1stTimeIntermap) + { + im_1stTimeIntermap = false; + + $('openIMBtn').hide(); + $('loadIMBtn').show(); + + imc_init_loadSkel(); + return; // loadSkel should call us back + } + + $('openIMBtn').hide(); + $('loadIMBtn').hide(); + $('closeIMBtn').show(); + + //Effect.BlindDown('im_mapContainer'); + Effect.BlindDown('im_map'); + Effect.BlindDown('im_mapImg'); + Effect.BlindDown('fillMeWithIntermap'); + //$('intermap').style.display='block'; +} + +function closeIntermap() +{ + $('closeIMBtn').hide(); + $('openIMBtn').show(); + + //Effect.BlindUp('im_mapContainer'); + Effect.BlindUp('im_map'); + Effect.BlindUp('fillMeWithIntermap'); + //$('intermap').style.display='none'; +} + +function imc_init_loadSkel() +{ var myAjax = new Ajax.Request ( '/intermap/srv/en/map.getMain.embedded', { method: 'get', parameters: '', - onSuccess: im_load_complete, + onSuccess: ker.wrap(this, im_init_loadCompleted), onFailure: im_load_error } ); } +// onSuccess: ker.wrap(this, im_load_complete), -function im_load_error() -{ - alert("Loading error"); -} -function im_load_complete(req) +function im_init_loadCompleted(req) { // Dinamically generate content - var im = $('intermap'); - copyTree(req.responseXML.documentElement.getElementsByTagName('html')[0].firstChild , im); - + var im = $('fillMeWithIntermap'); + im.innerHTML = req.responseText; $('im_mm_wait').hide(); //style.display='none'; - $('openIMBtn').textContent="Open Map Viewer"; - $('openIMBtn').className="imenabled"; - Event.observe('openIMBtn', 'click', function(){openIntermap()} ); new Effect.Pulsate('openIMBtn'); - - var bm =req.responseXML.documentElement.getElementsByTagName('bigmap')[0]; - var mm =req.responseXML.documentElement.getElementsByTagName('minimap')[0]; - - //im_setMapSize(368,276); -// var height = getWindowSize()[1]; // - Element.getHeight('banner'); -// $('im_layers').style.height = height + 'px'; - + + refreshNeeded(false, im_init_bmLoaded); +} + +function im_init_bmLoaded() +{ Event.observe('im_map', 'mousedown', mousedownEventListener); Event.observe('im_mm_map', 'mousedown', im_mm_mousedownEventListener); - setTool('zoomin'); // set the default tool - im_mm_setTool('zoomin'); // set the default tool - + setTool('zoomin'); // set the default tool imc_reloadLayers(); // append layers to list - im_mm_initTextControls($('northBL'), $('eastBL'), $('southBL'), $('westBL')) - - im_mm_set(mm); - im_bm_set(bm); + openIntermap(); } + function im_reset() { setStatus('busy'); @@ -68,10 +105,9 @@ function imc_reset() { var myAjax = new Ajax.Request ( - '/intermap/srv/en/map.getMain.embedded', + '/intermap/srv/en/map.reset', //'/intermap/srv/en/map.getMain.embedded', { method: 'get', - parameters: 'reset=true', onSuccess: im_reset_complete, onFailure: im_load_error } @@ -85,14 +121,8 @@ imc_reloadLayers(); // append layers to list - var bm =req.responseXML.documentElement.getElementsByTagName('bigmap')[0]; - var mm =req.responseXML.documentElement.getElementsByTagName('minimap')[0]; - - im_mm_set(mm); - im_bm_set(bm); - - setStatus('idle'); - im_mm_setStatus('idle'); + imc_updateBigMap(im_bm_width, im_bm_height, null, false, + function() { imc_mm_update(im_mm_width, im_mm_height, null);}); } @@ -119,348 +149,3 @@ // TODO } -/* -## Called by the bottom toolbar -*/ -function im_addLayer() -{ - imc_loadMapServers( im_mapServersLoaded ); -} - -/* -## Display the map servers and allow to select one of them -*/ -function im_mapServersLoaded(req) -{ - // setup WB - clearNode('im_whiteboard'); - var WB = $('im_whiteboard'); - - var wbtitle = im_createWBTitle('Add a layer'); //FIXME i18n - WB.appendChild(wbtitle); - - var closer = im_getWBCloser(); - WB.appendChild(closer); - Event.observe(closer, 'click', im_closeWhiteBoard); - - // fill contents - - var servers = req.responseXML.documentElement.getElementsByTagName('mapServers')[0].getElementsByTagName('server'); - - var div = document.createElement('div'); // main box - div.id = "im_serverList"; - div.className = 'im_wbcontent'; - WB.appendChild(div); - - var h1 = document.createElement('h1'); - h1.textContent = "Server list " ; //FIXME i18n me! - h1.id = "im_serverList_title"; - div.appendChild(h1); - - var ul = document.createElement('ul'); - ul.id = "im_serverList_list"; - div.appendChild(ul); - - $A(servers).each( - function(server) - { - var id=server.getAttribute('id'); - var name =server.getAttribute('name'); - - var li = document.createElement('li'); - ul.appendChild(li); - - var a = document.createElement('a'); - a.textContent = name; - a.id = "im_mapserver_" + id; - a.setAttribute("onClick", "im_mapServerSelected("+id+",'"+name+"');"); - li.appendChild(a); - -// Event.observe(li, 'click', function(){ imc_loadServices(id, im_servicesLoaded )} ); - } - ); - - // add a textbox to enter a server directly - var li = document.createElement('li'); - li.textContent = 'Other WMS server'; // FIXME i18n - ul.appendChild(li); - - var input = document.createElement('input'); - input.id= "im_wmsservername"; - input.className = 'content'; - input.setAttribute("type", "text"); - input.setAttribute("size", "40"); - li.appendChild(input); - - var button = document.createElement('button'); - button.textContent = "Connect"; // FIXME i18n - li.appendChild(button); - - Event.observe(button, "click", function() { im_mapServerURL($('im_wmsservername').value);}); -} - -/* -## Called when a known map server has been selected -*/ -function im_mapServerSelected(id, name) -{ - var im = $('im_serverList'); - clearNode(im); - - var t1 = document.createElement("p"); - t1.textContent = "...please wait..."; - im.appendChild(t1); - - var t2 = document.createElement("p"); - t2.textContent = "Loading services from " +name; - im.appendChild(t2); - - imc_loadServerServices(id, im_servicesLoaded ); -} - -function imc_loadServerServices(id, callback) -{ - var url = '/intermap/srv/en/mapServers.getServices.embedded'; - var pars = 'mapserver='+id ; - - var myAjax = new Ajax.Request ( - url, - { - method: 'get', - parameters: pars, - onSuccess: callback, - onFailure: im_load_error - } - ); -} - -/* -## Called when the URL of an unknown map server has been given -*/ -function im_mapServerURL(url) -{ - var im = $('im_serverList'); - clearNode(im); - - var t1 = document.createElement("p"); - t1.textContent = "...please wait..."; - im.appendChild(t1); - - var t2 = document.createElement("p"); - t2.textContent = "Loading services from given WMS server"; - im.appendChild(t2); - - imc_loadURLServices(url, -2, im_servicesLoaded ); -} - -function imc_loadURLServices(url, type, callback) -{ - var pars = 'mapserver='+type+"&url="+url ; - - var myAjax = new Ajax.Request ( - '/intermap/srv/en/mapServers.getServices.embedded', - { - method: 'get', - parameters: pars, - onSuccess: callback, - onFailure: im_load_error - } - ); -} - -function im_servicesLoaded(req) -{ - // Dinamically generate content - var im = $('im_serverList'); - im.innerHTML =req.responseText; -} - -/* -## Called by the ok button generated by service mapServers.getServices.embedded -*/ -function im_servicesSelected() -{ - var im = $('im_serverList'); - - // next two elements are created by the mapServers.getServices.embedded service - var url = $('im_addlayer_serverurl').value; - var type = $('im_addlayer_type').value; - - var services = new Array(); - //var query = "url="+url+"&type="+type; - - var lilist = im.getElementsByTagName("input"); - - $A(lilist).each( - function (input) - { - var value = input.value; - var checked = input.checked; - - if(checked) - { - services.push(value); - //query += "&service="+value; - } - } - - - ); - - //alert(query); - - setStatus('busy'); - imc_addServices(url, services, type, im_servicesAdded); - -} - -function im_servicesAdded(req) -{ - var im = $('im_serverList'); - clearNode(im); - - var t1 = document.createElement("p"); - t1.textContent = "Selected layers have been added"; // fixme i18n - im.appendChild(t1); - - im_buildLayerList(req); // rebuild layers' list - - //imc_reloadLayers(); - - // refreshes should be chained - refreshNeeded(); // refresh big map - // im_mm_refreshNeeded(); // refresh minimap - -} - -/******************************************************************** -*** MAIL -********************************************************************/ -/* -## Called by the bottom toolbar -*/ -function im_sendMail() -{ - clearNode('im_whiteboard'); - - var div = document.createElement('div'); - div.id = "im_sendMail"; - div.className = 'im_wbcontent'; - $('im_whiteboard').appendChild(div); - - var wbtitle = im_createWBTitle("Send this map's context"); //FIXME i18n - div.appendChild(wbtitle); - - var closer = im_getWBCloser(); - div.appendChild(closer); - Event.observe(closer, 'click', im_closeWhiteBoard); - - var h1 = document.createElement('h1'); - h1.textContent = "Send this map context" ; //FIXME i18n - div.appendChild(h1); - - - var input = document.createElement('input'); - input.setAttribute('name', 'emailaddress'); - input.setAttribute('size', '35'); - input.setAttribute('value', 'user@domain'); - div.appendChild(input); - -} - -/******************************************************************** -*** PDF -********************************************************************/ -/* -## Called by the bottom toolbar -*/ -function im_createPDF() -{ - clearNode('im_whiteboard'); - - var div = document.createElement('div'); - div.id = "im_createPDF"; - div.className = 'im_wbcontent'; - $('im_whiteboard').appendChild(div); - - var wbtitle = im_createWBTitle("Export this map as PDF"); //FIXME i18n - div.appendChild(wbtitle); - - var closer = im_getWBCloser(); - div.appendChild(closer); - Event.observe(closer, 'click', im_closeWhiteBoard); - - var h1 = document.createElement('h1'); - h1.textContent = "TODO" ; //FIXME i18n - div.appendChild(h1); - -} - -/******************************************************************** -*** Export image -********************************************************************/ -/* -## Called by the bottom toolbar -*/ -function im_createPic() -{ - clearNode('im_whiteboard'); - - var div = document.createElement('div'); - div.id = "im_createPic"; - $('im_whiteboard').appendChild(div); - - var wbtitle = im_createWBTitle("Export this map as image"); //FIXME i18n - div.appendChild(wbtitle); - - var closer = im_getWBCloser(); - div.appendChild(closer); - Event.observe(closer, 'click', im_closeWhiteBoard); - - var h1 = document.createElement('h1'); - h1.textContent = "TODO" ; //FIXME i18n - div.appendChild(h1); - -} - -/******************************************************************** -*** SUB TOOLBAR UTILITIES -********************************************************************/ - -function im_createWBTitle(title) -{ - var div = document.createElement('div'); - div.id = "im_wbtitle"; - var h1 = document.createElement('h1'); - h1.textContent = title; - div.appendChild(h1); - -// Effect.BlindDown('im_whiteboard'); - - return div; -} - - -function im_getWBCloser() -{ - var closer = document.createElement('div'); - closer.id = "im_wbcloser"; - var img = document.createElement('img'); - img.setAttribute("title", "Close"); // FIXME i18N - img.setAttribute("src", "/intermap/images/close.png"); - closer.appendChild(img); - - //Event.observe(closer, 'click', im_closeWhiteBoard); - - return closer; -} - -function im_closeWhiteBoard() -{ -// Effect.SwitchOff('im_whiteboard'); -// Effect.BlindUp('im_whiteboard'); - clearNode('im_whiteboard'); -} - - - Modified: trunk/web/intermap/scripts/im_ajax.js =================================================================== --- trunk/web/intermap/scripts/im_ajax.js 2007-07-31 13:51:25 UTC (rev 685) +++ trunk/web/intermap/scripts/im_ajax.js 2007-07-31 21:35:52 UTC (rev 686) @@ -3,6 +3,8 @@ var activeLayerId = null; // active layer +im_load_error = function() {alert("Loading error")}; + function imc_reloadLayers() { var url = '/intermap/srv/en/map.layers.getOrder'; @@ -297,23 +299,34 @@ * * *****************************************************************************/ -function imc_updateBigMap(width, height, qbbox) + +function imc_updateBigMap(width, height, qbbox, doUpdateMM, callback) { - setStatus('busy'); - - var url = '/intermap/srv/en/map.update'; + if(doUpdateMM == null) + followmm = true; + + var pars = "width=" + width + "&height=" + height; + if(qbbox) + pars += "&" + qbbox; + + setStatus('busy'); - var pars = "width=" + width + "&height=" + height + "&" + qbbox; - - var myAjax = new Ajax.Request ( - url, - { - method: 'get', - parameters: pars, - onComplete: updateMapImage, - onFailure: reportError - } - ); + var myAjax = new Ajax.Request ( + '/intermap/srv/en/map.update', + { + method: 'get', + parameters: pars, + onComplete: function(req) { + updateMapImage(req); + if( doUpdateMM ) + // !!! check if this refresh is not due to a minimap action, or we'll get a refresh loop !!! + imc_mm_update(im_mm_width, im_mm_height, im_dezoom(im_bm_north, im_bm_east, im_bm_south, im_bm_west)); + if(callback) + callback(); + }, + onFailure: reportError + } + ); } function imc_mm_update(width, height, qbbox) @@ -322,7 +335,9 @@ var url = '/intermap/srv/en/map.update'; - var pars = "width=" + width + "&height=" + height + "&" + qbbox; + var pars = "width=" + width + "&height=" + height; + if(qbbox) + pars += "&" + qbbox var myAjax = new Ajax.Request ( url, @@ -342,20 +357,22 @@ * * *****************************************************************************/ -function fullExtentButtonListener() +function imc_bm_fullExtent(w,h) { setStatus('busy'); deleteAoi(); - if (currentTool == 'zoomout' || currentTool == 'pan') setTool('zoomin'); - - var url = '/intermap/srv/en/map.fullExtent'; - + if (currentTool == 'zoomout' || currentTool == 'pan') + setTool('zoomin'); + + var pars = "width=" + w + "&height="+h; + var myAjax = new Ajax.Request ( - url, + '/intermap/srv/en/map.fullExtent', { method: 'get', + parameters: pars, onComplete: updateMapImage, onFailure: reportError } @@ -371,12 +388,10 @@ if (im_mm_currentTool == 'zoomout' || im_mm_currentTool == 'pan') im_mm_setTool('zoomin'); - var url = '/intermap/srv/en/map.fullExtent'; - var pars = "width=" + w + "&height="+h - - + var pars = "width=" + w + "&height="+h; + var myAjax = new Ajax.Request ( - url, + '/intermap/srv/en/map.fullExtent', { method: 'get', parameters: pars, @@ -392,8 +407,6 @@ * * *****************************************************************************/ - - function addLayer(baseUrl, serviceName) // DEBUG { setStatus('busy'); @@ -416,7 +429,7 @@ // improve me: this setting should be implemented client-side // this setting refers to big map only, while ajax calls should be independent from which map are they called on -function imc_toggleImageSize() +/*function imc_toggleImageSize() { deleteAoi(); unsetAoi(); @@ -433,24 +446,19 @@ } ); } - +*/ // improve me: this setting should be implemented client-side // this setting refers to big map only, while ajax calls should be independent from which map are they called on -function im_imageSizeToggled(req) +/*function im_imageSizeToggled(req) { var w = req.responseXML.getElementsByTagName('width')[0].firstChild.nodeValue; var h = req.responseXML.getElementsByTagName('height')[0].firstChild.nodeValue; im_bm_setSize(w,h); - - //$('im_mapImg').style.width = w; - //$('im_mapImg').style.height = h; - //$('im_map').style.width = w; - //$('im_map').style.height = h; - + imc_updateBigMap(im_bm_width, im_bm_height, im_bm_getURLbbox()); } - +*/ function imc_addService(surl, service, type, callback) { var url = '/intermap/srv/en/map.addServicesExt'; @@ -484,7 +492,7 @@ var myAjax = new Ajax.Request ( url, { - method: 'get', + method: 'post', parameters: pars, onComplete: callback, Modified: trunk/web/intermap/scripts/im_bigmap.js =================================================================== --- trunk/web/intermap/scripts/im_bigmap.js 2007-07-31 13:51:25 UTC (rev 685) +++ trunk/web/intermap/scripts/im_bigmap.js 2007-07-31 21:35:52 UTC (rev 686) @@ -17,17 +17,27 @@ * Main vars and setup * *****************************************************************************/ + + // these are the values of standard width and height. + // It starts with Xsize0, and then toggles to 1 and back again at user request. + + var im_bm_wsize0 = 368; + var im_bm_hsize0 = 276; + var im_bm_wsize1 = 580; + var im_bm_hsize1 = 435; +// Current image size +var im_bm_width = im_bm_wsize0; +var im_bm_height = im_bm_hsize0; + // Current bounding box var im_bm_north, im_bm_east, im_bm_south, im_bm_west; -// Current image size -var im_bm_width, im_bm_height; // Parse a response and set bm props accordingly function im_bm_set(bmResponse) { // Image URL - var url = bmResponse.getElementsByTagName('imgUrl')[0].textContent; + var url = bmResponse.getElementsByTagName('imgUrl')[0].firstChild.nodeValue; $('im_mapImg').src = url; // BBox @@ -38,8 +48,8 @@ var maxy = extent.getAttribute('maxy'); // Image size - var w = bmResponse.getElementsByTagName('width')[0].textContent; - var h = bmResponse.getElementsByTagName('height')[0].textContent; + var w = bmResponse.getElementsByTagName('width')[0].firstChild.nodeValue; + var h = bmResponse.getElementsByTagName('height')[0].firstChild.nodeValue; im_bm_setMapBB(maxy, maxx, miny, minx); im_bm_setSize(w, h); @@ -78,12 +88,11 @@ $('im_mapContainer').style.width = new Number(w)+2; $('im_mapContainer').style.height = new Number(h)+2; - $('im_map').style.width = w; //<xsl:value-of select="/root/response/mapRoot/response/imageWidth" /> + 'px'; - $('im_map').style.height = h; //<xsl:value-of select="/root/response/mapRoot/response/imageHeight" /> + 'px'; + $('im_map').style.width = w; + $('im_map').style.height = h; $('im_pleaseWait').style.width = w; -/* $('im_pleaseWait').style.height = h; - $('im_pleaseWait').style.top = h/2;*/ + } @@ -114,7 +123,8 @@ deleteAoi(); currentTool = tool; $('intermap_root').className = tool; //document.body.className = tool; - if (tool != 'aoi') $('im_geonetRecords').className = 'im_hidden'; +/* if (tool != 'aoi') + $('im_geonetRecords').className = 'im_hidden';*/ } @@ -853,11 +863,11 @@ while (target.childNodes.length > 0) {target.removeChild(target.childNodes[target.childNodes.length - 1]);} } -function refreshNeeded() +function refreshNeeded(refreshmm, callback) { if (autoRefresh) { - imc_updateBigMap(im_bm_width, im_bm_height, im_bm_getURLbbox()); + imc_updateBigMap(im_bm_width, im_bm_height, im_bm_getURLbbox(), refreshmm, callback); } else { @@ -867,7 +877,7 @@ function setStatus(status) { - var refreshButton = $('im_refreshButton'); +/* var refreshButton = $('im_refreshButton');*/ switch(status) { @@ -883,8 +893,8 @@ $('im_map').style.cursor = 'wait' // change refresh button status - refreshButton.className = 'im_disabled'; - refreshButton.disabled = true; +/* refreshButton.className = 'im_disabled'; + refreshButton.disabled = true;*/ $('im_pleaseWait').show(); //style.display = 'block'; break; @@ -895,15 +905,15 @@ // change refresh button status $('im_map').style.cursor = 'crosshair' - refreshButton.className = 'im_disabled'; - refreshButton.disabled = true; +/* refreshButton.className = 'im_disabled'; + refreshButton.disabled = true;*/ $('im_pleaseWait').hide(); //style.display = 'none'; break; case 'refresh': // refresh buton highlighted - means that refresh is needed after the user made some operations on layers // change refresh button status - refreshButton.className = 'im_refresh'; - refreshButton.disabled = false; +/* refreshButton.className = 'im_refresh'; + refreshButton.disabled = false;*/ break; } } @@ -925,14 +935,34 @@ imc_reloadLayers(); } -function resizeImage() +function im_bm_toggleImageSize() { - imc_toggleImageSize(); + // Set width + if( im_bm_width == im_bm_wsize0 ) + im_bm_width = im_bm_wsize1; + else + im_bm_width = im_bm_wsize0; + + // Set height + if( im_bm_height == im_bm_hsize0 ) + im_bm_height = im_bm_hsize1; + else + im_bm_height = im_bm_hsize0; + + deleteAoi(); + unsetAoi(); + + // Reload image + imc_updateBigMap(im_bm_width, im_bm_height, im_bm_getURLbbox(), false); +// imc_toggleImageSize(); } +function im_bm_fullExtent() +{ + imc_bm_fullExtent(im_bm_width, im_bm_height); +} - /***************************************************************************** * * Keyboard events @@ -987,11 +1017,5 @@ // Event.observe(vMapImg, 'load', function(e) { setStatus('idle') }); // better behaviour but needs debugging on explorer (newer version of prototype?) setStatus('idle'); - - - // the minimap must follow the bigger map - // !!! TODO check if this refresh is not due to a minimap action, or we'll get a refresh loop !!! - - imc_mm_update(im_mm_width, im_mm_height, im_dezoom(im_bm_north, im_bm_east, im_bm_south, im_bm_west)); } Added: trunk/web/intermap/scripts/im_extras.js =================================================================== --- trunk/web/intermap/scripts/im_extras.js (rev 0) +++ trunk/web/intermap/scripts/im_extras.js 2007-07-31 21:35:52 UTC (rev 686) @@ -0,0 +1,355 @@ +/*\xB0******************************************************** +* im_extras.js +* +* This file contains functions related to the intermap extra features +* ie the ones the user can call via the buttons below the bigger map. +* +*\xB0********************************************************/ + +/******************************************************************** +*** LAYERS +********************************************************************/ +/* +## Called by the bottom toolbar +*/ +function im_addLayer() +{ + imc_loadMapServers( im_mapServersLoaded ); +} + +/* +## Display the map servers and allow to select one of them +*/ +function im_mapServersLoaded(req) +{ + // setup WB + clearNode('im_whiteboard'); + var WB = $('im_whiteboard'); + + var wbtitle = im_createWBTitle('Add a layer'); //FIXME i18n + WB.appendChild(wbtitle); + + var closer = im_getWBCloser(); + WB.appendChild(closer); + Event.observe(closer, 'click', im_closeWhiteBoard); + + // fill contents + + var servers = req.responseXML.documentElement.getElementsByTagName('mapServers')[0].getElementsByTagName('server'); + + var div = document.createElement('div'); // main box + div.id = "im_serverList"; + div.className = 'im_wbcontent'; + WB.appendChild(div); + + var h1 = document.createElement('h1'); + h1.innterHTML = "Server list " ; //FIXME i18n me! + h1.id = "im_serverList_title"; + div.appendChild(h1); + + var ul = document.createElement('ul'); + ul.id = "im_serverList_list"; + div.appendChild(ul); + + $A(servers).each( + function(server) + { + var id=server.getAttribute('id'); + var name =server.getAttribute('name'); + + var li = document.createElement('li'); + ul.appendChild(li); + + var a = document.createElement('a'); + a.innerHTML = name; + a.id = "im_mapserver_" + id; + //a.setAttribute("onClick", "im_mapServerSelected("+id+",'"+name+"');"); + li.appendChild(a); + + Event.observe(li, 'click', function(){ im_mapServerSelected(id, name )} ); + } + ); + + // add a textbox to enter a server directly + var li = document.createElement('li'); + li.innerHTML = 'Other WMS server'; // FIXME i18n + ul.appendChild(li); + + var input = document.createElement('input'); + input.id= "im_wmsservername"; + input.className = 'content'; + input.setAttribute("type", "text"); + input.setAttribute("size", "40"); + li.appendChild(input); + + var button = document.createElement('button'); + button.innerHTML = "Connect"; // FIXME i18n + li.appendChild(button); + + Event.observe(button, "click", function() { im_mapServerURL($('im_wmsservername').value);}); +} + +/* +## Called when a known map server has been selected +*/ +function im_mapServerSelected(id, name) +{ + var im = $('im_serverList'); + clearNode(im); + + var t1 = Builder.node("p"); + t1.innerHTML = "...please wait..."; + im.appendChild(t1); + + var t2 = document.createElement("p"); + t2.innerHTML = "Loading services from " +name; + im.appendChild(t2); + + imc_loadServerServices(id, im_servicesLoaded ); +} + +function imc_loadServerServices(id, callback) +{ + var url = '/intermap/srv/en/mapServers.getServices.embedded'; + var pars = 'mapserver='+id ; + + var myAjax = new Ajax.Request ( + url, + { + method: 'get', + parameters: pars, + onSuccess: callback, + onFailure: im_load_error + } + ); +} + +/* +## Called when the URL of an unknown map server has been given +*/ +function im_mapServerURL(url) +{ + var im = $('im_serverList'); + clearNode(im); + + var t1 = document.createElement("p"); + t1.innerHTML = "...please wait..."; + im.appendChild(t1); + + var t2 = document.createElement("p"); + t2.innerHTML = "Loading services from given WMS server"; + im.appendChild(t2); + + imc_loadURLServices(url, -2, im_servicesLoaded ); +} + +function imc_loadURLServices(url, type, callback) +{ + var pars = 'mapserver='+type+"&url="+url ; + + var myAjax = new Ajax.Request ( + '/intermap/srv/en/mapServers.getServices.embedded', + { + method: 'get', + parameters: pars, + onSuccess: callback, + onFailure: im_load_error + } + ); +} + +function im_servicesLoaded(req) +{ + // Dinamically generate content + var im = $('im_serverList'); + im.innerHTML =req.responseText; +} + +/* +## Called by the ok button generated by service mapServers.getServices.embedded +*/ +function im_servicesSelected() +{ + var im = $('im_serverList'); + + // next two elements are created by the mapServers.getServices.embedded service + var url = $('im_addlayer_serverurl').value; + var type = $('im_addlayer_type').value; + + var services = new Array(); + //var query = "url="+url+"&type="+type; + + var lilist = im.getElementsByTagName("input"); + + $A(lilist).each( + function (input) + { + var value = input.value; + var checked = input.checked; + + if(checked) + { + services.push(value); + //query += "&service="+value; + } + } + + + ); + + //alert(query); + + setStatus('busy'); + imc_addServices(url, services, type, im_servicesAdded); + +} + +function im_servicesAdded(req) +{ + var im = $('im_serverList'); + clearNode(im); + + var t1 = document.createElement("p"); + t1.innerHTML = "Selected layers have been added"; // fixme i18n + im.appendChild(t1); + + im_buildLayerList(req); // rebuild layers' list + + //imc_reloadLayers(); + + // refreshes should be chained + refreshNeeded(); // refresh big map + // im_mm_refreshNeeded(); // refresh minimap + +} + +/******************************************************************** +*** MAIL +********************************************************************/ +/* +## Called by the bottom toolbar +*/ +function im_sendMail() +{ + clearNode('im_whiteboard'); + + var div = document.createElement('div'); + div.id = "im_sendMail"; + div.className = 'im_wbcontent'; + $('im_whiteboard').appendChild(div); + + var wbtitle = im_createWBTitle("Send this map's context"); //FIXME i18n + div.appendChild(wbtitle); + + var closer = im_getWBCloser(); + div.appendChild(closer); + Event.observe(closer, 'click', im_closeWhiteBoard); + + var h1 = document.createElement('h1'); + h1.innerHTML = "Send this map context" ; //FIXME i18n + div.appendChild(h1); + + + var input = document.createElement('input'); + input.setAttribute('name', 'emailaddress'); + input.setAttribute('size', '35'); + input.setAttribute('value', 'user@domain'); + div.appendChild(input); + +} + +/******************************************************************** +*** PDF +********************************************************************/ +/* +## Called by the bottom toolbar +*/ +function im_createPDF() +{ + clearNode('im_whiteboard'); + + var div = document.createElement('div'); + div.id = "im_createPDF"; + div.className = 'im_wbcontent'; + $('im_whiteboard').appendChild(div); + + var wbtitle = im_createWBTitle("Export this map as PDF"); //FIXME i18n + div.appendChild(wbtitle); + + var closer = im_getWBCloser(); + div.appendChild(closer); + Event.observe(closer, 'click', im_closeWhiteBoard); + + var h1 = document.createElement('h1'); + h1.innerHTML = "TODO" ; //FIXME i18n + div.appendChild(h1); + +} + +/******************************************************************** +*** Export image +********************************************************************/ +/* +## Called by the bottom toolbar +*/ +function im_createPic() +{ + clearNode('im_whiteboard'); + + var div = document.createElement('div'); + div.id = "im_createPic"; + $('im_whiteboard').appendChild(div); + + var wbtitle = im_createWBTitle("Export this map as image"); //FIXME i18n + div.appendChild(wbtitle); + + var closer = im_getWBCloser(); + div.appendChild(closer); + Event.observe(closer, 'click', im_closeWhiteBoard); + + var h1 = document.createElement('h1'); + h1.innerHTML = "TODO" ; //FIXME i18n + div.appendChild(h1); + +} + +/******************************************************************** +*** SUB TOOLBAR UTILITIES +********************************************************************/ + +function im_createWBTitle(title) +{ + var div = Builder.node('div', {id: "im_wbtitle"}); + var h1 = Builder.node('h1'); + h1.innerHTML = title; + div.appendChild(h1); + +// Effect.BlindDown('im_whiteboard'); + + return div; +} + + +function im_getWBCloser() +{ + var closer = Builder.node('div', {id: "im_wbcloser"}); + var img = Builder.node('img', + { + title: "Close", // FIXME i18N + src: "/intermap/images/close.png" + }); + closer.appendChild(img); + + //Event.observe(closer, 'click', im_closeWhiteBoard); + return closer; +} + +function im_closeWhiteBoard() +{ +// Effect.SwitchOff('im_whiteboard'); +// Effect.BlindUp('im_whiteboard'); + clearNode('im_whiteboard'); +} + + + Modified: trunk/web/intermap/scripts/im_layers.js =================================================================== --- trunk/web/intermap/scripts/im_layers.js 2007-07-31 13:51:25 UTC (rev 685) +++ trunk/web/intermap/scripts/im_layers.js 2007-07-31 21:35:52 UTC (rev 686) @@ -1,3 +1,8 @@ +/***************************************************************************** + * + * Functions related to layers handling + * + *****************************************************************************/ // Builds the layer list function im_buildLayerList(req) @@ -2,2 +7,5 @@ { + if( ! $('im_layersDiv') ) // map viewer not yet loaded + return; + var layers = req.responseXML.getElementsByTagName('layer'); @@ -11,129 +19,148 @@ // add each layer to the list for (var i = 0; i < layers.length; i++) { - var title = document.createTextNode(layers[i].getAttribute('title')); +// alert('Adding layer ' + layers[i].getAttribute('title')); + var title = Builder.node('p',{},layers[i].getAttribute('title')); +// var title = document.createTextNode(layers[i].getAttribute('title')); + var id = layers[i].getAttribute('id'); var transp = layers[i].getAttribute('transparency'); var addup = i>0; var adddown = (i<layers.length-1)&&(layers.length>1); - + +//zalert('Appending layer ' + layers[i].getAttribute('title')); appendToLayerList(ul, title, id, transp,addup, adddown); } + createSortable(); + // activate the first layer if none active if (!activeLayerId) - activateMapLayer(layers[0].getAttribute('id')); + activateMapLayer(layers[0].getAttribute('id')); } // Appends a single layer to the layer list function appendToLayerList(list, title, id, transp, addup, adddown) // layer in a TABLEs layout { - var li = document.createElement('li'); - li.setAttribute('id', 'layerList_' + id); + var li = Builder.node('li', {id: 'layerList_' + id}); - var toggleLayer = document.createElement('img'); - toggleLayer.id= 'layerButtonToggle'; - toggleLayer.className = 'im_layerControl'; - toggleLayer.setAttribute('src','/intermap/images/showLayer.png'); - toggleLayer.setAttribute('title','Toggle layer visibility'); // FIXME: i18n this string - toggleLayer.setAttribute('id','visibility_' + id); + var toggleLayer = Builder.node('img' , + { + id: 'visibility_' + id, + className: 'im_layerControl', + src: '/intermap/images/showLayer.png', + title:'Toggle layer visibility' // FIXME: i18n this string + }); - var delLayer = document.createElement('img'); - delLayer.id = 'layerButtonDelete'; - delLayer.className = 'im_layerButton'; - delLayer.setAttribute('src','/intermap/images/deleteLayer.png'); - delLayer.setAttribute('title','Remove layer'); // FIXME: i18n this string - delLayer.setAttribute('id','deleteLayer_' + id); + var delLayer = Builder.node('img', + { + id: 'deleteLayer_' + id, + className: 'im_layerButton', + src: '/intermap/images/deleteLayer.png', + title: 'Remove layer' // FIXME: i18n this string + }); - var showLayerMD = document.createElement('img'); - showLayerMD.id = 'layerButtonShowMD'; - showLayerMD.className = 'im_layerButton'; - showLayerMD.setAttribute('src','/intermap/images/info.png'); - showLayerMD.setAttribute('title','Show metadata'); // FIXME: i18n this string - showLayerMD.setAttribute('id','showLayerMD_' + id); + var showLayerMD = Builder.node('img', + { + id: 'showLayerMD_' + id, + className: 'im_layerButton', + src: '/intermap/images/info.png', + title: 'Show metadata' // FIXME: i18n this string + }); - var legend = document.createElement('img'); - legend.id = 'layerLegend'; - legend.className = 'im_layerButton'; - legend.setAttribute('src','/intermap/images/legend.png'); - legend.setAttribute('title','Show legend'); // FIXME: i18n this string - legend.setAttribute('id','legend_' + id); - + var legend = Builder.node('img', + { + id: 'legend_' + id, + className: 'im_layerButton', + src: '/intermap/images/legend.png', + title: 'Show legend' // FIXME: i18n this string + }); + +/* var trans = Builder.node('select', + { + id: "im_transp_"+id, + className: "layerSelectTransp" + }); +*/ var trans = document.createElement('select'); - trans.className = "layerSelectTransp"; - trans.id="im_transp_"+id; - - var opt = document.createElement('OPTION'); - opt.setAttribute("value", 100); - opt.innerHTML="opaque"; - trans.appendChild(opt); - - for (var t = 90; t >= 0; t-=10) { - var opt = document.createElement('OPTION'); + trans.setAttribute("id", "im_transp_"+id); + trans.setAttribute("className", "layerSelectTransp"); + + for (var t = 100; t >= 0; t-=10) { + var opt = document.createElement('option'); opt.setAttribute("value", t); if(transp==t) - opt.setAttribute("selected", 'true'); - opt.innerHTML=t+"%"; + { + //alert ("Transp for " + title + " is set at " + t); + opt.setAttribute('selected', 'true'); + } + var label = t+"%"; + if(t==100) + label = "opaque"; // FIXME i18n + + opt.innerHTML=label; trans.appendChild(opt); } // do layout list.appendChild(li); - var table = document.createElement('table'); + var table = Builder.node('table'); li.appendChild(table); + + var tbody = Builder.node('tbody'); + table.appendChild(tbody); - var trmainicons = document.createElement('tr'); - table.appendChild(trmainicons); - var tdmainicons = document.createElement('td'); - tdmainicons.setAttribute("rowspan","2"); - tdmainicons.setAttribute("height","35px"); - tdmainicons.className = 'im_layerControl'; + var trmainicons = Builder.node('tr'); + tbody.appendChild(trmainicons); + + var tdmainicons = Builder.node('td', + { + rowspan: "2", + height: "35px", + className: 'im_layerControl' + }); + trmainicons.appendChild(tdmainicons); tdmainicons.appendChild(toggleLayer); - if(addup) { - var upbtn = document.createElement('img'); - upbtn.id = 'im_layerControlUp'; - upbtn.className = 'im_layerControl'; - upbtn.setAttribute('src','/intermap/images/im_moveup.gif'); - upbtn.setAttribute('title','Move layer up'); // FIXME: i18n this string - //upbtn.setAttribute('id','showLayerMD_' + id); + var upbtn = Builder.node('img', + { + id: 'im_layerUp_'+id, + className: 'im_layerControl', + //style: 'position:absolute; bottom:3px;', + src: '/intermap/images/im_moveup.gif', + title: 'Move layer up' // FIXME: i18n this string + }); tdmainicons.appendChild(upbtn); } if(adddown) { - var downbtn = document.createElement('img'); - downbtn.id = 'im_layerControlDown'; - downbtn.className = 'im_layerControl'; - downbtn.setAttribute('src','/intermap/images/im_movedown.gif'); - downbtn.setAttribute('title','Move layer down'); // FIXME: i18n this string - //upbtn.setAttribute('id','showLayerMD_' + id); + var downbtn = Builder.node('img', + { + id: 'im_layerDown_'+id, + className: 'im_layerControl', + src: '/intermap/images/im_movedown.gif', + title: 'Move layer down' // FIXME: i18n this string + }); + tdmainicons.appendChild(downbtn); } - -/* var trtitle = document.createElement('tr'); - table.appendChild(trtitle); -*/ var tdtitle = document.createElement('td'); -/* trtitle.appendChild(tdtitle);*/ + var tdtitle = Builder.node('td'); trmainicons.appendChild(tdtitle); - tdtitle.appendChild(title); - - var trcontrols = document.createElement('tr'); - trcontrols.id = 'layerControl_' + id; + var trcontrols = Builder.node('tr', {id: 'layerControl_' + id}); /* trcontrols.style.display = "none"; */ - trcontrols.hide(); - table.appendChild(trcontrols); + tbody.appendChild(trcontrols); - var tdcontrols = document.createElement('td'); + var tdcontrols = Builder.node('td', { /*colspan:"2" */}); trcontrols.appendChild(tdcontrols); /* tdcontrols.appendChild(toggleLayer);*/ @@ -141,8 +168,12 @@ tdcontrols.appendChild(legend); tdcontrols.appendChild(showLayerMD); tdcontrols.appendChild(trans); + + //ker.wrap(this, function() { + //$(trcontrols).hide(); + //} )(); - +//alert("observers"); // add event observers (mousedown to select layer and dblclick to zoom to layer) Event.observe('layerList_' + id, 'mousedown', function(e){ activateMapLayer(id); }); // Event.observe('layerList_' + id, 'dblclick', function(e){ openInspector(id); }); @@ -152,11 +183,9 @@ Event.observe('deleteLayer_' + id, 'click', function(e){ im_deleteLayer(id); }); Event.observe('im_transp_' + id, 'change', function(e){ im_layerTransparencyChanged(id); }); // TODO Event.observe('showLayerMD_' + id, 'click', function(e){ }); - - createSortable(); + $(trcontrols).hide(); } - // Makes the layer list sortable function createSortable() { @@ -240,11 +269,11 @@ { // transparency slider // var offsetX = Position.cumulativeOffset($('transparencySlider'))[0]; - var transparency = parseFloat(req.responseXML.getElementsByTagName('transparency')[0].firstChild.nodeValue); - $('im_transparencyHandle').style.left = Math.round(transparency / 100 * 95) + 'px'; // handler width is 5px +// var transparency = parseFloat(req.responseXML.getElementsByTagName('transparency')[0].firstChild.nodeValue); +// $('im_transparencyHandle').style.left = Math.round(transparency / 100 * 95) + 'px'; // handler width is 5px // transparency value - $('im_transparencyValue').innerHTML = transparency; +// $('im_transparencyValue').innerHTML = transparency; } function disactivateAllMapLayers() @@ -257,18 +286,16 @@ { mapLayer.className = 'im_inactiveLayer'; - var tr=mapLayer.getElementsByTagName('tr'); - $A(tr).each( + var trList=mapLayer.getElementsByTagName('tr'); + $A(trList).each( function(tr) { if( new String(tr.id).search('layerControl_') != -1) - //tr.style.display="none"; tr.hide(); } ); } - ); - + ); } Modified: trunk/web/intermap/scripts/im_minimap.js =================================================================== --- trunk/web/intermap/scripts/im_minimap.js 2007-07-31 13:51:25 UTC (rev 685) +++ trunk/web/intermap/scripts/im_minimap.js 2007-07-31 21:35:52 UTC (rev 686) @@ -13,18 +13,33 @@ *****************************************************************************/ +// these are the values of standard width and height. +//var im_mm_wsize0 = 200; +//var im_mm_hsize0 = 100; + +var im_mm_width = 200; +var im_mm_height = 100; + + var im_mm_currentTool; var im_mm_north, im_mm_east, im_mm_south, im_mm_west; -var im_mm_width, im_mm_height; var im_mm_ctrl_n,im_mm_ctrl_e, im_mm_ctrl_s, im_mm_ctrl_w; +function trace(fname) +{ + alert("Entering function --> " + fname); +} + // Parse a response and set mm props accordingly function im_mm_set(minimapResponse) { +// trace("im_mm_set"); // Image URL - var mmurl = minimapResponse.getElementsByTagName('imgUrl')[0].textContent; + var mmurl = minimapResponse.getElementsByTagName('imgUrl')[0].firstChild.nodeValue; +//alert("setting src url " + mmurl); $('im_mm_image').src = mmurl; +//alert("src url set"); // BBox var extent=minimapResponse.getElementsByTagName('extent')[0]; @@ -32,10 +47,11 @@ var maxx = extent.getAttribute('maxx'); var miny = extent.getAttribute('miny'); var maxy = extent.getAttribute('maxy'); +//alert("extent set"); // Image size - var w = minimapResponse.getElementsByTagName('width')[0].textContent; - var h = minimapResponse.getElementsByTagName('height')[0].textContent; + var w = minimapResponse.getElementsByTagName('width')[0].firstChild.nodeValue; + var h = minimapResponse.getElementsByTagName('height')[0].firstChild.nodeValue; im_mm_setMapProp(maxy, maxx, miny, minx, w, h); } @@ -43,6 +59,8 @@ // Set width, height and bounding box function im_mm_setMapProp(n, e, s, w, width, height) { +/* trace("im_mm_setMapProp");*/ + im_mm_north=new Number(n); im_mm_east = new Number(e); im_mm_south = new Number(s); @@ -94,10 +112,13 @@ function im_mm_getURLbbox() { - return "bbnorth="+im_mm_north+ - "&bbeast="+im_mm_east+ - "&bbsouth="+im_mm_south+ - "&bbwest="+im_mm_west; + if(im_mm_north) + return "bbnorth="+im_mm_north+ + "&bbeast="+im_mm_east+ + "&bbsouth="+im_mm_south+ + "&bbwest="+im_mm_west; + else + return null; } /* computes bb for mm from bm */ Modified: trunk/web/intermap/scripts/util.js =================================================================== --- trunk/web/intermap/scripts/util.js 2007-07-31 13:51:25 UTC (rev 685) +++ trunk/web/intermap/scripts/util.js 2007-07-31 21:35:52 UTC (rev 686) @@ -53,3 +53,121 @@ return [width, weight]; } + + +function clearNode(node) +{ + var enode = $(node); + while (enode.firstChild) + { + enode.removeChild(enode.firstChild); + } +} + +//======================================== +// Util: Copy a XML tree with HTML format into the current Document +//======================================== + +function copyTree(src, parentDest) +{ + if(src.nodeType==Node.TEXT_NODE) + { + var newNode= document.createTextNode(src.nodeValue); + parentDest.appendChild(newNode); + return; + } + + if(src.nodeType==Node.COMMENT_NODE) + { + var newNode= document.createElement("COMMENT"); + newNode.style.display = "none"; + newNode.textContent= src.nodeValue; + parentDest.appendChild(newNode); + return; + } + +// var li = document.createElement("li"); // DEBUG!!! +// li.textContent= src.tagName+ " ID:" +src.getAttribute('id'); +// $('ETJ_DEBUG').appendChild(li); + + var newNode= document.createElement(src.tagName); +// if(src.className) +// newNode.className = src.className; +// newNode.nodeValue = src.nodeValue; + + //a("R!!!!!"); + var tattr = " "; + //if (src.hasAttributes()) // this line won't work in IE + if (src.attributes) + { + var attrs = src.attributes; + for(var i=attrs.length-1; i>=0; i--) + { + newNode.setAttribute(attrs[i].name, attrs[i].value); + tattr += (attrs[i].name+'="'+attrs[i].value+'"'); + } + }; + + //a("ADDING <" + src.tagName + tattr +'>'); + //a("Adding to " + parentDest); + //a("Adding to " + $(parentDest)); + $(parentDest).appendChild(newNode); + //a("ADDED"); + var child = src.firstChild; + while(child) + { + copyTree(child, newNode); + child = child.nextSibling; + } +} + +//======================================== +// Util: Transform a XML tree into its related text form +//======================================== + +function xml2text(src) +{ + if(src.nodeType==Node.TEXT_NODE) + { + return src.nodeValue; + } + + if(src.nodeType==Node.COMMENT_NODE) + { + return "<!-- "+ src.nodeValue +" -->"; + } + +// a("R!!!!!"); + var tattr = ""; + //if (src.hasAttributes()) // this line won't work in IE + if (src.attributes) + { + var attrs = src.attributes; + for(var i=attrs.length-1; i>=0; i--) + { + tattr += (attrs[i].name+'="'+attrs[i].value+'" '); + } + } + + var text = "<" + src.tagName + " " + tattr +'>\n'; + + var wrapstart = ""; + + if(src.tagName == "table") + { + text+= "<tbody>"; + wrapend= "</tbody>"; + } + +// a(text); + var child = src.firstChild; + while(child) + { + text += xml2text(child) + "\n"; + child = child.nextSibling; + } + + text += wrapend + "</"+ src.tagName+ ">"; + + return text; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |