diff --git a/CHANGES.md b/CHANGES.md index ed150d6a..726c33cc 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -77,6 +77,7 @@ * Change to move init-scripts to single folder * Change sickbeard variables to sickgear variables in init-scripts * Change improve the use of multiple plex servers +* Change to move JS code out of home template and into dedicated file [develop changelog] Enable Alpha Ratio again now that the secure login page over https is fixed diff --git a/gui/slick/interfaces/default/home.tmpl b/gui/slick/interfaces/default/home.tmpl index 5eef5a92..d972e551 100644 --- a/gui/slick/interfaces/default/home.tmpl +++ b/gui/slick/interfaces/default/home.tmpl @@ -8,158 +8,26 @@ #set global $sbPath = '..' #set global $topmenu = 'home' #set global $page_body_attr = 'show-list' +#set fuzzydate = 'airdate' ## #import os.path #include $os.path.join($sickbeard.PROG_DIR, 'gui/slick/interfaces/default/inc_top.tmpl') - - -## -#if $varExists('header') - + +

$showlists[0][1]

-#else - -

$title

-#end if #set $tab = 1 #if 'poster' != $layout @@ -324,7 +192,7 @@
#if $cur_airs_next #set $ldatetime = $sbdatetime.sbdatetime.convert_to_setting($network_timezones.parse_date_time($cur_airs_next,$curShow.airs,$curShow.network)) - $sbdatetime.sbdatetime.sbfdate($ldatetime) + $sbdatetime.sbdatetime.sbfdate($ldatetime) #else #set $output_html = '?' #if None is not $display_status @@ -471,7 +339,7 @@ #if $cur_airs_next #set $ldatetime = $sbdatetime.sbdatetime.convert_to_setting($network_timezones.parse_date_time($cur_airs_next,$curShow.airs,$curShow.network)) -
$sbdatetime.sbdatetime.sbfdate($ldatetime)
$ldatetime.strftime('%Y%m%d%H%M') +
$sbdatetime.sbdatetime.sbfdate($ldatetime)
$ldatetime.strftime('%Y%m%d%H%M') #else #end if @@ -550,21 +418,6 @@ #end if #end for ## - + #include $os.path.join($sickbeard.PROG_DIR, 'gui/slick/interfaces/default/inc_bottom.tmpl') \ No newline at end of file diff --git a/gui/slick/js/home.js b/gui/slick/js/home.js new file mode 100644 index 00000000..eb8d4c50 --- /dev/null +++ b/gui/slick/js/home.js @@ -0,0 +1,140 @@ +$.tablesorter.addParser({ + id: 'loadingNames', + is: function (s) { + return false; + }, + format: function (s) { + if (s.indexOf('Loading...') === 0) { + return s.replace('Loading...', '000'); + } else if (config.sortArticle) { + return (s || ''); + } else { + return (s || '').replace(/^(?:(?:A(?!\s+to)n?)|The)\s(\w)/i, '$1'); + } + }, + type: 'text' +}); + +$.tablesorter.addParser({ + id: 'quality', + is: function (s) { + return false; + }, + format: function (s) { + return s.replace('hd1080p', 5).replace('hd720p', 4).replace('hd', 3).replace('sd', 2).replace('any', 1).replace('custom', 7); + }, + type: 'numeric' +}); + +$(document).ready(function () { + if (config.homeSearchFocus) { + $('#search_show_name').focus(); + } + + if (config.fuzzyDating) { + fuzzyMoment({ + dtInline: config.isPoster, + containerClass: config.fuzzydate, + dateHasTime: !1, + dateFormat: config.datePreset, + timeFormat: config.timePreset, + trimZero: config.trimZero + }); + } + + $('div[id^="progressbar"]').each(function (k, v) { + var progress = parseInt($(this).siblings('span[class="sort-data"]').attr('data-progress'), 10), elId = '#' + $(this).attr('id'), v = 80; + $(elId).progressbar({value: progress}); + if (progress < 80) { + v = progress >= 40 ? 60 : (progress >= 20 ? 40 : 20); + } + $(elId + ' > .ui-progressbar-value').addClass('progress-' + v); + }); + + $('img#network').on('error', function () { + $(this).parent().text($(this).attr('alt')); + $(this).remove(); + }); + + if (config.isPoster) { + $('.container').each(function (i, obj) { + $(obj).isotope({ + itemSelector: '.show', + sortBy: config.posterSortby, + sortAscending: config.posterSortdir, + layoutMode: 'masonry', + masonry: { + columnWidth: 12, + isFitWidth: true + }, + getSortData: { + name: function (itemElem) { + var name = $(itemElem).attr('data-name'); + if (config.sortArticle) { + return (name || ''); + } else { + return (name || '').replace(/^(?:(?:A(?!\s+to)n?)|The)\s(\w)/i, '$1'); + } + }, + date: function (itemElem) { + var date = $(itemElem).attr('data-date'); + return date.length && parseInt(date, 10) || Number.POSITIVE_INFINITY; + }, + network: '[data-network]', + progress: function (itemElem) { + var progress = $(itemElem).children('.sort-data').attr('data-progress'); + return progress.length && parseInt(progress, 10) || Number.NEGATIVE_INFINITY; + } + } + }); + + $('#postersort').on('change', function () { + var sortValue = this.value; + $(obj).isotope({sortBy: sortValue}); + $.get(this.options[this.selectedIndex].getAttribute('data-sort')); + }); + + $('#postersortdirection').on('change', function () { + var sortDirection = this.value; + sortDirection = sortDirection == 'true'; + $(obj).isotope({sortAscending: sortDirection}); + $.get(this.options[this.selectedIndex].getAttribute('data-sort')); + }); + }); + } else { + $('.tablesorter').each(function (i, obj) { + $(obj).has('tbody tr').tablesorter({ + sortList: [[5, 1], [1, 0]], + textExtraction: { + 0: function (node) { + return $(node).find('span').text().toLowerCase(); + }, + 2: function (node) { + return $(node).find('span').text().toLowerCase(); + }, + 3: function (node) { + return $(node).find('span').text().toLowerCase(); + }, + 4: function (node) { + return $(node).find('span').attr('data-progress'); + }, + 5: function (node) { + return $(node).find('i').attr('alt'); + } + }, + widgets: ['saveSort', 'zebra', 'stickyHeaders', 'filter'], + headers: { + 0: {sorter: 'isoDate'}, + 1: {sorter: 'loadingNames'}, + 3: {sorter: 'quality'}, + 4: {sorter: 'eps'} + }, + widgetOptions: { + filter_columnFilters: false, + filter_reset: '.resetshows' + }, + sortStable: true + }); + }); + } +}); \ No newline at end of file