Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
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].

Replies are listed 'Best First'.
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?
[LanX]: you can manipulate a html tree by addressing and replacing so called document objects (DOM) and from my experience the same methods can be used with any XML, though I didn't test all browsers yet
LanX just joking, playing "ego judo"
[marto]: good morning all
[Corion]: Hi marto!
[marto]: the race to the bottom continues, many people lost their job yesterday as a client moves to another outsourcer
[LanX]: brexit or perlxit ?
[Corion]: Ow, marto :-/ I hope you aren't affected (except for the looming dread of more work for the same pay)
[marto]: unrelated
[marto]: Corion, no we're already being g tupe transferred to another employer. This was a banking sector client. They provided a reporting platform using ancient tech

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (14)
As of 2017-03-23 09:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (285 votes). Check out past polls.