From acb9f950df0b8bfa54552de7c46d8f3b887fff39 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Tue, 29 May 2012 21:47:22 +0200 Subject: [PATCH] Use document.getElementById in examples. Previously examples would either use the now deprecated `window.$` or the non-API-method `OpenLayers.Util.getElement`. This was well caught by @probins and @elemoine. --- examples/editing-methods.js | 14 ++++++-------- examples/game-accel-ball.html | 3 +-- examples/geolocation.js | 9 ++++----- examples/getfeatureinfo-control.html | 3 +-- examples/select-feature.html | 6 ++---- examples/snap-split.html | 23 ++++++++++------------- examples/snapping.html | 10 ++++------ examples/strategy-cluster-extended.js | 6 ++---- examples/strategy-cluster-threshold.html | 14 ++++++-------- examples/strategy-cluster.html | 17 ++++++++--------- examples/using-proj4js.js | 15 +++++++-------- 11 files changed, 51 insertions(+), 69 deletions(-) diff --git a/examples/editing-methods.js b/examples/editing-methods.js index 1c227c4b11..03d5e82311 100644 --- a/examples/editing-methods.js +++ b/examples/editing-methods.js @@ -19,10 +19,8 @@ var draw = new OpenLayers.Control.DrawFeature( map.addControl(draw); draw.activate(); -var $ = OpenLayers.Util.getElement; - // handle clicks on method links -$("insertXY").onclick = function() { +document.getElementById("insertXY").onclick = function() { var values = parseInput( window.prompt( "Enter map coordinates for new point (e.g. '-111, 46')", "x, y" @@ -32,7 +30,7 @@ $("insertXY").onclick = function() { draw.insertXY(values[0], values[1]); } }; -$("insertDeltaXY").onclick = function() { +document.getElementById("insertDeltaXY").onclick = function() { var values = parseInput( window.prompt( "Enter offset values for new point (e.g. '15, -10')", "dx, dy" @@ -42,7 +40,7 @@ $("insertDeltaXY").onclick = function() { draw.insertDeltaXY(values[0], values[1]); } }; -$("insertDirectionLength").onclick = function() { +document.getElementById("insertDirectionLength").onclick = function() { var values = parseInput( window.prompt( "Enter direction and length offset values for new point (e.g. '-45, 10')", "direction, length" @@ -52,7 +50,7 @@ $("insertDirectionLength").onclick = function() { draw.insertDirectionLength(values[0], values[1]); } }; -$("insertDeflectionLength").onclick = function() { +document.getElementById("insertDeflectionLength").onclick = function() { var values = parseInput( window.prompt( "Enter deflection and length offset values for new point (e.g. '15, 20')", "deflection, length" @@ -62,10 +60,10 @@ $("insertDeflectionLength").onclick = function() { draw.insertDeflectionLength(values[0], values[1]); } }; -$("cancel").onclick = function() { +document.getElementById("cancel").onclick = function() { draw.cancel(); }; -$("finishSketch").onclick = function() { +document.getElementById("finishSketch").onclick = function() { draw.finishSketch(); }; diff --git a/examples/game-accel-ball.html b/examples/game-accel-ball.html index a622768bd2..c832e86721 100644 --- a/examples/game-accel-ball.html +++ b/examples/game-accel-ball.html @@ -33,10 +33,9 @@ vlayer.drawFeature(feature); } function init() { - var $ = OpenLayers.Util.getElement; map = new OpenLayers.Map( 'map', { - 'maxExtent': new OpenLayers.Bounds(0, 0, $("map").clientWidth, $("map").clientHeight), + 'maxExtent': new OpenLayers.Bounds(0, 0, document.getElementById("map").clientWidth, document.getElementById("map").clientHeight), controls: [], maxResolution: 'auto'} ); diff --git a/examples/geolocation.js b/examples/geolocation.js index acde5faae5..3d8d6f4b55 100644 --- a/examples/geolocation.js +++ b/examples/geolocation.js @@ -92,16 +92,15 @@ geolocate.events.register("locationupdated",geolocate,function(e) { geolocate.events.register("locationfailed",this,function() { OpenLayers.Console.log('Location detection failed'); }); -var $ = OpenLayers.Util.getElement; -$('locate').onclick = function() { +document.getElementById('locate').onclick = function() { vector.removeAllFeatures(); geolocate.deactivate(); - $('track').checked = false; + document.getElementById('track').checked = false; geolocate.watch = false; firstGeolocation = true; geolocate.activate(); }; -$('track').onclick = function() { +document.getElementById('track').onclick = function() { vector.removeAllFeatures(); geolocate.deactivate(); if (this.checked) { @@ -110,4 +109,4 @@ $('track').onclick = function() { geolocate.activate(); } }; -$('track').checked = false; +document.getElementById('track').checked = false; diff --git a/examples/getfeatureinfo-control.html b/examples/getfeatureinfo-control.html index 2dcdf3c58d..baecd420fb 100644 --- a/examples/getfeatureinfo-control.html +++ b/examples/getfeatureinfo-control.html @@ -48,7 +48,6 @@