diff options
author | louise <louise> | 2009-09-23 09:27:51 +0000 |
---|---|---|
committer | louise <louise> | 2009-09-23 09:27:51 +0000 |
commit | 81b01d79ed8303af1f1119e8ddac01e4d970b40d (patch) | |
tree | 3e2be3df2f0cc5129cd678556019e783e57062fc /web/js.js | |
parent | 9f149d2fb00ab93eae46188e25445a533fa0a1d1 (diff) |
Adding host to the params available in header templates, renaming global vars x and y to fms_x and fms_y to reduce conflict when used in context with other js
Diffstat (limited to 'web/js.js')
-rw-r--r-- | web/js.js | 39 |
1 files changed, 20 insertions, 19 deletions
@@ -9,6 +9,7 @@ * */ + YAHOO.util.Event.onContentReady('pc', function() { if (this.id && this.value == this.defaultValue) { this.focus(); @@ -41,23 +42,25 @@ YAHOO.util.Event.onContentReady('compass', function() { YAHOO.util.Event.addListener(points[4], 'click', compass_pan, { home:1, orig_x:drag_x, orig_y:drag_y }); }); + YAHOO.util.Event.onContentReady('map', function() { var ua=navigator.userAgent.toLowerCase(); // if (document.getElementById('mapForm') && (/safari/.test(ua) || /Konqueror/.test(ua))) return; if (document.getElementById('map').offsetWidth > 510) return; - new YAHOO.util.DDMap('map'); update_tiles(start_x, start_y, true); }); + YAHOO.util.Event.onContentReady('mapForm', function() { this.onsubmit = function() { - if (this.submit_problem) { + if (this.submit_problem) { this.submit_problem.disabled = true; this.submit_map.value = 2; } - this.x.value = x + 2; - this.y.value = y + 2; + + this.x.value = fms_x + 2; + this.y.value = fms_y + 2; /* if (swfu && swfu.getStats().files_queued > 0) { swfu.startUpload(); @@ -141,21 +144,21 @@ YAHOO.util.Event.addListener('all_pins_link', 'click', function(e) { if (this.innerHTML == 'Include stale reports') { this.innerHTML = 'Hide stale reports'; document.getElementById('all_pins').value = '1'; - load_pins(x, y); + load_pins(fms_x, fms_y); } else if (this.innerHTML == 'Cynnwys hen adroddiadau') { this.innerHTML = 'Cuddio hen adroddiadau'; document.getElementById('all_pins').value = '1'; welsh = 1; - load_pins(x, y); + load_pins(fms_x, fms_y); } else if (this.innerHTML == 'Cuddio hen adroddiadau') { this.innerHTML = 'Cynnwys hen adroddiadau'; welsh = 1; document.getElementById('all_pins').value = ''; - load_pins(x, y); + load_pins(fms_x, fms_y); } else if (this.innerHTML == 'Hide stale reports') { this.innerHTML = 'Include stale reports'; document.getElementById('all_pins').value = ''; - load_pins(x, y); + load_pins(fms_x, fms_y); } if (welsh) { document.getElementById('hide_pins_link').innerHTML = 'Cuddio pinnau'; @@ -275,7 +278,6 @@ var drag_y = 0; function update_tiles(dx, dy, force) { dx = getInt(dx); dy = getInt(dy); if (!dx && !dy && !force) return; - var old_drag_x = drag_x; var old_drag_y = drag_y; drag_x += dx; @@ -288,21 +290,20 @@ function update_tiles(dx, dy, force) { var horizontal = Math.floor(old_drag_x/tilewidth) - Math.floor(drag_x/tilewidth); var vertical = Math.floor(old_drag_y/tileheight) - Math.floor(drag_y/tileheight); if (!horizontal && !vertical && !force) return; - - x += horizontal; + fms_x += horizontal; + tile_x += horizontal; - y -= vertical; + fms_y -= vertical; tile_y += vertical; - var url = [ '/tilma/tileserver/10k-full/', x, '-', (x+5), ',', y, '-', (y+5), '/JSON' ].join(''); + var url = [ '/tilma/tileserver/10k-full/', fms_x, '-', (fms_x+5), ',', fms_y, '-', (fms_y+5), '/JSON' ].join(''); YAHOO.util.Connect.asyncRequest('GET', url, { success: urls_loaded, failure: urls_not_loaded, argument: [tile_x, tile_y] }); if (force) return; - - load_pins(x, y); + load_pins(fms_x, fms_y); } function load_pins(x, y) { @@ -312,7 +313,7 @@ function load_pins(x, y) { ';all_pins=', document.getElementById('all_pins').value ].join(''); YAHOO.util.Connect.asyncRequest('GET', url, { - success: pins_loaded + success: pins_loaded }); } } @@ -340,8 +341,8 @@ function urls_loaded(o) { if (tiles[i][j] == null) continue; var jj = (j + o.argument[0]); var id = [ 't', ii, '.', jj ].join(''); - var xx = x+j; - var yy = y+5-i; + var xx = fms_x+j; + var yy = fms_y+5-i; var img = document.getElementById(id); if (img) { if (!img.galleryimg) { img.galleryimg = false; } @@ -391,7 +392,7 @@ function cloneNode() { var tileCache=[]; function cleanCache() { for (var i in tileCache) { - if (tileCache[i].x < x || tileCache[i].x > x+5 || tileCache[i].y < y || tileCache[i].y > y+5) { + if (tileCache[i].x < fms_x || tileCache[i].x > fms_x+5 || tileCache[i].y < fms_y || tileCache[i].y > fms_y+5) { var t = tileCache[i].t; t.parentNode.removeChild(t); // de-leak? delete tileCache[i]; |