An example of a callback script that runs when a new item is added to the river. (original) (raw)

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

var now = new Date ();
if (localStorage.feeds === undefined) {
localStorage.feeds = new Object ();
}
if (localStorage.feeds [urlfeed] === undefined) {
localStorage.feeds [urlfeed] = {
ctAdds: 0,
whenFirstAdd: now
};
}
var thisFeed = localStorage.feeds [urlfeed];
thisFeed.ctAdds++;
thisFeed.whenLastAdd = now;
if (thisFeed.stories === undefined) {
thisFeed.stories = new Array ();
}
thisFeed.stories [thisFeed.stories.length] = itemFromRiver.title;
itemFromRiver.whenLastSayHello = now;
if (itemFromRiver.ctHellos === undefined) {
itemFromRiver.ctHellos = 0;
}
itemFromRiver.ctHellos++;
todaysRiverChanged (); //tell River4 to save it