From 52233b8ca0dd227cfdc1dbed9bb7f4d04c5d152f Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sat, 2 Jul 2016 01:57:25 +0200 Subject: fixed sorting for show and musicpool selector diff --git a/www/js/musicpools.js b/www/js/musicpools.js index 0ce1c9c..db295c7 100644 --- a/www/js/musicpools.js +++ b/www/js/musicpools.js @@ -99,7 +99,15 @@ Rdxport.MusicpoolsView.prototype.updateSelector = function() { $('li', $musicpoolSelector).remove(); $(this.model.groups).sort(function(a, b) { - return a.title.toLowerCase() >= b.title.toLowerCase() + var atitle = a.title.toLowerCase(); + var btitle = b.title.toLowerCase(); + if(atitle == btitle) { + if(a.clock > b.clock) return 1; + if(a.clock < b.clock) return -1; + return 0; + } + if(atitle > btitle) return 1; + return -1; }).each(function(index, musicpool) { var name = '' + musicpool.title + ' (' + musicpool.clock + ')'; var link = $('').attr('href', '#').html(name).click(function() { diff --git a/www/js/shows.js b/www/js/shows.js index 81d9e5a..1ec986d 100644 --- a/www/js/shows.js +++ b/www/js/shows.js @@ -99,10 +99,25 @@ Rdxport.ShowListView.prototype.updateSelector = function() { $('li', $showSelector).remove(); $(this.model.groups).sort(function(a, b) { - if(a.title.toLowerCase() == b.title.toLowerCase()) { - return b.rhythm - a.rhythm; + var atitle = a.title.toLowerCase(); + var btitle = b.title.toLowerCase(); + if(atitle == btitle) { + if(b.rhythm == a.rhythm) { + if(a.dayofweek == b.dayofweek) { + if(a.starttime == b.starttime) { + return a.showid - b.showid; + } + if(a.starttime > b.starttime) return 1; + return -1; + } + var adow = a.dayofweek == 0 ? 7 : a.dayofweek; + var bdow = b.dayofweek == 0 ? 7 : b.dayofweek; + return adow - bdow; + } + return parseInt(b.rhythm) - parseInt(a.rhythm); } - return a.title.toLowerCase() >= b.title.toLowerCase() + if(atitle > btitle) return 1; + return -1; }).each(function(index, show) { var name = show.id + ' | ' + show.title + ' (' + show.rhythm + ', ' + weekday[show.dayofweek] + ', ' + show.starttime + ', ' + show.length + ' Min.)'; var link = $('').attr('href', '#').html(name).click(function() { -- cgit v0.10.2