MeasurementTesting / static /DropboxWorker.js
Marthee's picture
Update static/DropboxWorker.js
7c85b2c verified
// 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);