is now set to false
function addEvent(obj, evType, fn){
if(obj.addEventListener){
obj.addEventListener(evType, fn, false);
return true;
} else if (obj.attachEvent){
var r = obj.attachEvent('on'+evType, fn);
return r;
} else {
return false;
}
}
// Time Since
// by Mark Wubben - http://neo.dzygn.com
Date.prototype.toTimeSinceString = function(nLimit, sBetween, sLastBetween){
if(!nLimit){ nLimit = 2; }
if(!sBetween){ sBetween = ", "; }
if(!sLastBetween){ sLastBetween = " and "; }
if(!Date.prototype.toTimeSinceString._collStructs){
Date.prototype.toTimeSinceString._collStructs = new Array(
{seconds: 60 * 60 * 24 * 365, name: "year"},
{seconds: 60 * 60 * 24 * 30, name: "month"},
{seconds: 60 * 60 * 24 * 7, name: "week"},
{seconds: 60 * 60 * 24, name: "day"},
{seconds: 60 * 60, name: "hour"},
{seconds: 60, name: "minute"}
);
}
var collStructs = Date.prototype.toTimeSinceString._collStructs;
var nSecondsRemain = ((new Date).valueOf() - this.valueOf()) / 1000;
var sReturn = "";
var nCount = 0;
var nFloored;
for(var i = 0; i < collStructs.length && nCount < nLimit; i++){
nFloored = Math.floor(nSecondsRemain / collStructs[i].seconds);
if(nFloored > 0){
if(sReturn.length > 0){
if(nCount == nLimit - 1 || i == collStructs.length - 1){
sReturn += sLastBetween;
} else if(nCount < nLimit && i < collStructs.length){
sReturn += sBetween;
}
}
sReturn += nFloored + " " + collStructs[i].name;
if(nFloored > 1){
sReturn += "s";
}
nSecondsRemain -= nFloored * collStructs[i].seconds;
nCount++;
}
}
return sReturn;
}
// Here the default nice titles are created
// by Dunstan Orchard - http://www.1976design.com/
// Improved by Victor Kulinski - http://www.victr.lm85.com/
FancyTooltips.autoCreation = function(){
if(!document.getElementsByTagName){ return; }
function rewriteDateTime(collNodes){
var nMonth, nDay, nHours, nMinutes, nSeconds, sDateTime, oDate;
for(var i = 0; i < collNodes.length; i++){
sDateTime = collNodes[i].getAttribute("datetime");
if(sDateTime != null || sDateTime != ""){
nYear = Number(sDateTime.substring(0,4));
nMonth = Number(sDateTime.substring(5,7)) - 1;
nDay = Number(sDateTime.substring(8,10));
nHours = Number(sDateTime.substring(11, 13));
nMinutes = Number(sDateTime.substring(14,16));
nSeconds = Number(sDateTime.substring(17,19));
oDate = new Date(nYear, nMonth, nDay, nHours, nMinutes, nSeconds);
collNodes[i].setAttribute("nicetime", oDate.toTimeSinceString());
collNodes[i].setAttribute("gmttime", oDate.toGMTString());
}
}
return collNodes;
}
FancyTooltips.autoCreated = new Object();
FancyTooltips.autoCreated.anchors = new FancyTooltips("attr(fancytooltip)? [attr(accesskey)]?
attr(href)
", 600);
FancyTooltips.autoCreated.inserts = new FancyTooltips("Added attr(fancytooltip) ago
Complete timestamp: attr(gmttime)
?Reason: attr(cite)
?", 600);
FancyTooltips.autoCreated.deletions = new FancyTooltips("Deleted attr(fancytooltip) ago
Complete timestamp: attr(gmttime)
?Reason: attr(cite)
?", 600);
FancyTooltips.autoCreated.acronyms = new FancyTooltips("content(): attr(fancytooltip)
", 600);
FancyTooltips.autoCreated.abbreviations = new FancyTooltips("content(): attr(fancytooltip)
", 600);
FancyTooltips.autoCreated.images = new FancyTooltips("Caption: attr(fancytooltip)
", 600);
// More of Restrict to ID
// - by Chris Beaven and Brett Taylor - http://www.webfroot.co.nz/
if (sOnlyInThisID) {
oNode = document.getElementById(sOnlyInThisID);
} else {
oNode = null;
}
if (!oNode) {
oNode = document;
}
FancyTooltips.autoCreated.anchors.addElements(oNode.getElementsByTagName("a"), "title");
FancyTooltips.autoCreated.inserts.addElements(rewriteDateTime(oNode.getElementsByTagName("ins")), "nicetime");
FancyTooltips.autoCreated.deletions.addElements(rewriteDateTime(oNode.getElementsByTagName("del")), "nicetime");
FancyTooltips.autoCreated.acronyms.addElements(oNode.getElementsByTagName("acronym"), "title");
FancyTooltips.autoCreated.acronyms.addElements(oNode.getElementsByTagName("abbr"), "title");
// FancyTooltips img recognition.
// - Turned off by default. To turn it on, remove /* */ around the
// first line. This will display alt FancyTooltips. For title tooltips,
// remove /* */ from the second line. This may, however, cause problems
// in MSIE (Microsoft Internet Explorer.
// - by Victor Kulinski - http://www.victr.lm85.com/
/* FancyTooltips.autoCreated.images.addElements(oNode.getElementsByTagName("img"), "alt"); */
/* FancyTooltips.autoCreated.images.addElements(document.getElementsByTagName("img"), "title"); */
}
addEvent(window, "load", FancyTooltips.autoCreation);