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;
}
+
//-->
</script>
EOF
sub format (@) { #{{{
my %params=@_;
- if ($params{content}=~s!(<div class="toggleable(?:-open)?" id="[^"]+">)</div>!$1!g) {
+ if ($params{content}=~s!(<div class="toggleable(?:-open)?" id="[^"]+">\s*)</div>!$1!g) {
$params{content}=~s/<div class="toggleableend">//g;
- if (! ($params{content}=~s!^<\/body>!$javascript</body>!m)) {
+ if (! ($params{content}=~s!^<body>!<body>$javascript!m)) {
# no </body> tag, probably in preview mode
- $params{content}.=$javascript;
+ $params{content}=$javascript.$params{content};
}
}
return $params{content};