76
76
var img = document.createElement("img");
77
77
img.src = twidenash.items[i].img;
79
var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
80
var delta = parseInt((relative_to.getTime() - twidenash.items[i].dt) / 1000);
81
var pluralize = function (singular, n) {
82
return '' + n + ' ' + singular + (n == 1 ? '' : 's');
85
date_msg = 'less than a minute ago ';
86
} else if(delta < (45*60)) {
87
date_msg = 'about ' + pluralize("minute", parseInt(delta / 60)) + ' ago ';
88
} else if(delta < (24*60*60)) {
89
date_msg = 'about ' + pluralize("hour", parseInt(delta / 3600)) + ' ago ';
91
date_msg = 'about ' + pluralize("day", parseInt(delta / 86400)) + ' ago ';
79
93
var span = document.createElement("span");
80
94
span.className = 'comment';
81
95
var nick = document.createElement("span");
82
96
nick.className = 'nick';
83
nick.appendChild(document.createTextNode(twidenash.items[i].user +
97
nick.appendChild(document.createTextNode(twidenash.items[i].user));
98
var time = document.createElement("span");
99
time.className = 'time';
100
time.appendChild(document.createTextNode(" ( "+ date_msg +" ) "));
85
102
var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gi;
86
103
span.innerHTML = twidenash.items[i].text.replace(exp,"<a href='$1' target='_blank'>$1</a>");
87
104
li.appendChild(img);
88
105
li.appendChild(nick);
106
li.appendChild(time);
89
107
li.appendChild(span);
90
108
ul.appendChild(li);
91
109
twidenash.printed++;