changeset 2566:033454f36982

Remove some useless obsolete compat code.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 27 Jan 2024 05:35:04 +0200
parents d55944cb90a4
children f0c682a75e27
files src/util.js
diffstat 1 files changed, 9 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/src/util.js	Sat Jan 27 05:29:44 2024 +0200
+++ b/src/util.js	Sat Jan 27 05:35:04 2024 +0200
@@ -14,27 +14,9 @@
 var mapScrollIndex = 0.0, mapScrollSteps = 50;
 
 
-function mapAddEventOb(obname, evobj, evtype, evcallback)
+function mapAddEventListener(obname, evtype, evcallback)
 {
-  if (evobj == null || typeof(evobj) == 'undefined')
-  {
-    console.log("Event object '"+ obname +"' == null.");
-    return;
-  }
-
-  if (evobj.addEventListener)
-    evobj.addEventListener(evtype, evcallback, false);
-  else
-  if (evobj.attachEvent)
-    evobj.attachEvent("on"+evtype, evcallback);
-  else
-    evobj["on"+evtype] = evcallback;
-}
-
-
-function mapAddEvent(obname, evtype, evcallback)
-{
-  mapAddEventOb(obname, document.getElementById(obname), evtype, evcallback);
+  document.getElementById(obname).addEventListener(evtype, evcallback, false);
 }
 
 
@@ -319,15 +301,13 @@
     }
   }
 
-  mapAddEvent("slabels", "change", mapUpdateLabelVisibility);
-  mapUpdateLabelVisibility();
-
-  mapAddEvent("slocation", "change", mapGotoLocation);
+  mapAddEventListener("slabels", "change", mapUpdateLabelVisibility);
+  mapAddEventListener("slocation", "change", mapGotoLocation);
+  mapAddEventListener("spanning", "change", mapUpdateDragPan);
+  mapAddEventListener("smap", "mousedown", mapStartDragPan);
+  document.addEventListener("mousemove", mapDragMoveHandler);
+  document.addEventListener("mouseup", mapDragUpHandler);
 
-  mapAddEvent("spanning", "change", mapUpdateDragPan);
-  mapAddEvent("smap", "mousedown", mapStartDragPan);
-  mapAddEventOb("document", document, "mousemove", mapDragMoveHandler);
-  mapAddEventOb("document", document, "mouseup", mapDragUpHandler);
-
+  mapUpdateLabelVisibility();
   mapUpdateDragPan();
 }