From 864637d8469ec0b40c41ef80c661e6e923cd0a66 Mon Sep 17 00:00:00 2001 From: PeterTheOne Date: Thu, 28 Jan 2016 16:50:14 +0100 Subject: musicpool fetch pool carts and cuts diff --git a/www/js/musicpools.js b/www/js/musicpools.js index 6b46981..30e9d70 100644 --- a/www/js/musicpools.js +++ b/www/js/musicpools.js @@ -39,11 +39,23 @@ function musicpools_cleanup() { var Musicpools = function() { // todo: get current Pool Id from session like shows? this.currentPoolId = sessionStorage.getItem("currentPoolId"); - this.currentPoolId = this.currentPoolId === null ? 0 : this.currentPoolId; this.musicpools = []; this.fetch(); }; +Musicpools.prototype.getCurrentPool = function() { + if (this.musicpools.length === 0) { + return null; + } + if (this.currentPoolId === null) { + this.currentPoolId = 0; + } + if (this.currentPoolId > this.musicpools.length) { + this.currentPoolId = 0; + } + return this.musicpools[this.currentPoolId]; +}; + Musicpools.prototype.fetch = function() { var self = this; @@ -79,6 +91,12 @@ Musicpools.prototype.updateSelector = function() { $('#musicpool-selector').append($('