http://qs1969.pair.com?node_id=507486

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.

Result:
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].firstChild.data; 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"; document.all.fn_dsp_put.style.display = "none"; document.all.fn_dsp_vnt.style.display = ""; } //--></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.

Replies are listed 'Best First'.
Re: Free Nodelet Hack: Set Timestamp for Newest Nodes
by Dietz (Curate) on Nov 13, 2005 at 11:24 UTC

    I just noticed one can set his own Format for date-times in User Settings which could cause the regex to fail because the setting also has an effect on the displayed node creation time.

    When not set, the default setting for the date format on PM currently is "%b %d, %Y at %H:%M %Z" (i.e. 'Nov 13, 2005 at 01:23 CET').
    Using "%b %d, %Y at %H:%M:%S %Z" to also show the seconds would still work.

    The javascript expects the variable 'timestr' to be in the format of "%b %d, %Y %H:%M:%S" or "%b %d, %Y %H:%M" (i.e. 'Nov 13, 2005 01:23') to convert the time string into unix time (aka epoch seconds).