Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Node ids by node titles

by bmann (Priest)
on Nov 01, 2006 at 21:15 UTC ( [id://581764]=note: print w/replies, xml ) Need Help??


in reply to Node ids by node titles

Good idea, it'd be nice to have the node id easily accessible for each reply.

Put this snippet in your free nodelet - it'll add "#node_id" after the reply title (ie #581764 for this node).

<script language="javascript"><!-- function add_node_ids() { var trs = document.getElementsByTagName('tr'); var i; for ( i = 0; i < trs.length; i++ ) { if ( trs[i].className == 'reply' ){ var anch = trs[i].getElementsByTagName( 'a' ); var id = anch[0].href.match( /\d+$/ ); var txt = document.createTextNode( " #" + id ); //or for [id://nnnnnn] style, //var txt = document.createTextNode( " [id://" + id + "]" ); anch[0].parentNode.insertBefore( txt, anch[0].nextSibling +); } } } add_node_ids(); </script><!-- end add_node_ids -->

Update: Tested on Firefox 1.507 & IE 6
Update 2: Only showed ids for new replies. Fixed to show id's for all replies. Added [id://nnnnnn].

Replies are listed 'Best First'.
Free Nodelet Hack: Node IDs by node titles
by jdporter (Paladin) on May 01, 2007 at 16:25 UTC

    Due to a recent patch, the above code no longer works.
    The following illustrates the necessary fix, which I've flagged with XXX:

    function add_node_ids() { var trs = document.getElementsByTagName('tr'); var i; for ( i = 0; i < trs.length; i++ ) { if ( trs[i].className == 'reply' ){ var anch = trs[i].getElementsByTagName( 'a' ); var id = anch[0].name; // XXX var ntre = document.createElement('input'); ntre.type = 'text'; ntre.name = 'see_Free_Nodelet_Settings'; ntre.value = "[id://" + id + "]"; anch[0].parentNode.insertBefore( ntre, anch[0].nextSibling.nextS +ibling ); } } }
    A word spoken in Mind will reach its own level, in the objective world, by its own weight

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://581764]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-03-28 13:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found