Last change
on this file since 1 was
1,
checked in by myroslav, 18 years ago
|
Building directory structure
|
File size:
1.4 KB
|
Rev | Line | |
---|
[1] | 1 | // tiles.js |
---|
| 2 | |
---|
| 3 | var DEBUG = false, message = ""; |
---|
| 4 | |
---|
| 5 | function getElementsByClassName(className, parentElement) { |
---|
| 6 | var result = new Array(), |
---|
| 7 | list = (parentElement || window.document.body).getElementsByTagName('*'); |
---|
| 8 | if(list.length == 0) list = (parentElement || window.document.body).all; |
---|
| 9 | for(var i = 0; i < list.length; i++) { |
---|
| 10 | // if(DEBUG) message += '\n' + list[i].className; |
---|
| 11 | if(list[i].className.match(new RegExp('(^|\\s)' + className + '(\\s|$)'))) result[result.length] = list[i]; |
---|
| 12 | } |
---|
| 13 | return result |
---|
| 14 | }; |
---|
| 15 | |
---|
| 16 | function getNeededHref(a_list) { |
---|
| 17 | var result, classname_re = new RegExp('(^|\\s)' + 'primary' + '(\\s|$)'); |
---|
| 18 | if(a_list.length == 0) return false; |
---|
| 19 | for(var i = 0; i < a_list.length; i++) { |
---|
| 20 | if(classname_re.exec(a_list[i].className)) return a_list[i].href; |
---|
| 21 | } |
---|
| 22 | return a_list[0].href |
---|
| 23 | } |
---|
| 24 | |
---|
| 25 | function setTiles(){ |
---|
| 26 | var tiles_elms = getElementsByClassName("tile", window.document) |
---|
| 27 | for(var i = 0; i < tiles_elms.length; i++) { |
---|
| 28 | var tiles_a = tiles_elms[i].getElementsByTagName('A'); |
---|
| 29 | if(tiles_a.length > 0) { |
---|
| 30 | var Href = getNeededHref(tiles_a); |
---|
| 31 | if(Href != false) tiles_elms[i].onclick = new Function("window.location = '"+Href+"'; return false;") |
---|
| 32 | } |
---|
| 33 | if(DEBUG) message += '\n' + tiles_elms[i].onclick + ' - ' + Href; |
---|
| 34 | } |
---|
| 35 | if(DEBUG) window.alert(message); |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | registerPloneFunction(setTiles); |
---|
Note: See
TracBrowser
for help on using the repository browser.