From 2f5cb810292512a5913792ba570afdf2dfe4e05c Mon Sep 17 00:00:00 2001 From: Ruud Date: Tue, 30 Apr 2013 22:28:15 +0200 Subject: [PATCH] Optimize initial requests --- couchpotato/core/_base/updater/static/updater.js | 2 +- .../core/notifications/core/static/notification.js | 6 +--- couchpotato/core/plugins/movie/static/list.js | 37 ++++++++-------------- couchpotato/static/scripts/page/wanted.js | 2 +- couchpotato/templates/index.html | 11 ++++++- 5 files changed, 27 insertions(+), 31 deletions(-) diff --git a/couchpotato/core/_base/updater/static/updater.js b/couchpotato/core/_base/updater/static/updater.js index cc17be5..79fe7b6 100644 --- a/couchpotato/core/_base/updater/static/updater.js +++ b/couchpotato/core/_base/updater/static/updater.js @@ -5,7 +5,7 @@ var UpdaterBase = new Class({ initialize: function(){ var self = this; - App.addEvent('load', self.info.bind(self, 1000)) + App.addEvent('load', self.info.bind(self, 2000)) App.addEvent('unload', function(){ if(self.timer) clearTimeout(self.timer); diff --git a/couchpotato/core/notifications/core/static/notification.js b/couchpotato/core/notifications/core/static/notification.js index 025d81d..3843df1 100644 --- a/couchpotato/core/notifications/core/static/notification.js +++ b/couchpotato/core/notifications/core/static/notification.js @@ -28,14 +28,10 @@ var NotificationBase = new Class({ $(App.block.notification).inject(App.getBlock('search'), 'after'); self.badge = new Element('div.badge').inject(App.block.notification, 'top').hide(); - /* App.getBlock('notification').addLink(new Element('a.more', { - 'href': App.createUrl('notifications'), - 'text': 'Show older notifications' - })); */ }); window.addEvent('load', function(){ - self.startInterval.delay(Browser.safari ? 100 : 0, self) + self.startInterval.delay(2000, self) }); }, diff --git a/couchpotato/core/plugins/movie/static/list.js b/couchpotato/core/plugins/movie/static/list.js index e1cb0d8..0fbd187 100644 --- a/couchpotato/core/plugins/movie/static/list.js +++ b/couchpotato/core/plugins/movie/static/list.js @@ -255,18 +255,19 @@ var MovieList = new Class({ }); // Get available chars and highlight - Api.request('movie.available_chars', { - 'data': Object.merge({ - 'status': self.options.status - }, self.filter), - 'onSuccess': function(json){ - - json.chars.split('').each(function(c){ - self.letters[c.capitalize()].addClass('available') - }) - - } - }); + if(self.navigation.isDisplayed() || self.navigation.isVisible()) + Api.request('movie.available_chars', { + 'data': Object.merge({ + 'status': self.options.status + }, self.filter), + 'onSuccess': function(json){ + + json.chars.split('').each(function(c){ + self.letters[c.capitalize()].addClass('available') + }) + + } + }); // Add menu or hide if (self.options.menu.length > 0) @@ -274,17 +275,7 @@ var MovieList = new Class({ self.navigation_menu.addLink(menu_item); }) else - self.navigation_menu.hide() - - self.nav_scrollspy = new ScrollSpy({ - min: 10, - onEnter: function(){ - self.navigation.addClass('float') - }, - onLeave: function(){ - self.navigation.removeClass('float') - } - }); + self.navigation_menu.hide(); }, diff --git a/couchpotato/static/scripts/page/wanted.js b/couchpotato/static/scripts/page/wanted.js index 6e32997..eabd146 100644 --- a/couchpotato/static/scripts/page/wanted.js +++ b/couchpotato/static/scripts/page/wanted.js @@ -30,7 +30,7 @@ Page.Wanted = new Class({ $(self.wanted).inject(self.el); // Check if search is in progress - self.startProgressInterval(); + self.startProgressInterval.delay(4000, self); } }, diff --git a/couchpotato/templates/index.html b/couchpotato/templates/index.html index 4fcb5c9..36dca09 100644 --- a/couchpotato/templates/index.html +++ b/couchpotato/templates/index.html @@ -3,7 +3,7 @@ - + {% for url in fireEvent('clientscript.get_styles', as_html = True, location = 'front', single = True) %} {% endfor %} {% for url in fireEvent('clientscript.get_scripts', as_html = True, location = 'front', single = True) %} @@ -20,6 +20,15 @@