Mercurial > hg > mgallery
comparison mgallery.js @ 154:0b87e7c1675c
Improve the JavaScript event hook functions.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 07 Nov 2017 14:40:14 +0200 |
parents | 606b05c31d5e |
children | ba02d12cb4be |
comparison
equal
deleted
inserted
replaced
153:fd84c6a8c4c9 | 154:0b87e7c1675c |
---|---|
4 // Programmed and designed by Matti 'ccr' Hamalainen <ccr@tnsp.org> | 4 // Programmed and designed by Matti 'ccr' Hamalainen <ccr@tnsp.org> |
5 // (C) Copyright 2015-2017 Tecnic Software productions (TNSP) | 5 // (C) Copyright 2015-2017 Tecnic Software productions (TNSP) |
6 // | 6 // |
7 | 7 |
8 | 8 |
9 function mgalAddEvent(evobj, evtype, evcallback) | 9 function mgalAddEventOb(obname, evobj, evtype, evcallback) |
10 { | 10 { |
11 if (evobj == null || typeof(evobj) == 'undefined') | 11 if (evobj == null || typeof(evobj) == 'undefined') |
12 { | |
13 console.log("Event object '"+ obname +"' == null."); | |
12 return; | 14 return; |
15 } | |
13 | 16 |
14 if (evobj.addEventListener) | 17 if (evobj.addEventListener) |
15 evobj.addEventListener(evtype, evcallback, false); | 18 evobj.addEventListener(evtype, evcallback, false); |
16 else | 19 else |
17 if (evobj.attachEvent) | 20 if (evobj.attachEvent) |
18 evobj.attachEvent("on" + evtype, evcallback); | 21 evobj.attachEvent("on"+evtype, evcallback); |
19 else | 22 else |
20 evobj["on"+evtype] = evcallback; | 23 evobj["on"+evtype] = evcallback; |
21 }; | 24 } |
25 | |
26 | |
27 function mgalAddEvent(obname, evtype, evcallback) | |
28 { | |
29 mgalAddEventOb(obname, document.getElementById(obname), evtype, evcallback); | |
30 } | |
22 | 31 |
23 | 32 |
24 function mgalNavigateTo(url) | 33 function mgalNavigateTo(url) |
25 { | 34 { |
26 if (url != "") | 35 if (url != "") |