diff options
Diffstat (limited to 'www/js/rivendell.rh.js')
-rw-r--r-- | www/js/rivendell.rh.js | 83 |
1 files changed, 48 insertions, 35 deletions
diff --git a/www/js/rivendell.rh.js b/www/js/rivendell.rh.js index fdacd85..dde1fda 100644 --- a/www/js/rivendell.rh.js +++ b/www/js/rivendell.rh.js @@ -72,51 +72,32 @@ Rivendell.Rivendell.prototype.setMusicgrid = function(dow, hour, name, success) return $.post(this.musicgridEndpoint, command, success, "xml"); }; -Rivendell.GroupList = function(rivendell, type) { - this.rivendell = rivendell; - - this.type = type; - - this.groups = []; -}; - -Rivendell.GroupList.prototype.fetch = function(success) { +Rivendell.GroupList.prototype.fetch = function(type, success) { this.groups = []; var self = this; - this.rivendell.listDropboxes(this.type, function(groupsXml, status, req) { + this.rivendell.listDropboxes(type, function(groupsXml, status, req) { var dbs = $('dropboxList', groupsXml).children(); dbs.each(function(index, groupXml) { + var group = null; switch ($('type', groupXml).text()) { - case 'show': + /*case 'show': // todo - break; + break;*/ case 'jingle': - var group = new JingleGroup( - $('jingle-title', groupXml).text(), - $('group', groupXml).text(), - $('group-description', groupXml).text(), - $('group-low-cart', groupXml).text(), - $('group-high-cart', groupXml).text(), - $('normalization-level', groupXml).text(), - $('autotrim-level', groupXml).text() - ); + group = new JingleGroup(groupXml); break; case 'musicpool': - var group = new Musicpool( - $('musicpool-title', groupXml).text(), - $('musicpool-clock', groupXml).text(), - $('group', groupXml).text(), - $('group-description', groupXml).text(), - $('group-low-cart', groupXml).text(), - $('group-high-cart', groupXml).text(), - $('normalization-level', groupXml).text(), - $('autotrim-level', groupXml).text() - ); + group = new Musicpool(groupXml); + break; + default: + group = new Rivendell(groupXml); break; } - self.groups.push(group); + if (group !== null) { + self.groups.push(group); + } }); if (success) { @@ -125,8 +106,40 @@ Rivendell.GroupList.prototype.fetch = function(success) { }); }; -Rivendell.GroupList.prototype.destroy = function() { - $(this.groups).each(function(index, group) { - group.destroy(); +Rivendell.Musicgrid = function() { + this.clocks = []; +}; + +Rivendell.Musicgrid.prototype.fetch = function(success) { + this.clocks = []; + + var self = this; + rivendell.getMusicgrid(function(gridXml, status, req) { + var dbs = $('grid', gridXml).children(); + dbs.each(function(index, clockXml) { + self.clocks.push(new Rivendell.MusicgridClock(clockXml)); + }); + if (success) { + success(); + } }); }; + +Rivendell.MusicgridClock = function(name, color, title, dow, hour) { + this.clockXml = null; + + if (arguments.length === 1) { + this.clockXml = name; + this.name = $('name', this.clockXml).text(); + this.color = $('color', this.clockXml).text(); + this.title = $('title', this.clockXml).text(); + this.dow = $(this.clockXml).attr('dow'); + this.hour = $(this.clockXml).attr('hour'); + } else { + this.name = name; + this.color = color; + this.title = title; + this.dow = dow; + this.hour = hour; + } +}; |