X-Git-Url: https://scripts.mit.edu/gitweb/www/ikiwiki.git/blobdiff_plain/895faed6428f3523871d29ed82b0ab3326453b75..14cd75746a2c73b50548b6fdb3583d536b6ef9bd:/IkiWiki/Plugin/toggle.pm diff --git a/IkiWiki/Plugin/toggle.pm b/IkiWiki/Plugin/toggle.pm index f969d7686..cd9617e25 100644 --- a/IkiWiki/Plugin/toggle.pm +++ b/IkiWiki/Plugin/toggle.pm @@ -39,18 +39,22 @@ function toggle(s) { style.display = "none"; } -function getElementsByClass(class) { +function getElementsByClass(cls, node, tag) { + if (document.getElementsByClass) + return document.getElementsByClass(cls, node, tag); + if (! node) node = document; + if (! tag) tag = '*'; var ret = new Array(); - var pattern = new RegExp("(^|\\s)"+class+"(\\s|$)"); - var els = document.getElementsByTagName('*'); - for (i = 0, j = 0; i < els.length; i++) { + var pattern = new RegExp("(^|\\s)"+cls+"(\\s|$)"); + var els = node.getElementsByTagName(tag); + for (i = 0; i < els.length; i++) { if ( pattern.test(els[i].className) ) { - ret[j] = els[i]; - j++; + ret.push(els[i]); } } return ret; } + //--> EOF @@ -108,9 +112,9 @@ sub format (@) { #{{{ if ($params{content}=~s!(