//copyright:@Meaue 2011.4.28
function executeTimeLink(){
var timeLinkList = getTimeLinkList();
for(var i=0; i<timeLinkList.length; i++){
//timetag is not necessarily class...
var timetag = timeLinkList(i).id;
if( timetag != null){
var content=timetag.split("timelink");
//supposing... id="timelink_start:2002.12.31_end:2004.12.12"
if(content[0]=="" && content[1]!=null){
var limits = content[1].split("_");
for(var m=0; m<limits.length; m++){
if(limits[m].match(/./)){
var methodAndTime = limits[m].split(":");
var now = new Date();
//Further extension is possible.
alert(methodAndTime[0]);
if(methodAndTime[0]=="start" && isValidTimeLink(methodAndTime[1])){
//dissapear if date is before start
if(now-toDate(methodAndTime[1])< 0){
dissapear(timeLinkList(i));
}
}
if(methodAndTime[0]=="end" && isValidTimeLink(methodAndTime[1])){
//disappear if date is after end
if(now-toDate(methodAndTime[1])>0){
disappear(timeLinkList(i));
}
}
}
}
}
}
}
}
function getTimeLinkList(){
var elemList = document.getElementsByTagName("div");
return elemList;
}
function disappear(timeLink){
//make the tag empty
document.getElementById(timeLink.id).innerHTML = "";
}
function toDate(time){
var contents = time.split(".");
return new Date(contents[0], contents[1]+1, contents[2]);
}
function isValidTimeLink(str){
//leap year should be concerned...
if(str.match(/./)){
var contents = str.split(".");
if(contents.length == 3){
return true;
}
}
return false;
}
window.onload=executeTimeLink;