2016-08-19 21:36:12 +08:00
|
|
|
(function(){
|
2016-08-19 22:38:34 +08:00
|
|
|
var count = 0;
|
2016-08-19 21:36:12 +08:00
|
|
|
|
|
|
|
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");
|
|
|
|
var timestamp = el.data("timestamp");
|
|
|
|
var img_url = $(updated).find(".workflowimg-container").data('updated-img');
|
2016-08-19 22:38:34 +08:00
|
|
|
|
2016-08-19 21:36:12 +08:00
|
|
|
animateSpinner($(updated).find(".workflowimg-container"), true);
|
2016-08-19 22:38:34 +08:00
|
|
|
checkUpdatedImg(el, img_url, url, timestamp, updated);
|
|
|
|
animateSpinner($(updated).find(".workflowimg-container"), false);
|
|
|
|
}
|
2016-08-19 21:36:12 +08:00
|
|
|
|
2016-08-19 22:38:34 +08:00
|
|
|
|
|
|
|
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++;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2016-08-19 21:36:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function getNewWorkforwImg(el, url, updated){
|
|
|
|
$.ajax({
|
|
|
|
url: url,
|
|
|
|
type: "GET",
|
|
|
|
dataType: "json",
|
|
|
|
success: function (data) {
|
|
|
|
el.html(data.workflowimg);
|
|
|
|
animateSpinner($(updated).find(".workflowimg-container"), false);
|
|
|
|
},
|
|
|
|
error: function (ev) {
|
2016-08-19 22:38:34 +08:00
|
|
|
// TODO
|
2016-08-19 21:36:12 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
// init
|
|
|
|
initProjectExperiment();
|
|
|
|
})();
|