Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Node ids by node titles

by bmann (Priest)
on Nov 01, 2006 at 21:15 UTC ( #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].


Comment on Re: Node ids by node titles
Select or Download Code
Free Nodelet Hack: Node IDs by node titles
by jdporter (Canon) 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
Node Status?
node history
Node Type: note [id://581764]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (13)
As of 2014-07-23 19:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (152 votes), past polls