Changing commented out values via javascript

M

Mike Gifford

A year or so ago you I got some help generating the javascript I've
included at the bottom of this page to convert:
<!-- Start index3col.tpl -->

to:
<a
href="/admin/BE_editTemplateAdmin.php?submit=edit&file=index3col.tpl"><img
src="/BE/buttons/templateView.gif"></a>

So that I can more easily identify the templates which are used in our
GPL CMS.

Unfortunately we've changed our comments structure for identifying our
templates site to use:
<!-- END FILE index3col.tpl -->

Unfortunately I keep getting this as a result:
<a
href="/admin/BE_editTemplateAdmin.php?submit=edit&file=FILE%20index3col.tpl%20"><img
src="/BE/buttons/templateView.gif"></a>

Any suggestions you might have to modify this would be appreciated..
I've tried changing:
if (text.substr(0,7)==" START ") {
to:
if (text.substr(0,10)==" END FILE ") {

and:
var newNode = createNewNode(text.substr(7));
to:
var newNode = createNewNode(text.substr(10));

But this doesn't seem to be having any impact. I'm browsing this with
firefox.

Mike

<script type="text/javascript">
<!--
// Code Contributed by Lasse Nielsen - http://www.infimum.dk
function convert(node) {
if (!node) {node = document.body;}

switch (node.nodeType) {
case Node.COMMENT_NODE:
var text = node.nodeValue;
if (text.substr(0,7)==" START ") {
var newNode = createNewNode(text.substr(7));
node.parentNode.replaceChild(newNode,node);
}
break
case Node.ELEMENT_NODE:
for (var i=0;i<node.childNodes.length;i++) {
convert(node.childNodes);
}
break;
default:
break;
}
}

function createNewNode(text) {
var a = document.createElement("a");
a.href =
"{ROOTURL}/admin/BE_editTemplateAdmin.php?submit=edit&file="+escape(text);
var img = document.createElement("img");
img.src = "{IMAGEURL}/BE/buttons/templateView.gif";
a.appendChild(img);
return a;
}
-->
</script>

<input type="button" value="Convert!" onclick="convert()" />
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top