Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

This hack will update the timestamp for Newest Nodes with the node creation time of the node from where it was submitted, leaving you with a node list presentation since the updated timestamp.

The Motivation

Although I am an everyday visitor, I cannot manage to keep up with the newest nodes during the week, because my job keeps me rather busy more often than not and so I have to catch up on evenings and on weekends until I can click on 'I've checked all of these' on Newest Nodes. Switching between my nodes list at work and the list at home without 'checking all of these' doesn't present me a clear overview of what I've already read.

The Hack

This is a two step process.

Step 1:
By clicking the button 'Get node creation time', the node creation (local)time (based on your settings in Timezone Settings) will be converted to unix time - in full minutes only, since there is no more information in the node itself. This button will disappear, the node creation time and a textbox with the converted unix time in it will be presented and below that a submit button.

Step 2:
By clicking the button 'Set Timestamp' then, the database entry for 'viewedNewNodes' on PM will be updated with the value which was in the textbox above, and you will be redirected to the updated Newest Nodes.

Without changing the unix time, the node where the submit action took place, will then be one of the oldest node id's to be displayed in Newest Nodes, depending on the node id, when there are more than one nodes from the same minute.

However, if you're applying this on a node where there is no such table with the id "titlebar-bottom" (i.e. Newest Nodes), or when the calculated unix time is not exactly 10 digits, the button 'Get node creation time' will (safely) not do anything. Bear in mind, that you are responsible which value you will submit if you are changing the textbox entry or if you are submitting the form on a really old node. Also watch out for nodes from other PM sections with lower node id's before updating, so that you will not miss these.

The Code

Add the javascript and the HTML part to your Free Nodelet Settings.
Insert the javascript without script tags in the javascript section if you already have such a section in your Free Nodelet!

The javascript part:
<script language="javascript"><!-- // Get Unix Time from node creation time and prepare form // to set last to display node time for 'Newest Nodes' function fn_getunixtime() { var table = document.getElementById("titlebar-bottom"); var span = table.getElementsByTagName("span"); var ctime = span[0]; var re = /^on\s+(\w+\s+\d{1,2},\s*\d{4}\s+)at\s+([\d:]+)/; re.exec(ctime); var timestr = RegExp.$1 + RegExp.$2; var unixtime = new Date(timestr) / 1000; var chkfmt = /^\d{10}$/; var ok = chkfmt.test(unixtime); if (ok == false) return false; var TStext = document.getElementById("fn_SetTimeText"); var TSform = document.all.fn_ViewedNodesTime; TStext.firstChild.nodeValue = timestr; TSform.pageloadtime.value = unixtime; TSform.viewedNewNodes.value = "Set Timestamp"; = "none"; = ""; } //--></script>

The HTML part:
<hr> <center> <div id="fn_SetTimeText"> Set Timestamp for 'Newest Nodes' </div> <form name="fn_PrepareUnixTime"> <div id="fn_dsp_put"> <input type="button" name="prepare" value="Get node creation time" onClick=fn_getunixtime()> </div> </form> <form name="fn_ViewedNodesTime" method="post" action="?" enctype="application/x-www-form-urlencoded"> <input name="node_id" value="3628" type="hidden"> <div id="fn_dsp_vnt" style="display:none"> <input name="pageloadtime" size="12" maxlength="10" type="text"><br> <input name="viewedNewNodes" type="submit"> </div> </form> </center> <hr>

For general information about the Free Nodelet you should read Free Nodelet freed.

Successfully tested on:
WindowsXP: Firefox 1.07, Opera 8.01, IE 6.0
Linux (FC4): Firefox 1.06, Mozilla 1.7.8, Epiphany 1.6.1

Didn't get it to work with Konqueror 3.4.

In reply to Free Nodelet Hack: Set Timestamp for Newest Nodes by Dietz

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-05-28 00:44 GMT
Find Nodes?
    Voting Booth?

    No recent polls found