phorte
February 24th, 2006, 12:02 AM
Alrite, well awhile back somebody was asking about adding a expiry date to kirupa's newsTicker newsTicker (http://www.kirupa.com/developer/mx2004/newsticker.htm). So yeah that was pretty simple, then few days ago, someone bumped that thread and was asking about adding in a starting date too. So yeah, i was fiddling around and got it too work eventually, and well thought i may as well share it with all of you. So here you go.
Basicly you just an extra node into the xml for the item you want to have an expiry of starting date:
<start>dd/mm/yyyy</start>
<expire>dd/mm/yyyy</expire>
So therefore if the current date is before the start date then the item wont be shown, and if it is after the expire date, then it wont be shown either, and if it is inbetween thoose two dates, it will be shown.
Also you dont have to add both, if you so wish it to start at a certain date and be shown forever, then just add the <start> node, and same deal with the expiry.
I basicly just stuck this into the existing code, and fiddling a few other bits around.//CHECKS FOR STARTED ITEMS
for (i = 0; i < total; i++) {
if (start[i] != undefined) {
temp = start[i].split("/");
if (year < temp[2] or (year == temp[2] and month < temp[1]) or (year == temp[2] and month == temp[1] and day < temp[0])) {
caption.splice(i, 1);
url.splice(i, 1);
expire.splice(i, 1);
start.splice(i, 1);
total--;
i = -1;
}
}
}
// CHECKS FOR EXPIRED ITEMS
for (i = 0; i < total; i++) {
if (expire[i] != undefined) {
temp = expire[i].split("/");
if (year > temp[2] or (year == temp[2] and month > temp[1]) or (year == temp[2] and month == temp[1] and day > temp[0])) {
caption.splice(i, 1);
url.splice(i, 1);
expire.splice(i, 1);
start.splice(i, 1);
total--;
i = -1;
}
}
}So yeah, let me know what you think.
-Aussie Devil
Basicly you just an extra node into the xml for the item you want to have an expiry of starting date:
<start>dd/mm/yyyy</start>
<expire>dd/mm/yyyy</expire>
So therefore if the current date is before the start date then the item wont be shown, and if it is after the expire date, then it wont be shown either, and if it is inbetween thoose two dates, it will be shown.
Also you dont have to add both, if you so wish it to start at a certain date and be shown forever, then just add the <start> node, and same deal with the expiry.
I basicly just stuck this into the existing code, and fiddling a few other bits around.//CHECKS FOR STARTED ITEMS
for (i = 0; i < total; i++) {
if (start[i] != undefined) {
temp = start[i].split("/");
if (year < temp[2] or (year == temp[2] and month < temp[1]) or (year == temp[2] and month == temp[1] and day < temp[0])) {
caption.splice(i, 1);
url.splice(i, 1);
expire.splice(i, 1);
start.splice(i, 1);
total--;
i = -1;
}
}
}
// CHECKS FOR EXPIRED ITEMS
for (i = 0; i < total; i++) {
if (expire[i] != undefined) {
temp = expire[i].split("/");
if (year > temp[2] or (year == temp[2] and month > temp[1]) or (year == temp[2] and month == temp[1] and day > temp[0])) {
caption.splice(i, 1);
url.splice(i, 1);
expire.splice(i, 1);
start.splice(i, 1);
total--;
i = -1;
}
}
}So yeah, let me know what you think.
-Aussie Devil