Skip to content
Snippets Groups Projects
Commit 968a9c2d authored by Sebastien's avatar Sebastien
Browse files

Remove direct dependency from rekall to online-script.js

parent 006d4f58
No related branches found
No related tags found
1 merge request!98refresh the mosaic on annotation modification
...@@ -70,6 +70,10 @@ Rekall.prototype.allowProjectDeletion = function () { ...@@ -70,6 +70,10 @@ Rekall.prototype.allowProjectDeletion = function () {
this.Settings._allowProjectDeletion = arguments[0]; this.Settings._allowProjectDeletion = arguments[0];
} }
Rekall.prototype.publish = function (eventName, data){
return window.app.rekall.Rekall('pubSub').publish(eventName, data);
}
Rekall.prototype.loadXMLFile = function () { Rekall.prototype.loadXMLFile = function () {
var oldURL = window.document.location + ""; var oldURL = window.document.location + "";
var index = 0; var index = 0;
...@@ -92,16 +96,19 @@ Rekall.prototype.loadXMLFile = function () { ...@@ -92,16 +96,19 @@ Rekall.prototype.loadXMLFile = function () {
this.baseUrl = url; this.baseUrl = url;
let that = this; let that = this;
rouletteStart(); this.publish('roulette.started');
$.ajax("php/file.php?r=project.xml", { $.ajax("php/file.php?r=project.xml", {
type: "GET", type: "GET",
cache: false, cache: false,
data: {"rand": random()}, data: {"rand": Math.random()},
dataType: "xml", dataType: "xml",
success: function (xml) { success: function (xml) {
if ((xml == null) || (xml == undefined)) if ((xml == null) || (xml == undefined)) {
openAlert("Your project is unreachable. Did you move the folder to an other location?", 60); that.publish('alert', {
else { message: "Your project is unreachable. Did you move the folder to an other location?",
buttons: 60
});
} else {
$(xml).find('project').each(function () { $(xml).find('project').each(function () {
//if($(this).find('document').length == 0) { //if($(this).find('document').length == 0) {
// openAlert("Start by adding files to your project.", 60); // openAlert("Start by adding files to your project.", 60);
...@@ -112,21 +119,27 @@ Rekall.prototype.loadXMLFile = function () { ...@@ -112,21 +119,27 @@ Rekall.prototype.loadXMLFile = function () {
//} //}
}); });
} }
rouletteEnd(); that.publish('roulette.terminated', {});
}, },
error: function () { error: function () {
$.ajax("file/project.xml", { $.ajax("file/project.xml", {
type: "GET", type: "GET",
cache: false, cache: false,
data: {"rand": random()}, data: {"rand": Math.random()},
dataType: "xml", dataType: "xml",
success: function (xml) { success: function (xml) {
if ((xml == null) || (xml == undefined)) if ((xml == null) || (xml == undefined)) {
openAlert("Your project is unreachable. Did you move the folder to an other location?", 60); that.publish('alert', {
else { message: "Your project is unreachable. Did you move the folder to an other location?",
buttons: 60
});
} else {
$(xml).find('project').each(function () { $(xml).find('project').each(function () {
if ($(this).find('document').length == 0) { if ($(this).find('document').length == 0) {
openAlert("Start by adding files to your project.", 60); that.publish('alert', {
message: "Start by adding files to your project.",
buttons: 60
});
} else { } else {
if (that.project == undefined) if (that.project == undefined)
that.project = new Project(url, that); that.project = new Project(url, that);
...@@ -134,13 +147,13 @@ Rekall.prototype.loadXMLFile = function () { ...@@ -134,13 +147,13 @@ Rekall.prototype.loadXMLFile = function () {
} }
}); });
} }
rouletteEnd(); that.publish('roulette.terminated', {});
}, },
error: function () { error: function () {
rouletteEnd(); that.publish('roulette.terminated', {});
} }
}); });
rouletteEnd(); that.publish('roulette.terminated');
} }
}); });
} }
......
...@@ -12,6 +12,9 @@ window.onload = function() { ...@@ -12,6 +12,9 @@ window.onload = function() {
pubSub.subscribe('open_paste_modal', openPasteModal); pubSub.subscribe('open_paste_modal', openPasteModal);
pubSub.subscribe('close_paste_modal', closePasteModal); pubSub.subscribe('close_paste_modal', closePasteModal);
pubSub.subscribe('updated.project.name', onUpdatedProjectName); pubSub.subscribe('updated.project.name', onUpdatedProjectName);
pubSub.subscribe('alert', openAlertWrapper);
pubSub.subscribe('roulette.terminated', rouletteEnd);
pubSub.subscribe('roulette.started', rouletteStart);
}; };
$(document).ready(function() { $(document).ready(function() {
...@@ -655,6 +658,10 @@ function openAlert(message, buttons) { ...@@ -655,6 +658,10 @@ function openAlert(message, buttons) {
} }
} }
function openAlertWrapper(message, data){
openAlert(data.message, data.buttons);
}
function closeAlert() { function closeAlert() {
$("#popupAlertMessage").html(""); $("#popupAlertMessage").html("");
$(".popupAlertButton").hide(); $(".popupAlertButton").hide();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment