var OAAS_CONTROLLER = (function (my, Backbone, OAAS_VIEW, OAAS_MODEL, _, $) { my.JobVisualExtensionListener = function (model, element) { var extension = new OAAS_MODEL.VisualExtension({ id: model.get('algorithmName') }); extension.fetch({ cache: true, success: function () { //eval extension.js -> execute addVisualExtension(model, element): var js = extension.get('ScenarioJs'); if (js != null) { (function (model, element) { addExtension = undefined; eval(js); if (addExtension) addExtension(model, element); } (model, element)); } }, error: function (model, response, options) { } }); }, my.JobPageController = function () { this.create = function () { var self = this; var jobList = new OAAS_MODEL.JobList(); var jobOverview = new OAAS_VIEW.JobOverView({ collection: jobList, el: $('#jobOverview') }); var listener = {}; // add listener capabilities to instance _.extend(listener, Backbone.Events); listener.listenTo(jobList, 'updated', function (evt) { // refresh overview jobOverview.render(); }); listener.listenTo(jobOverview, 'jobSelected', function (jobId) { var runList = new OAAS_MODEL.RunList({ jobId: jobId }); var lv = new OAAS_VIEW.LoadingView({ el: $('#jobDetails'), model: 'Loading results of job...' }); lv.render(); runList.fetch({ cache: false, success: function () { $('#jobDetails').empty(); var div = $('
').appendTo($('#jobDetails')); if (runList.models && runList.models.length == 0) { $('').text('No job results available!').appendTo(div); return; } // else draw the result view var rv = new OAAS_VIEW.ResultView({ model: runList, el: div }); listener.listenTo(rv, 'renderVisualExtension', my.JobVisualExtensionListener); rv.render(); var av = new OAAS_VIEW.AccordionView({ el: div }); av.render(); }, error: function (model, response, options) { $('#jobDetails').empty(); var lv = new OAAS_VIEW.LoadingView({ el: $('#jobDetails'), model: 'Error during retrieval!' }); lv.render(); } }); }); jobList.poll(); } } return my; } (OAAS_CONTROLLER || {}, Backbone, OAAS_VIEW, OAAS_MODEL, _, $));