From 1451c8691b39e039dda449d32df6664e6c798edd Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Fri, 9 Aug 2013 00:05:39 -0700 Subject: [PATCH] Banner.cb.toggle() Because sometimes you get that one banner you don't want. --- LICENSE | 2 +- builds/appchan-x.user.js | 15 ++++++++++++++- builds/crx/script.js | 15 ++++++++++++++- src/Theming/Banner.coffee | 11 +++++++++++ 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/LICENSE b/LICENSE index 4a6afc0ea..e27bc20e2 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ /* -* appchan x - Version 2.2.2 - 2013-08-08 +* appchan x - Version 2.2.2 - 2013-08-09 * * Licensed under the MIT license. * https://github.com/zixaphir/appchan-x/blob/master/LICENSE diff --git a/builds/appchan-x.user.js b/builds/appchan-x.user.js index 130cd9419..6e6a1efa8 100644 --- a/builds/appchan-x.user.js +++ b/builds/appchan-x.user.js @@ -18,7 +18,7 @@ // ==/UserScript== /* -* appchan x - Version 2.2.2 - 2013-08-08 +* appchan x - Version 2.2.2 - 2013-08-09 * * Licensed under the MIT license. * https://github.com/zixaphir/appchan-x/blob/master/LICENSE @@ -10629,6 +10629,7 @@ child = children[i]; if (child.tagName.toLowerCase() === "img") { child.id = "Banner"; + $.on(child, 'click', Banner.cb.toggle); continue; } if (Conf['Custom Board Titles']) { @@ -10639,7 +10640,19 @@ $.add(title, nodes.reverse()); $.after(banner, title); }, + types: { + jpg: 227, + png: 270, + gif: 253 + }, cb: { + toggle: function() { + var num, type; + + type = ['jpg', 'png', 'gif'][Math.floor(3 * Math.random())]; + num = Math.floor(Banner.types[type] * Math.random()); + return this.src = "//static.4chan.org/image/title/" + num + "." + type; + }, click: function(e) { if (e.shiftKey) { return this.contentEditable = true; diff --git a/builds/crx/script.js b/builds/crx/script.js index 9cdbac594..c3e2b3c5c 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1,6 +1,6 @@ // Generated by CoffeeScript /* -* appchan x - Version 2.2.2 - 2013-08-08 +* appchan x - Version 2.2.2 - 2013-08-09 * * Licensed under the MIT license. * https://github.com/zixaphir/appchan-x/blob/master/LICENSE @@ -10617,6 +10617,7 @@ child = children[i]; if (child.tagName.toLowerCase() === "img") { child.id = "Banner"; + $.on(child, 'click', Banner.cb.toggle); continue; } if (Conf['Custom Board Titles']) { @@ -10627,7 +10628,19 @@ $.add(title, nodes.reverse()); $.after(banner, title); }, + types: { + jpg: 227, + png: 270, + gif: 253 + }, cb: { + toggle: function() { + var num, type; + + type = ['jpg', 'png', 'gif'][Math.floor(3 * Math.random())]; + num = Math.floor(Banner.types[type] * Math.random()); + return this.src = "//static.4chan.org/image/title/" + num + "." + type; + }, click: function(e) { if (e.shiftKey) { return this.contentEditable = true; diff --git a/src/Theming/Banner.coffee b/src/Theming/Banner.coffee index 51bce680d..a524b4be8 100644 --- a/src/Theming/Banner.coffee +++ b/src/Theming/Banner.coffee @@ -14,6 +14,7 @@ Banner = child = children[i] if child.tagName.toLowerCase() is "img" child.id = "Banner" + $.on child, 'click', Banner.cb.toggle continue if Conf['Custom Board Titles'] @@ -25,7 +26,17 @@ Banner = $.after banner, title return + types: + jpg: 227 + png: 270 + gif: 253 + cb: + toggle: -> + type = ['jpg', 'png', 'gif'][Math.floor 3 * Math.random()] + num = Math.floor Banner.types[type] * Math.random() + @src = "//static.4chan.org/image/title/#{num}.#{type}" + click: (e) -> if e.shiftKey @contentEditable = true