Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- static/API_Refresh_workerJS.js +13 -9
- static/DropboxWorker.js +38 -0
- static/MC_T_API_Worker.js +33 -0
static/API_Refresh_workerJS.js
CHANGED
|
@@ -1,28 +1,32 @@
|
|
| 1 |
-
// getRefreshAPIAjax()
|
| 2 |
intervalBegin()
|
| 3 |
|
|
|
|
| 4 |
function intervalBegin(){
|
| 5 |
// minutes= min *60*1000
|
| 6 |
-
intervalAPI= setInterval( getRefreshAPIAjax ,
|
| 7 |
|
| 8 |
}
|
| 9 |
|
| 10 |
function getRefreshAPIAjax(){
|
| 11 |
-
ajax("/refreshAPI")
|
| 12 |
-
.then(function(data) {
|
| 13 |
-
var data1=JSON.parse(data);
|
| 14 |
-
self.postMessage(data); // Code depending on result
|
| 15 |
-
})
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
}
|
| 18 |
-
|
|
|
|
|
|
|
| 19 |
return new Promise(function(resolve, reject) {
|
| 20 |
var xhr = new XMLHttpRequest();
|
| 21 |
xhr.onload = function() {
|
| 22 |
resolve(this.responseText);
|
| 23 |
};
|
| 24 |
xhr.onerror = reject;
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
| 26 |
xhr.send();
|
| 27 |
});
|
| 28 |
}
|
|
|
|
|
|
|
| 1 |
intervalBegin()
|
| 2 |
|
| 3 |
+
|
| 4 |
function intervalBegin(){
|
| 5 |
// minutes= min *60*1000
|
| 6 |
+
intervalAPI= setInterval( getRefreshAPIAjax ,300000) // 30*60*1000 // every 30 min
|
| 7 |
|
| 8 |
}
|
| 9 |
|
| 10 |
function getRefreshAPIAjax(){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
+
ajax("/refreshAPI")//, sectionData)
|
| 13 |
+
.then(function(data) {
|
| 14 |
+
self.postMessage(JSON.parse(data)); // Code depending on result
|
| 15 |
+
})
|
| 16 |
}
|
| 17 |
+
|
| 18 |
+
function ajax(url , sectionData) {
|
| 19 |
+
|
| 20 |
return new Promise(function(resolve, reject) {
|
| 21 |
var xhr = new XMLHttpRequest();
|
| 22 |
xhr.onload = function() {
|
| 23 |
resolve(this.responseText);
|
| 24 |
};
|
| 25 |
xhr.onerror = reject;
|
| 26 |
+
|
| 27 |
+
// xhr.open('POST', url, true);
|
| 28 |
+
// xhr.send("sectionData=" + sectionData);
|
| 29 |
+
xhr.open('GET', url)//+'?sectionData=' + sectionData);
|
| 30 |
xhr.send();
|
| 31 |
});
|
| 32 |
}
|
static/DropboxWorker.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// intervalBegin()
|
| 2 |
+
function intervalBegin(){
|
| 3 |
+
console.log('cheeckingg')
|
| 4 |
+
// minutes= min *60*1000
|
| 5 |
+
// intervalAPI= setInterval( function() {
|
| 6 |
+
|
| 7 |
+
// const delay = ms => new Promise(res => setTimeout(res, ms));
|
| 8 |
+
ajax("/refreshDropbox")
|
| 9 |
+
.then(function(data) {
|
| 10 |
+
self.postMessage(data); // Code depending on result
|
| 11 |
+
|
| 12 |
+
})
|
| 13 |
+
|
| 14 |
+
// },3600000) // 60*60*1000
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
function ajax(url) {
|
| 18 |
+
return new Promise(function(resolve, reject) {
|
| 19 |
+
var xhr = new XMLHttpRequest();
|
| 20 |
+
xhr.onload = function() {
|
| 21 |
+
resolve(this.responseText);
|
| 22 |
+
};
|
| 23 |
+
xhr.onerror = reject;
|
| 24 |
+
xhr.open('POST', url);
|
| 25 |
+
xhr.send();
|
| 26 |
+
});
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
this.now = new Date();
|
| 30 |
+
this.hours = this.now.getHours();
|
| 31 |
+
this.minutes = this.now.getMinutes();
|
| 32 |
+
|
| 33 |
+
var millisTill10 = new Date(this.now.getFullYear(), this.now.getMonth(), this.now.getDate(), 9, 0, 0, 0) - this.now;
|
| 34 |
+
console.log(this.now)
|
| 35 |
+
if (millisTill10 < 0) {
|
| 36 |
+
millisTill10 += 43200000; // try every 12 hours
|
| 37 |
+
}
|
| 38 |
+
setTimeout(function(){intervalBegin()}, millisTill10);
|
static/MC_T_API_Worker.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
intervalBegin()
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
function intervalBegin(){
|
| 5 |
+
// minutes= min *60*1000
|
| 6 |
+
intervalAPI= setInterval( getRefreshAPIAjax ,300000) // 30*60*1000 // every 30 min
|
| 7 |
+
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
function getRefreshAPIAjax(){
|
| 11 |
+
|
| 12 |
+
ajax('/RetrieveMCTNames/')
|
| 13 |
+
.then(function(data) {
|
| 14 |
+
MCTNames=JSON.parse(data);
|
| 15 |
+
self.postMessage(MCTNames); // Code depending on result
|
| 16 |
+
})
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
function ajax(url) { //sectionData
|
| 21 |
+
return new Promise(function(resolve, reject) {
|
| 22 |
+
var xhr = new XMLHttpRequest();
|
| 23 |
+
xhr.onload = function() {
|
| 24 |
+
resolve(this.responseText);
|
| 25 |
+
};
|
| 26 |
+
xhr.onerror = reject;
|
| 27 |
+
|
| 28 |
+
xhr.open('GET', url)//+'?jsdata=' + jsdata);
|
| 29 |
+
xhr.send();
|
| 30 |
+
});
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
/*Retrieve MCTNAMES Dictionary from API - Flask*/
|