Old Proxomitron Forums
October 31, 2014, 01:02:49 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: No activity here! This forum is read-only. Go to http://prxbx.com/forums/index.php.
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Filter to add Javascript Time & Date to webpages  (Read 854 times)
arfirebird
Newbie
*
Posts: 9


View Profile WWW Email
« on: May 29, 2002, 08:20:42 PM »

OK, I can't take credit for writing the javascript on this
filter... I searched the web for a script to do what I
wanted & found one that was close...
did a couple of slight mods and came up with this.

Name = "Add Date & Time to top of page"
Active = TRUE
Multi = TRUE
Limit = 5096
Match = "<body1>"
Replace = "<body1><font color="ff0066"><center><script language="javascript"> date = new Date(); today=date.getDay(); if(today=="1") today="Monday"; else if(today=="2") today="Tuesday"; else if(today=="3") today="Wednesday"; else if(today=="4") today="Thursday"; else if(today=="5") today="Friday"; else if(today=="6") today="Saturday"; else if(today=="7") today="Sunday"; year=date.getYear(); month = date.getMonth(); hours = date.getHours(); if(hours < 10) hours = "0" + hours; minutes = date.getMinutes(); if(minutes < 10) minutes = "0" + minutes; seconds = date.getSeconds(); if(seconds < 10) seconds = "0" + seconds; day = date.getDate(); function y2k(number) { return(number<1000)?number+1900:number; } year=y2k(date.getYear()); if(month=="0") month="January"; else if(month=="1") month="February"; else if(month=="2") month="March"; else if(month=="3") month="April"; else if(month=="4") month="May"; else if(month=="5") month="June"; else if(month=="6") month="July"; else if(month=="7") month="August"; else if(month=="8") month="September"; else if(month=="9") month="October"; else if(month=="10") month="November"; else if(month=="11") month="December";  var the_date= today+" "+month+" "+day+","+year+" "; var the_time= hours+":"+minutes+":"+seconds; </script><script language="javascript"> document.write("Today is: " + the_date + ".  It's " + the_time + ".");  </script></font> </center>"

The Limit value may be larger than needed... not sure I haven't played
around with it to see if it still works like I want with a smaller value.
If you want to add the date & time to the bottom of the page instead
of or in additon to the top, download JD5000's config set (it has a filter
to add an END tag to the page, then make the following changes to
the filter above:

Name = "Add Date & Time to end of page"
Match = "<end>"
Replace = Same as filter above, just remove the "<body1>" part of
the replacement code.

The font will be red, you can of course change the font color value to
whatever suits your taste.

 
Logged

 
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!