Spaces:
Sleeping
Sleeping
Update static/API_Refresh_workerJS.js
Browse files
static/API_Refresh_workerJS.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
var prjname=''
|
| 2 |
var prjpart=''
|
|
|
|
| 3 |
self.onmessage = function(event) {
|
| 4 |
console.log('Message received from main script:', event.data);
|
| 5 |
console.log(typeof event.data)
|
|
@@ -7,6 +8,7 @@ self.onmessage = function(event) {
|
|
| 7 |
{
|
| 8 |
prjname=event.data[0]
|
| 9 |
prjpart=event.data[1]
|
|
|
|
| 10 |
console.log(prjname,prjpart)
|
| 11 |
}
|
| 12 |
|
|
@@ -27,21 +29,13 @@ function intervalBegin(){
|
|
| 27 |
function getRefreshAPIAjax(){
|
| 28 |
|
| 29 |
console.log(prjname,'jgjk')
|
| 30 |
-
ajax("/refreshAPI",prjname,prjpart)//, sectionData)
|
| 31 |
.then(function(data) {
|
| 32 |
self.postMessage(data); // Code depending on result
|
| 33 |
})
|
| 34 |
}
|
| 35 |
|
| 36 |
|
| 37 |
-
// function getRefreshAPIPartAjax(prjname){
|
| 38 |
-
|
| 39 |
-
// ajax("/getnewparts",prjname)//, sectionData)
|
| 40 |
-
// .then(function(data) {
|
| 41 |
-
// self.postMessage(data); // Code depending on result ['parts',data]
|
| 42 |
-
// })
|
| 43 |
-
// }
|
| 44 |
-
|
| 45 |
function ajax(url , prjname=0) {
|
| 46 |
|
| 47 |
return new Promise(function(resolve, reject) {
|
|
@@ -51,8 +45,8 @@ function ajax(url , prjname=0) {
|
|
| 51 |
};
|
| 52 |
xhr.onerror = reject;
|
| 53 |
if (prjname){
|
| 54 |
-
console.log('gss',prjname,prjpart)
|
| 55 |
-
xhr.open('GET', url+'?prjname=' + prjname+'&prjpart=' + prjpart );
|
| 56 |
xhr.send();
|
| 57 |
}
|
| 58 |
else
|
|
@@ -75,52 +69,5 @@ function appendtotables(data){
|
|
| 75 |
}
|
| 76 |
|
| 77 |
|
| 78 |
-
// $.ajax({
|
| 79 |
-
// type: "POST",
|
| 80 |
-
// url: '/refreshAPIAppendNewTables',
|
| 81 |
-
// // set content type header to use Flask response.get_json()
|
| 82 |
-
// contentType: "application/json",
|
| 83 |
-
// // convert data/object to JSON to send
|
| 84 |
-
// data: JSON.stringify({value:data[1]}),
|
| 85 |
-
// // expect JSON data in return (e.g. Flask jsonify)
|
| 86 |
-
// dataType: "json",
|
| 87 |
-
// // handle response
|
| 88 |
-
// success: function(response) {
|
| 89 |
-
// self.addEventListener('message', function(e) {
|
| 90 |
-
|
| 91 |
-
// self.postMessage('heeeeyyyy');
|
| 92 |
-
// }, false);
|
| 93 |
-
// if (data[1].toString()==='projectsection')
|
| 94 |
-
// {
|
| 95 |
-
// displayprjnames();
|
| 96 |
-
// displayprojsections();
|
| 97 |
-
// }
|
| 98 |
-
// if (data[1].toString()==='project')
|
| 99 |
-
// displayprjnames();
|
| 100 |
-
// if (data[1].toString()==='part')
|
| 101 |
-
// displayprojparts();
|
| 102 |
-
// if (data[1].toString()==='section')
|
| 103 |
-
// displayprojsections();
|
| 104 |
-
// if (data[1].toString()==='projectpart')
|
| 105 |
-
// {
|
| 106 |
-
// displayprjnames();
|
| 107 |
-
// displayprojparts();
|
| 108 |
-
// }
|
| 109 |
-
// if (data[1].toString()==='partsection')
|
| 110 |
-
// {
|
| 111 |
-
// displayprojparts();
|
| 112 |
-
// displayprojsections();
|
| 113 |
-
// }
|
| 114 |
-
|
| 115 |
-
// },
|
| 116 |
-
// error: function(err) {
|
| 117 |
-
// PopupElement.textContent='Error occured. Refresh and try again. If the error continues, please contact the ADR team to fix it. ';
|
| 118 |
-
// ShowPopUp();
|
| 119 |
-
|
| 120 |
-
// }
|
| 121 |
-
// })
|
| 122 |
-
// }
|
| 123 |
-
|
| 124 |
-
|
| 125 |
|
| 126 |
|
|
|
|
| 1 |
var prjname=''
|
| 2 |
var prjpart=''
|
| 3 |
+
var prjpartid=''
|
| 4 |
self.onmessage = function(event) {
|
| 5 |
console.log('Message received from main script:', event.data);
|
| 6 |
console.log(typeof event.data)
|
|
|
|
| 8 |
{
|
| 9 |
prjname=event.data[0]
|
| 10 |
prjpart=event.data[1]
|
| 11 |
+
prjpartid=event.data[2]
|
| 12 |
console.log(prjname,prjpart)
|
| 13 |
}
|
| 14 |
|
|
|
|
| 29 |
function getRefreshAPIAjax(){
|
| 30 |
|
| 31 |
console.log(prjname,'jgjk')
|
| 32 |
+
ajax("/refreshAPI",prjname,prjpart,prjpartid)//, sectionData)
|
| 33 |
.then(function(data) {
|
| 34 |
self.postMessage(data); // Code depending on result
|
| 35 |
})
|
| 36 |
}
|
| 37 |
|
| 38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
function ajax(url , prjname=0) {
|
| 40 |
|
| 41 |
return new Promise(function(resolve, reject) {
|
|
|
|
| 45 |
};
|
| 46 |
xhr.onerror = reject;
|
| 47 |
if (prjname){
|
| 48 |
+
console.log('gss',prjname,prjpart,prjpartid)
|
| 49 |
+
xhr.open('GET', url+'?prjname=' + prjname+'&prjpart=' + prjpart+'&prjpartid=' + prjpartid );
|
| 50 |
xhr.send();
|
| 51 |
}
|
| 52 |
else
|
|
|
|
| 69 |
}
|
| 70 |
|
| 71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
|