diff options
author | Joey Hess <joey@kodama.kitenet.net> | 2008-07-25 01:43:37 -0400 |
---|---|---|
committer | Joey Hess <joey@kodama.kitenet.net> | 2008-07-25 01:43:37 -0400 |
commit | 89e0de5bc46f87231a3447acb8609641cc9162aa (patch) | |
tree | 957d51322f3d81189fe43fd5b91b8ab812adaa95 | |
parent | 3640b88f9575882373eac93a47815d870e54d366 (diff) | |
download | ikiwiki-89e0de5bc46f87231a3447acb8609641cc9162aa.tar ikiwiki-89e0de5bc46f87231a3447acb8609641cc9162aa.tar.gz |
improved, possibly faster getelementsbyclass by willu
-rw-r--r-- | IkiWiki/Plugin/toggle.pm | 16 | ||||
-rw-r--r-- | doc/bugs/toggle_fails_on_Safari.mdwn | 3 |
2 files changed, 13 insertions, 6 deletions
diff --git a/IkiWiki/Plugin/toggle.pm b/IkiWiki/Plugin/toggle.pm index ef30fe6b6..cd9617e25 100644 --- a/IkiWiki/Plugin/toggle.pm +++ b/IkiWiki/Plugin/toggle.pm @@ -39,18 +39,22 @@ function toggle(s) { style.display = "none"; } -function getElementsByClass(c) { +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)"+c+"(\\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; } + //--> </script> EOF diff --git a/doc/bugs/toggle_fails_on_Safari.mdwn b/doc/bugs/toggle_fails_on_Safari.mdwn index 5ba14d257..25f62e088 100644 --- a/doc/bugs/toggle_fails_on_Safari.mdwn +++ b/doc/bugs/toggle_fails_on_Safari.mdwn @@ -53,3 +53,6 @@ Looking at the Safari Web Inspector, it believes there is a parse error on line >> they're filled in with useful defaults. >> I don't know if it is worth making this change, but it is there if you want it. + +>>> Well, it seems to work. Although god only knows about IE. Suppose I +>>> might as well.. --[[Joey]] |