Spaces:
Sleeping
Sleeping
File size: 1,675 Bytes
7dbf557 7c85b2c 7dbf557 7c85b2c 7dbf557 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
// intervalBegin()
function intervalBegin(){
console.log('cheeckingg')
// minutes= min *60*1000
// intervalAPI= setInterval( function() {
// const delay = ms => new Promise(res => setTimeout(res, ms));
ajax("/refreshDropbox")
.then(function(data) {
self.postMessage(data); // Code depending on result
})
// },3600000) // 60*60*1000
}
function ajax(url) {
return new Promise(function(resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.onload = function() {
resolve(this.responseText);
};
xhr.onerror = reject;
xhr.open('POST', url);
xhr.send();
});
}
// console.log(new Date(this.now.getFullYear(), this.now.getMonth(), this.now.getDate(), 9, 0, 0, 0) )
// this.now = new Date();
// this.hours = this.now.getHours();
// this.minutes = this.now.getMinutes();
// var millisTill10 = new Date(this.now.getFullYear(), this.now.getMonth(), this.now.getDate(), 9, 0, 0, 0) - this.now;
// console.log(this.now)
// if (millisTill10 < 0) {
// millisTill10 += 43200000; // try every 12 hours
// }
// setTimeout(function(){intervalBegin()}, millisTill10);
datenow= new Date();
var utc_timestamp =Date.UTC(datenow.getUTCFullYear(),datenow.getUTCMonth(), datenow.getUTCDate() , datenow.getUTCHours(), datenow.getUTCMinutes());
var utc_timestamp1 =Date.UTC(datenow.getUTCFullYear(),datenow.getUTCMonth(), datenow.getUTCDate() , 11, 0,0,0); //eet to utc - our time -2
millisTill10= utc_timestamp-utc_timestamp1
if (millisTill10 < 0) {
millisTill10 += 43200000; // try every 12 hours
}
setTimeout(function(){intervalBegin()}, millisTill10);
|