diff --git a/couchpotato/core/notifications/core/static/notification.js b/couchpotato/core/notifications/core/static/notification.js index db533f20..f4026d48 100644 --- a/couchpotato/core/notifications/core/static/notification.js +++ b/couchpotato/core/notifications/core/static/notification.js @@ -8,7 +8,7 @@ var NotificationBase = new Class({ self.setOptions(options); // Listener - App.addEvent('load', self.request.bind(self)); + App.addEvent('load', self.startInterval.bind(self)); self.addEvent('notification', self.notify.bind(self)) // Add test buttons to settings page @@ -16,15 +16,25 @@ var NotificationBase = new Class({ }, - request: function(){ + startInterval: function(){ var self = this; - Api.request('core_notifier.listener', { + self.request = Api.request('core_notifier.listener', { 'initialDelay': 100, 'delay': 3000, 'onComplete': self.processData.bind(self) - }).startTimer() + }) + self.request.startTimer() + + }, + + startTimer: function(){ + this.request.startTimer() + }, + + stopTimer: function(){ + this.request.stopTimer() }, notify: function(data){ diff --git a/couchpotato/core/plugins/movie/static/search.css b/couchpotato/core/plugins/movie/static/search.css index 053ecaaa..ad2f5b00 100644 --- a/couchpotato/core/plugins/movie/static/search.css +++ b/couchpotato/core/plugins/movie/static/search.css @@ -1,4 +1,4 @@ -/* @override +/* @override http://localhost:5000/static/movie_plugin/search.css http://192.168.1.20:5000/static/movie_plugin/search.css http://127.0.0.1:5000/static/movie_plugin/search.css @@ -8,8 +8,8 @@ display: inline-block; width: 25%; } - - .search_form input { + + .search_form input { padding-right: 25px; padding: 4px; margin: 0; @@ -26,18 +26,18 @@ background: url('../images/checks.png') right -36px no-repeat; cursor: pointer; } - + .search_form .results_container { position: absolute; background: #5c697b; margin: 6px 0 0 -246px; width: 470px; min-height: 140px; - + border-radius: 3px; -webkit-border-radius: 3px; -moz-border-radius: 3px; - + box-shadow: 0 0 50px rgba(0,0,0,0.55); -moz-box-shadow: 0 0 50px rgba(0,0,0,0.55); -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.55); @@ -45,7 +45,7 @@ .search_form .spinner { background: rgba(0,0,0,0.8) url('../images/spinner.gif') no-repeat center 70px; } - + .search_form .pointer { border-right: 10px solid transparent; border-left: 10px solid transparent; @@ -56,19 +56,19 @@ left: 50%; margin: -9px 0 0 110px; } - + .search_form .results { max-height: 550px; overflow-x: hidden; padding: 10px 0; } - - .search_form .results .movie { + + .movie_result { overflow: hidden; min-height: 140px; } - - .search_form .results .movie .options { + + .movie_result .options { height: 139px; border: 1px solid transparent; border-width: 1px 0; @@ -79,38 +79,38 @@ -moz-box-shadow: inset 0 1px 8px rgba(0,0,0,0.25); -webkit-box-shadow: inset 0 1px 8px rgba(0,0,0,0.25); } - - .search_form .results .movie .options > div { + + .movie_result .options > div { padding: 0 15px; border: 0; } - - .search_form .results .movie .options .thumbnail { + + .movie_result .options .thumbnail { vertical-align: middle; } - - .search_form .results .movie .options select { + + .movie_result .options select { vertical-align: middle; display: inline-block; margin-right: 10px; } - .search_form .results .movie .options select[name=title] { width: 180px; } - .search_form .results .movie .options select[name=profile] { width: 90px; } - - .search_form .results .movie .options .button { + .movie_result .options select[name=title] { width: 180px; } + .movie_result .options select[name=profile] { width: 90px; } + + .movie_result .options .button { vertical-align: middle; display: inline-block; } - - .search_form .results .movie .options .message { + + .movie_result .options .message { height: 100%; line-height: 140px; font-size: 20px; text-align: center; color: #fff; } - - .search_form .results .movie .data { + + .movie_result .data { padding: 0 15px; width: 440px; position: relative; @@ -120,19 +120,19 @@ min-height: 140px; background: #5c697b; cursor: pointer; - + border-bottom: 1px solid #333; border-top: 1px solid rgba(255,255,255, 0.15); } - .search_form .results .movie:last-child .data { border-bottom: 0; } - - .search_form .results .movie .thumbnail { + .movie_result:last-child .data { border-bottom: 0; } + + .movie_result .thumbnail { width: 17%; display: inline-block; margin: 15px 3% 15px 0; vertical-align: top; - + border-radius: 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px; @@ -140,32 +140,32 @@ -moz-box-shadow: 0 0 3px rgba(0,0,0,0.35); -webkit-box-shadow: 0 0 3px rgba(0,0,0,0.35); } - - .search_form .results .movie .info { + + .movie_result .info { width: 74%; display: inline-block; vertical-align: top; padding: 15px 0; } - - .search_form .results .movie .info .tagline { + + .movie_result .info .tagline { max-height: 70px; overflow: hidden; display: inline-block; } - .search_form .results .movie .add +.info { + .movie_result .add +.info { margin-left: 20%; } - - .search_form .results .movie .info h2 { + + .movie_result .info h2 { margin: 0; } - - .search_form .results .movie .info h2 span { + + .movie_result .info h2 span { padding: 0 5px; content: ")"; } - - .search_form .results .movie .info h2 span:before { content: "("; } - .search_form .results .movie .info h2 span:after { content: ")"; } + + .movie_result .info h2 span:before { content: "("; } + .movie_result .info h2 span:after { content: ")"; } diff --git a/couchpotato/core/plugins/movie/static/search.js b/couchpotato/core/plugins/movie/static/search.js index b92ee745..8f4dfcc6 100644 --- a/couchpotato/core/plugins/movie/static/search.js +++ b/couchpotato/core/plugins/movie/static/search.js @@ -167,7 +167,7 @@ Block.Search.Item = new Class({ var info = self.info; - self.el = new Element('div.movie', { + self.el = new Element('div.movie_result', { 'id': info.imdb }).adopt( self.options = new Element('div.options.inlay'), diff --git a/couchpotato/core/plugins/userscript/__init__.py b/couchpotato/core/plugins/userscript/__init__.py index 962254ec..5df5a801 100644 --- a/couchpotato/core/plugins/userscript/__init__.py +++ b/couchpotato/core/plugins/userscript/__init__.py @@ -1,6 +1,6 @@ -from .main import Extension +from .main import Userscript def start(): - return Extension() + return Userscript() config = [] diff --git a/couchpotato/core/plugins/userscript/main.py b/couchpotato/core/plugins/userscript/main.py index 7bfec90e..89a9c64f 100644 --- a/couchpotato/core/plugins/userscript/main.py +++ b/couchpotato/core/plugins/userscript/main.py @@ -1,3 +1,4 @@ +from couchpotato import index from couchpotato.api import addApiView from couchpotato.core.event import fireEvent from couchpotato.core.helpers.request import getParam, jsonified @@ -10,12 +11,12 @@ from flask.helpers import url_for log = CPLog(__name__) -class Extension(Plugin): +class Userscript(Plugin): def __init__(self): - addApiView('userscript', self.getExtension) - - addApiView('userscript.add_via_url', self.addViaUrl) + addApiView('userscript.get', self.getExtension) + addApiView('userscript', self.iFrame) + addApiView('userscript.add_via_url', self.getViaUrl) def getExtension(self): @@ -38,9 +39,8 @@ class Extension(Plugin): return version - def addViaUrl(self): - url = getParam('url') - return self.renderTemplate(__file__, 'iframe.html', url = url) + def iFrame(self): + return index() def getViaUrl(self): diff --git a/couchpotato/core/plugins/userscript/static/userscript.css b/couchpotato/core/plugins/userscript/static/userscript.css new file mode 100644 index 00000000..304dfa74 --- /dev/null +++ b/couchpotato/core/plugins/userscript/static/userscript.css @@ -0,0 +1,14 @@ +.page.userscript { + position: absolute; + width: 100%; + top: 0; + bottom: 0; + left: 0; + right: 0; +} + + .page.userscript .frame.loading { + text-align: center; + font-size: 20px; + padding: 20px; + } diff --git a/couchpotato/core/plugins/userscript/static/userscript.js b/couchpotato/core/plugins/userscript/static/userscript.js new file mode 100644 index 00000000..c03016db --- /dev/null +++ b/couchpotato/core/plugins/userscript/static/userscript.js @@ -0,0 +1,46 @@ +Page.Userscript = new Class({ + + Extends: PageBase, + + name: 'userscript', + has_tab: false, + + options: { + 'onOpened': function(){ + App.stopLoadTimer(); + App.getBlock('header').hide(); + } + }, + + indexAction: function(param){ + var self = this; + + self.el.adopt( + self.frame = new Element('div.frame.loading', { + 'text': 'Loading...' + }) + ); + + var url = window.location.href.split('url=')[1]; + + Api.request('userscript.add_via_url', { + 'data': { + 'url': url + }, + 'onComplete': function(json){ + self.frame.empty(); + self.frame.removeClass('loading'); + + if(json.error) + self.frame.set('html', json.error); + else { + var item = new Block.Search.Item(json.movie); + self.frame.adopt(item); + item.showOptions(); + } + } + }); + + } + +}); \ No newline at end of file diff --git a/couchpotato/static/scripts/block.js b/couchpotato/static/scripts/block.js index e77d006f..da816d24 100644 --- a/couchpotato/static/scripts/block.js +++ b/couchpotato/static/scripts/block.js @@ -11,6 +11,7 @@ var BlockBase = new Class({ self.page = parent; self.create(); + }, create: function(){ @@ -20,6 +21,14 @@ var BlockBase = new Class({ getParent: function(){ return this.page }, + + hide: function(){ + this.el.hide(); + }, + + show: function(){ + this.el.show(); + }, toElement: function(){ return this.el @@ -27,4 +36,4 @@ var BlockBase = new Class({ }); -var Block = {} \ No newline at end of file +var Block = BlockBase \ No newline at end of file diff --git a/couchpotato/static/scripts/couchpotato.js b/couchpotato/static/scripts/couchpotato.js index 8899d482..2c5a02c7 100644 --- a/couchpotato/static/scripts/couchpotato.js +++ b/couchpotato/static/scripts/couchpotato.js @@ -31,7 +31,7 @@ var CouchPotato = new Class({ self.c.addEvent('click:relay(a:not([target=_blank]))', self.pushState.bind(self)); }, - + getOption: function(name){ return this.options[name]; }, @@ -48,8 +48,10 @@ var CouchPotato = new Class({ createLayout: function(){ var self = this; + self.block.header = new Block(); + self.c.adopt( - self.header = new Element('div.header').adopt( + $(self.block.header).addClass('header').adopt( new Element('div').adopt( self.block.navigation = new Block.Navigation(self, {}), self.block.search = new Block.Search(self, {}) @@ -70,9 +72,16 @@ var CouchPotato = new Class({ $(pg).inject(self.content); }); - self.fireEvent('load') + self.load_timer = (function(){ + self.fireEvent('load'); + }).delay(1000); }, + + stopLoadTimer: function(){ + if(this.load_timer) + clearInterval(this.load_timer); + }, openPage: function(url) { var self = this; @@ -132,7 +141,8 @@ var Route = new Class({ parse: function(url_string){ var self = this; - var current = History.getPath().replace(/^\/+|\/+$/g, '') + var path = History.getPath().replace(Api.getOption('url'), '/') //Remove API front + var current = path.replace(/^\/+|\/+$/g, '') var url = current.split('/') self.page = (url.length > 0) ? url.shift() : self.defaults.page diff --git a/couchpotato/static/scripts/page.js b/couchpotato/static/scripts/page.js index f178da09..01a2ecc2 100644 --- a/couchpotato/static/scripts/page.js +++ b/couchpotato/static/scripts/page.js @@ -7,6 +7,7 @@ var PageBase = new Class({ }, has_tab: true, + name: '', initialize: function(options) { var self = this; diff --git a/couchpotato/templates/_desktop.html b/couchpotato/templates/_desktop.html index 8ef539c6..463ab18b 100644 --- a/couchpotato/templates/_desktop.html +++ b/couchpotato/templates/_desktop.html @@ -1,45 +1,46 @@ - - - + + + - - + + - - + + - - - - - - - + + + + + + + - - - + + + + - - - + + + {% for url in fireEvent('clientscript.get_scripts', as_html = True, single = True) %} {% endfor %} {% for url in fireEvent('clientscript.get_styles', as_html = True, single = True) %} {% endfor %} - - - - + + + + - - + +