mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-06 20:56:42 +08:00
refactor initProjectExperiment
This commit is contained in:
parent
cac5033eba
commit
b86e67a0d6
1 changed files with 27 additions and 20 deletions
|
@ -1,30 +1,38 @@
|
|||
(function(){
|
||||
var count = 0;
|
||||
|
||||
function initProjectExperiment(){
|
||||
var url = $("[data-lupdated-url]").data("lupdated-url");
|
||||
var updated = "[data-id=" + $("[data-lupdated-id]").data('lupdated-id') +"]";
|
||||
var el = $(updated).find("img");
|
||||
el.hide();
|
||||
var timestamp = el.data("timestamp");
|
||||
var img_url = $(updated).find(".workflowimg-container").data('updated-img');
|
||||
animateSpinner($(updated).find(".workflowimg-container"), true);
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: "GET",
|
||||
data: { "timestamp": timestamp },
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
getNewWorkforwImg(el, img_url, updated);
|
||||
animateSpinner($(updated).find(".workflowimg-container"), false);
|
||||
},
|
||||
error: function (ev) {
|
||||
if (ev.status == 404) {
|
||||
setTimeout(initProjectExperiment(), 200);
|
||||
}
|
||||
animateSpinner($(updated).find(".workflowimg-container"), false);
|
||||
}
|
||||
});
|
||||
animateSpinner($(updated).find(".workflowimg-container"), true);
|
||||
checkUpdatedImg(el, img_url, url, timestamp, updated);
|
||||
animateSpinner($(updated).find(".workflowimg-container"), false);
|
||||
}
|
||||
|
||||
|
||||
function checkUpdatedImg(el, img_url, url, timestamp, updated){
|
||||
if (count !== 100){
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: "GET",
|
||||
data: { "timestamp": timestamp },
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
getNewWorkforwImg(el, img_url, updated);
|
||||
animateSpinner($(updated).find(".workflowimg-container"), false);
|
||||
},
|
||||
error: function (ev) {
|
||||
if (ev.status == 404) {
|
||||
setTimeout(checkUpdatedImg(el, img_url, url, timestamp, updated), 200);
|
||||
}
|
||||
count++;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function getNewWorkforwImg(el, url, updated){
|
||||
|
@ -35,10 +43,9 @@
|
|||
success: function (data) {
|
||||
el.html(data.workflowimg);
|
||||
animateSpinner($(updated).find(".workflowimg-container"), false);
|
||||
|
||||
},
|
||||
error: function (ev) {
|
||||
animateSpinner($(updated).find(".workflowimg-container"), false);
|
||||
// TODO
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue