Hi again. I just tried the updated version, April 5, but my multiple clocks do not keep the correct time. I have 5 clocks installed and only the last one changes so much so that within 4 minutes of real time my last clock has changed 20 minutes while the other 4 have not changed time at all. I guess I will have to revert back to my older version where I have modified the js code. I could post the changes I made, but not sure where to do that. Thanks for trying. -drew-pal

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tstoeckler’s picture

I think that would be #1427420: Multiple Clocks - not correct time.
It would be awesome (!!!) if you could post some form of patch over there. I am really pretty bad at JS. I have not dug deeply into that issue, but tried once for ~1 hour to fix the problem and failed. So any help is very much appreciated. (It always is, but it is more pressing for that issue :) )

drew-pal’s picture

Issue tags: +patch for clocks, +js file

The following js is the patch that I used for the clock.js file.
clocks[cid] begins at line #77

clocks[cid] = {
date: date,
dateFormat: dateFormat,
timeZone: timeZone,
}// END CLOCKS[CID]
}// END FOR LOOP

//BEGIN drew-pal MODIFICATION

//for (var i = 0; i < allSettings['names'].length; i++) {
var cid = allSettings['names'][0];
clock = clocks[cid];

$('span.' + cid).each(function () {

$(this).once(cid, function() {

window.setInterval(function () {

//moved the for loop to here

for (var i = 0; i < allSettings['names'].length; i++) {
cid = allSettings['names'][i];
clock = clocks[cid];

// Add 1 second (1000 milliseconds) to the time.
var timestamp = clock.date.getTime();
timestamp += 1000;
clock.date = new Date(timestamp);
// Format the clock.
formattedDate = formatDate(clock.date, clock.dateFormat, clock.timeZone, monthNames, weekdayNames);
$('span.' + cid).text(formattedDate);
clocks[cid] = clock;
};//end for loop

}, 1000);//end window.setInterval

});//end .once
});//end .each
//}//end original for

}
}

})(jQuery);

//END drew-pal MODIFICATION

sepehr.sadatifar’s picture

Status: Active » Needs review
FileSize
1.25 KB

thanks drew-pal , I confirm this works perfectly and made a patch.
for detailed explanation on how to make a patch see "Making a Drupal patch with Git" and "Advanced patch contributor guide".

tstoeckler’s picture

Status: Needs review » Fixed

Awesome stuff!!!
Thanks so much!
I just committed this to 7.x-2.x. I wasn't sure who to put in --author, but went with sepehrmm because he rolled the patch. I hope that's OK drew-pal!

Either way, this issue is proof that you guys are better at JS than I am, so I would love (!) to see you over in: #1311314: Refactor clock.js

Marking this fixed for now, although I was only able to test with 2 clocks, because of #1556074: Clocks can not be created (oops!)

Automatically closed -- issue fixed for 2 weeks with no activity.