Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- var xmlHttp, srvTime, thisDay;
- function getSrvTime() {
- try {
- xmlHttp = new XMLHttpRequest();
- }
- catch (err1) {
- try {
- xmlHttp = new ActiveXObject('Msxml2.XMLHTTP');
- }
- catch (err2) {
- try {
- xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
- }
- catch (eerr3) {
- // Browser didn't support ajax so use client time
- return new Date();
- }
- }
- }
- xmlHttp.open('HEAD', window.location.href.toString(), false);
- xmlHttp.setRequestHeader("Content-Type", "text/html");
- xmlHttp.send('');
- return xmlHttp.getResponseHeader("Date");
- }
- function updateSchedule() {
- var now = new Date(srvTime());
- var currentDay = now.getDay();
- if (currentDay !== thisDay) {
- // the day has changed so update div using jQuery
- jQuery("#schedule").load(location.href + " #schedule");
- // set thisDay to the currentDay (this means the function will only update once a day)
- thisDay = currentDay;
- }
- }
- (function($, window){
- $(function(){
- // get server time on init
- var now = new Date(getSrvTime());
- // set thisDay to the current day
- thisDay = now.getDay();
- // set the interval for polling (every 30 seconds
- setInterval(function() {
- updateSchedule();
- }, 30000);
- });
- })(jQuery, window);
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement