diff --git a/capsule-prototype/js/online-rekall/Rekall.js b/capsule-prototype/js/online-rekall/Rekall.js index 67d737618f8f37575f6eec3878ae3bd85ef73948..971ed994e585972f879df97e842ae97ee0b81e9e 100644 --- a/capsule-prototype/js/online-rekall/Rekall.js +++ b/capsule-prototype/js/online-rekall/Rekall.js @@ -70,6 +70,10 @@ Rekall.prototype.allowProjectDeletion = function () { this.Settings._allowProjectDeletion = arguments[0]; } +Rekall.prototype.publish = function (eventName, data){ + return window.app.rekall.Rekall('pubSub').publish(eventName, data); +} + Rekall.prototype.loadXMLFile = function () { var oldURL = window.document.location + ""; var index = 0; @@ -92,16 +96,19 @@ Rekall.prototype.loadXMLFile = function () { this.baseUrl = url; let that = this; - rouletteStart(); + this.publish('roulette.started'); $.ajax("php/file.php?r=project.xml", { type: "GET", cache: false, - data: {"rand": random()}, + data: {"rand": Math.random()}, dataType: "xml", success: function (xml) { - if ((xml == null) || (xml == undefined)) - openAlert("Your project is unreachable. Did you move the folder to an other location?", 60); - else { + if ((xml == null) || (xml == undefined)) { + that.publish('alert', { + message: "Your project is unreachable. Did you move the folder to an other location?", + buttons: 60 + }); + } else { $(xml).find('project').each(function () { //if($(this).find('document').length == 0) { // openAlert("Start by adding files to your project.", 60); @@ -112,21 +119,27 @@ Rekall.prototype.loadXMLFile = function () { //} }); } - rouletteEnd(); + that.publish('roulette.terminated', {}); }, error: function () { $.ajax("file/project.xml", { type: "GET", cache: false, - data: {"rand": random()}, + data: {"rand": Math.random()}, dataType: "xml", success: function (xml) { - if ((xml == null) || (xml == undefined)) - openAlert("Your project is unreachable. Did you move the folder to an other location?", 60); - else { + if ((xml == null) || (xml == undefined)) { + that.publish('alert', { + message: "Your project is unreachable. Did you move the folder to an other location?", + buttons: 60 + }); + } else { $(xml).find('project').each(function () { 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 { if (that.project == undefined) that.project = new Project(url, that); @@ -134,13 +147,13 @@ Rekall.prototype.loadXMLFile = function () { } }); } - rouletteEnd(); + that.publish('roulette.terminated', {}); }, error: function () { - rouletteEnd(); + that.publish('roulette.terminated', {}); } }); - rouletteEnd(); + that.publish('roulette.terminated'); } }); } @@ -236,4 +249,4 @@ Rekall.prototype.ensureVideoPlayerCreated = function (url, tech) { }); return true; -} \ No newline at end of file +} diff --git a/capsule-prototype/js/online-script.js b/capsule-prototype/js/online-script.js index 3a2987758bce3e6b1551067088f6deec32ea8fc5..ddda241364803cd5d8ff99fffe23fa3ebde655d1 100644 --- a/capsule-prototype/js/online-script.js +++ b/capsule-prototype/js/online-script.js @@ -12,6 +12,9 @@ window.onload = function() { pubSub.subscribe('open_paste_modal', openPasteModal); pubSub.subscribe('close_paste_modal', closePasteModal); pubSub.subscribe('updated.project.name', onUpdatedProjectName); + pubSub.subscribe('alert', openAlertWrapper); + pubSub.subscribe('roulette.terminated', rouletteEnd); + pubSub.subscribe('roulette.started', rouletteStart); }; $(document).ready(function() { @@ -655,6 +658,10 @@ function openAlert(message, buttons) { } } +function openAlertWrapper(message, data){ + openAlert(data.message, data.buttons); +} + function closeAlert() { $("#popupAlertMessage").html(""); $(".popupAlertButton").hide();