Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Perlmonks Navigator

by tilly (Archbishop)
on Mar 18, 2001 at 05:46 UTC ( #65224=sourcecode: print w/replies, xml ) Need Help??
Category: Related Scripts
Author/Contact Info
Description: First, while this is useful and Perlmonks related, it isn't Perl. It is JavaScript.

d/l the code, and save the two pieces marked with ##filename=foo.html## as what the name is supposed to be. Be sure cookies and JavaScript are on. Then point your browser at perlmonks.html, and try it out.

With this, this morning I was able to walk through every post for several days worth of PerlMonks in just a few hours. Most of that time was spent writing up responses. With this I can follow the whole site with less energy than it would take to hit a reasonable portion of it through using Newest Nodes.

Clearly my cookie handling in JavaScript sucks. Oh well, I don't like either cookies or JavaScript, so I guess that was my internal bias showing. :-) Now fixed.

    <title>Perlmonks Navigator</title>
  <frameset cols='10%,90%'>
    <frame name='control' src='nav.html' scrolling='yes'>
    <frame name='perlmonks'
      src='' scrolling=

  <title>Perlmonks Navigation Sidebar</title>

   <form name="nav_control">
     <input type="button" value="prev"  onClick="move(-1)"><br>
     <input type="button" value="next" onClick="move(1)"><p>
     <input type="text" size="8" name="article_no"><br>
     <input type="button" value="jump" onClick="move_to(document.nav_c
     <input type="button" value="cookie" onClick="alert(document.cooki

     var cookie_index = "pm_index";

     function get_next_year () {
       var year = new Date();
       year.setFullYear(year.getFullYear() + 1);
       return year;

     // Takes the encoded name of the attrib, returns the decoded valu
     function get_cookie_attrib (name) {
       var stored_as = unescape(name) + "=";
       var pieces = document.cookie.split(/; /);
         for (my_index in document.cookie.split("")) {
           var piece = pieces[my_index];
           if (null == piece)
           if (0 == piece.indexOf(stored_as)) {
             var escaped_val = piece.substr(stored_as.length);
             return unescape(escaped_val);
       return null;

     // Gets the current pos or "tilly"'s home node
     function get_cur_pos () {
       // Don't forget that this should be a number.
       var cur_pos = get_cookie_attrib(cookie_index) - 0;
       return (0 == cur_pos ? 26179 : cur_pos);

     // Move forward or back
     function move (count) {
       move_to(get_cur_pos() + count);

     // Takes an index, moves there.
     function move_to (pos) {
       set_cookie_attrib(cookie_index, pos);
       document.nav_control.article_no.value = pos;
       parent.perlmonks.location.href =
         "" + pos;

     // Takes a name/value, encodes and stores them in the cookie
     function set_cookie_attrib (name, value) {
       // This does not disturb other attributes.  Why?
       // Just another stupid JavaScript interface decision. :-(
       var cookie_str = escape(name) + "=" + escape(value);
       cookie_str += ";expires= " + get_next_year().toGMTString();
       document.cookie = cookie_str;

     // Default location

Replies are listed 'Best First'.
Re: Perlmonks Navigator
by busunsl (Vicar) on Mar 19, 2001 at 13:26 UTC
    Nice work !

    It's working fine with Netscape 4.7x, but it doesn't work with Mozilla 0.8.
    But I think that's a bug in Mozilla :-(

      It's working fine under Mozilla 0.9.3 on my RedHat 6.2 box

      Good Stuff!

Re: Perlmonks Navigator
by poqui (Deacon) on Aug 16, 2001 at 18:52 UTC
    Its working fine in MS IE 5.5 too. Thanks for the tool!
Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://65224]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2017-02-27 02:53 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (376 votes). Check out past polls.