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
|
|
|
|
2016-08-22 17:29:19 +08:00
|
|
|
function init(){
|
|
|
|
$("[data-id]").each(function(){
|
|
|
|
var that = $(this);
|
|
|
|
that.find(".workflowimg-container").hide();
|
|
|
|
initProjectExperiment(that);
|
|
|
|
});
|
2016-11-14 21:27:35 +08:00
|
|
|
|
|
|
|
initTutorial();
|
2016-08-19 22:38:34 +08:00
|
|
|
}
|
2016-08-19 21:36:12 +08:00
|
|
|
|
2016-08-22 17:29:19 +08:00
|
|
|
function initProjectExperiment(element){
|
|
|
|
var container = element.find(".workflowimg-container");
|
|
|
|
var url = container.data("check-img");
|
|
|
|
var timestamp = container.data("timestamp");
|
|
|
|
var img_url = container.data('updated-img');
|
2016-08-19 22:38:34 +08:00
|
|
|
|
2016-08-22 17:29:19 +08:00
|
|
|
animateSpinner(container, true);
|
|
|
|
checkUpdatedImg(img_url, url, timestamp, container);
|
|
|
|
}
|
|
|
|
|
|
|
|
// checks if the experiment image is updated
|
|
|
|
function checkUpdatedImg(img_url, url, timestamp, container){
|
|
|
|
if (count < 30 && timestamp){
|
2016-08-19 22:38:34 +08:00
|
|
|
$.ajax({
|
|
|
|
url: url,
|
|
|
|
type: "GET",
|
|
|
|
data: { "timestamp": timestamp },
|
|
|
|
dataType: "json",
|
|
|
|
success: function (data) {
|
2016-08-22 17:29:19 +08:00
|
|
|
getNewWorkforwImg(container, img_url);
|
|
|
|
container.show();
|
|
|
|
animateSpinner(container, false);
|
2016-08-19 22:38:34 +08:00
|
|
|
},
|
|
|
|
error: function (ev) {
|
|
|
|
if (ev.status == 404) {
|
2016-08-22 17:29:19 +08:00
|
|
|
setTimeout(checkUpdatedImg(img_url, url, timestamp, container), 500);
|
|
|
|
} else {
|
|
|
|
animateSpinner(container, false);
|
|
|
|
}
|
|
|
|
count++;
|
2016-08-19 22:38:34 +08:00
|
|
|
}
|
|
|
|
});
|
2016-08-22 17:29:19 +08:00
|
|
|
} else {
|
|
|
|
animateSpinner(container, false);
|
2016-08-19 22:38:34 +08:00
|
|
|
}
|
2016-08-19 21:36:12 +08:00
|
|
|
}
|
|
|
|
|
2016-08-22 17:29:19 +08:00
|
|
|
// fetch the new experiment image
|
|
|
|
function getNewWorkforwImg(el, url){
|
2016-08-19 21:36:12 +08:00
|
|
|
$.ajax({
|
|
|
|
url: url,
|
|
|
|
type: "GET",
|
|
|
|
dataType: "json",
|
|
|
|
success: function (data) {
|
2016-08-22 17:29:19 +08:00
|
|
|
el.append(data.workflowimg);
|
2016-08-19 21:36:12 +08:00
|
|
|
},
|
|
|
|
error: function (ev) {
|
2016-08-19 22:38:34 +08:00
|
|
|
// TODO
|
2016-08-19 21:36:12 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2016-08-25 01:03:58 +08:00
|
|
|
|
2016-11-14 21:27:35 +08:00
|
|
|
/**
|
|
|
|
* Initializes tutorial
|
|
|
|
*/
|
|
|
|
function initTutorial() {
|
2016-11-22 20:49:35 +08:00
|
|
|
var stepNum = parseInt(Cookies.get('current_tutorial_step'), 10);
|
|
|
|
if (stepNum >= 4 && stepNum <= 5) {
|
|
|
|
var nextPage = $('[data-canvas-link]').data('canvasLink');
|
2017-04-25 21:06:18 +08:00
|
|
|
var steps = [{
|
|
|
|
element: $('#new-experiment')[0],
|
|
|
|
intro: I18n.t('tutorial.tutorial_welcome_title_html'),
|
|
|
|
position: 'left'
|
|
|
|
}, {
|
|
|
|
element: $('.experiment-panel')[0],
|
|
|
|
intro: I18n.t('tutorial.edit_experiment_html'),
|
|
|
|
position: 'right'
|
|
|
|
}];
|
|
|
|
initPageTutorialSteps(4, 5, nextPage, tutorialBeforeCb, tutorialAfterCb,
|
|
|
|
steps);
|
2016-11-22 20:49:35 +08:00
|
|
|
}
|
2016-08-25 01:03:58 +08:00
|
|
|
}
|
|
|
|
|
2016-11-14 21:27:35 +08:00
|
|
|
/**
|
2016-11-16 02:30:17 +08:00
|
|
|
* Callback to be executed before tutorial starts
|
2016-11-14 21:27:35 +08:00
|
|
|
*/
|
|
|
|
function tutorialBeforeCb() {
|
|
|
|
$.each( $(".panel-title"), function(){
|
|
|
|
$(this).css({ "pointer-events": "none" });
|
|
|
|
});
|
|
|
|
$.each( $(".workflowimg-container"), function(){
|
|
|
|
$(this).css({ "pointer-events": "none" });
|
|
|
|
});
|
|
|
|
$.each( $(".dropdown-experiment-actions").find("li"),
|
|
|
|
function(){
|
|
|
|
$(this).css({ "pointer-events": "none" });
|
2016-08-25 21:16:51 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-11-14 21:27:35 +08:00
|
|
|
/**
|
|
|
|
* Callback to be executed after tutorial exits
|
|
|
|
*/
|
|
|
|
function tutorialAfterCb() {
|
2016-08-30 14:52:44 +08:00
|
|
|
$.each( $(".panel-title"), function(){
|
2016-08-30 17:03:33 +08:00
|
|
|
$(this).css({ "pointer-events": "auto" });
|
|
|
|
});
|
|
|
|
$.each( $(".workflowimg-container"), function(){
|
|
|
|
$(this).css({ "pointer-events": "auto" });
|
2016-08-30 14:52:44 +08:00
|
|
|
});
|
2016-08-25 21:16:51 +08:00
|
|
|
$.each( $(".dropdown-experiment-actions").find("li"),
|
|
|
|
function(){
|
2016-08-30 17:03:33 +08:00
|
|
|
$(this).css({ "pointer-events": "auto" });
|
2016-08-25 21:16:51 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-11-14 21:27:35 +08:00
|
|
|
init();
|
2016-08-25 01:03:58 +08:00
|
|
|
})();
|