diff --git a/pandora/static/js/pandora.js b/pandora/static/js/pandora.js index d11aa860..f5c99c9d 100755 --- a/pandora/static/js/pandora.js +++ b/pandora/static/js/pandora.js @@ -55,7 +55,7 @@ var app = new Ox.App({ Ox.print('requestStop') app.$ui.loadingIcon.stop(); }); - + $.each(app.afterLaunch, function(i, fn){ fn() }); }); @@ -1940,4 +1940,4 @@ app.getGroupWidth = function(pos, panelWidth) { }); -*/ \ No newline at end of file +*/ diff --git a/pandora/static/js/pandora.local.js b/pandora/static/js/pandora.local.js new file mode 100644 index 00000000..78d2d356 --- /dev/null +++ b/pandora/static/js/pandora.local.js @@ -0,0 +1,312 @@ +$(function() { + if (typeof(OxFF) == 'undefined') + return; + app.local = { + api: new OxFF(), + volumes: function(cb) { + var _this = this; + this.api.access(function(access) { + Ox.print('access callback', access); + if(!access) { + var dialogHeight = app.$document.height()/2, + dialogWidth = parseInt((dialogHeight - 48) * 0.75); + + var $dialog = new Ox.Dialog({ + buttons: [ + { + title: 'Close', + click: function() { + $dialog.close(); + delete $dialog; + } + } + ], + height: dialogHeight, + padding: 0, + title: "Pan.do/ra OxFF Local Archive", + width: dialogWidth + }) + .append("For this part of the page to work, you have to allow OxFF to send data to this site") + .open(); + } else { + Ox.print('we got it, lets party'); + _this.api.login(app.user.username); + _this.api.volumes(function(result) { + var data = JSON.parse(result); + cb(data); + }); + } + }); + }, + files: function(archive, cb) { + if(!this.api.access()) + return false; + this.api.login(app.user.username); + this.api.files(archive, function(result) { + var data = JSON.parse(result); + cb(data); + }); + return true; + }, + upload: function(options, done_cb, progress_cb) { + function wrap(cb) { + if(!cb) + return null; + return function(result) { + var data = JSON.parse(result); + cb(data) + } + } + this.api.upload(JSON.stringify(options), + wrap(done_cb), + wrap(progress_cb)); + return true; + }, + parsePath: function(path) { + var folder = path.split('/'); + folder.pop(); + if(folder.length==0) { + folder.push("rootfolder"); + } + //FIXME: this is also done on the backend but might require more sub options + if (folder[folder.length-1] == "Extras" || folder[folder.length-1] == "Versions") + folder.pop(); + folder = folder.join('/'); + return { + folder: folder, + name: path.substring(folder.length), + } + }, + loadVolumes: function() { + Ox.print("load volumes"); + var $section = new Ox.CollapsePanel({ + id: 'volumes', + size: 'small', + title: 'Volumes' + }); + app.$ui.sections.push($section); + app.local.volumes(function(data) { + Ox.print("got volumes", data); + $.each(data, function(name, info) { + Ox.print("add volume", name, info); + var status = info.available?"online":"offline"; + var $line = $('