From 4291e2233d8f9918805dc42469489ad3d630eccb Mon Sep 17 00:00:00 2001 From: Ruud Date: Sun, 13 Jul 2014 12:23:27 +0200 Subject: [PATCH] Releader class --- couchpotato/static/scripts/reloader.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 couchpotato/static/scripts/reloader.js diff --git a/couchpotato/static/scripts/reloader.js b/couchpotato/static/scripts/reloader.js new file mode 100644 index 00000000..3a4eec8c --- /dev/null +++ b/couchpotato/static/scripts/reloader.js @@ -0,0 +1,24 @@ +var ReloaderBase = new Class({ + + initialize: function(){ + var self = this; + + App.on('watcher.changed', self.reloadFile.bind(self)) + + }, + + reloadFile: function(data){ + var self = this, + urls = data.data; + + urls.each(function(url){ + var without_timestamp = url.split('?')[0], + old_links = document.getElement('[data-url^=\''+without_timestamp+'\']'); + + old_links.set('href', old_links.get('href') + 1) + }) + } + +}); + +var Reloader = new ReloaderBase();