diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9c58313d5..fd44b65c2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,6 @@
seaweedchan:
- Disable settings removing scroll bar when opened, thus fixing the issue where it jumps up the page randomly
+- Hide watcher by default, add [Watcher] shortcut.
### 1.1.12 - 2013-05-06
detharonil
diff --git a/builds/4chan-X.js b/builds/4chan-X.js
index d2967ab0e..b6615fb62 100644
--- a/builds/4chan-X.js
+++ b/builds/4chan-X.js
@@ -6731,7 +6731,9 @@
innerHTML: "0 / 0",
id: 'thread-stats'
});
- Header.addShortcut(sc);
+ $.ready(function() {
+ return Header.addShortcut(sc);
+ });
} else {
this.dialog = sc = UI.dialog('thread-stats', 'bottom: 0px; right: 0px;', "
0 / 0
");
$.ready(function() {
@@ -6796,7 +6798,9 @@
innerHTML: "",
id: 'updater'
});
- Header.addShortcut(sc);
+ $.ready(function() {
+ return Header.addShortcut(sc);
+ });
} else {
this.dialog = sc = UI.dialog('updater', 'bottom: 0px; left: 0px;', "");
$.addClass(doc, 'float');
@@ -7190,13 +7194,28 @@
ThreadWatcher = {
init: function() {
+ var sc,
+ _this = this;
+
if (!Conf['Thread Watcher']) {
return;
}
+ this.sc = sc = $.el('a', {
+ textContent: 'Watcher',
+ id: 'watcher-link',
+ href: 'javascript:;',
+ className: 'disabled'
+ });
this.dialog = UI.dialog('watcher', 'top: 50px; left: 0px;', 'Thread Watcher
');
$.on(d, 'QRPostSuccessful', this.cb.post);
- $.on(d, '4chanXInitFinished', this.ready);
$.sync('WatchedThreads', this.refresh);
+ $.on(sc, 'click', this.toggleWatcher);
+ Header.addShortcut(sc);
+ $.ready(function() {
+ ThreadWatcher.refresh();
+ $.add(d.body, ThreadWatcher.dialog);
+ return ThreadWatcher.dialog.hidden = true;
+ });
return Thread.prototype.callbacks.push({
name: 'Thread Watcher',
cb: this.node
@@ -7222,14 +7241,6 @@
return $["delete"]('AutoWatch');
});
},
- ready: function() {
- $.off(d, '4chanXInitFinished', ThreadWatcher.ready);
- if (!Main.isThisPageLegit()) {
- return;
- }
- ThreadWatcher.refresh();
- return $.add(d.body, ThreadWatcher.dialog);
- },
refresh: function(watched) {
var ID, board, div, favicon, id, link, nodes, props, thread, x, _ref, _ref1;
@@ -7267,6 +7278,14 @@
favicon.src = ID in watched ? Favicon["default"] : Favicon.empty;
}
},
+ toggleWatcher: function() {
+ $.toggleClass(ThreadWatcher.sc, 'disabled');
+ if (ThreadWatcher.dialog.hidden) {
+ return ThreadWatcher.dialog.hidden = false;
+ } else {
+ return ThreadWatcher.dialog.hidden = true;
+ }
+ },
cb: {
toggle: function() {
return ThreadWatcher.toggle(Get.postFromNode(this).thread);
diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js
index e2548f6b5..87d6c20a4 100644
--- a/builds/4chan-X.user.js
+++ b/builds/4chan-X.user.js
@@ -6752,7 +6752,9 @@
innerHTML: "0 / 0",
id: 'thread-stats'
});
- Header.addShortcut(sc);
+ $.ready(function() {
+ return Header.addShortcut(sc);
+ });
} else {
this.dialog = sc = UI.dialog('thread-stats', 'bottom: 0px; right: 0px;', "0 / 0
");
$.ready(function() {
@@ -6817,7 +6819,9 @@
innerHTML: "",
id: 'updater'
});
- Header.addShortcut(sc);
+ $.ready(function() {
+ return Header.addShortcut(sc);
+ });
} else {
this.dialog = sc = UI.dialog('updater', 'bottom: 0px; left: 0px;', "");
$.addClass(doc, 'float');
@@ -7211,13 +7215,28 @@
ThreadWatcher = {
init: function() {
+ var sc,
+ _this = this;
+
if (!Conf['Thread Watcher']) {
return;
}
+ this.sc = sc = $.el('a', {
+ textContent: 'Watcher',
+ id: 'watcher-link',
+ href: 'javascript:;',
+ className: 'disabled'
+ });
this.dialog = UI.dialog('watcher', 'top: 50px; left: 0px;', 'Thread Watcher
');
$.on(d, 'QRPostSuccessful', this.cb.post);
- $.on(d, '4chanXInitFinished', this.ready);
$.sync('WatchedThreads', this.refresh);
+ $.on(sc, 'click', this.toggleWatcher);
+ Header.addShortcut(sc);
+ $.ready(function() {
+ ThreadWatcher.refresh();
+ $.add(d.body, ThreadWatcher.dialog);
+ return ThreadWatcher.dialog.hidden = true;
+ });
return Thread.prototype.callbacks.push({
name: 'Thread Watcher',
cb: this.node
@@ -7243,14 +7262,6 @@
return $["delete"]('AutoWatch');
});
},
- ready: function() {
- $.off(d, '4chanXInitFinished', ThreadWatcher.ready);
- if (!Main.isThisPageLegit()) {
- return;
- }
- ThreadWatcher.refresh();
- return $.add(d.body, ThreadWatcher.dialog);
- },
refresh: function(watched) {
var ID, board, div, favicon, id, link, nodes, props, thread, x, _ref, _ref1;
@@ -7288,6 +7299,14 @@
favicon.src = ID in watched ? Favicon["default"] : Favicon.empty;
}
},
+ toggleWatcher: function() {
+ $.toggleClass(ThreadWatcher.sc, 'disabled');
+ if (ThreadWatcher.dialog.hidden) {
+ return ThreadWatcher.dialog.hidden = false;
+ } else {
+ return ThreadWatcher.dialog.hidden = true;
+ }
+ },
cb: {
toggle: function() {
return ThreadWatcher.toggle(Get.postFromNode(this).thread);
diff --git a/builds/crx/script.js b/builds/crx/script.js
index 9feb8c5fd..8612aa281 100644
--- a/builds/crx/script.js
+++ b/builds/crx/script.js
@@ -6731,7 +6731,9 @@
innerHTML: "0 / 0",
id: 'thread-stats'
});
- Header.addShortcut(sc);
+ $.ready(function() {
+ return Header.addShortcut(sc);
+ });
} else {
this.dialog = sc = UI.dialog('thread-stats', 'bottom: 0px; right: 0px;', "0 / 0
");
$.ready(function() {
@@ -6796,7 +6798,9 @@
innerHTML: "",
id: 'updater'
});
- Header.addShortcut(sc);
+ $.ready(function() {
+ return Header.addShortcut(sc);
+ });
} else {
this.dialog = sc = UI.dialog('updater', 'bottom: 0px; left: 0px;', "");
$.addClass(doc, 'float');
@@ -7190,13 +7194,28 @@
ThreadWatcher = {
init: function() {
+ var sc,
+ _this = this;
+
if (!Conf['Thread Watcher']) {
return;
}
+ this.sc = sc = $.el('a', {
+ textContent: 'Watcher',
+ id: 'watcher-link',
+ href: 'javascript:;',
+ className: 'disabled'
+ });
this.dialog = UI.dialog('watcher', 'top: 50px; left: 0px;', 'Thread Watcher
');
$.on(d, 'QRPostSuccessful', this.cb.post);
- $.on(d, '4chanXInitFinished', this.ready);
$.sync('WatchedThreads', this.refresh);
+ $.on(sc, 'click', this.toggleWatcher);
+ Header.addShortcut(sc);
+ $.ready(function() {
+ ThreadWatcher.refresh();
+ $.add(d.body, ThreadWatcher.dialog);
+ return ThreadWatcher.dialog.hidden = true;
+ });
return Thread.prototype.callbacks.push({
name: 'Thread Watcher',
cb: this.node
@@ -7222,14 +7241,6 @@
return $["delete"]('AutoWatch');
});
},
- ready: function() {
- $.off(d, '4chanXInitFinished', ThreadWatcher.ready);
- if (!Main.isThisPageLegit()) {
- return;
- }
- ThreadWatcher.refresh();
- return $.add(d.body, ThreadWatcher.dialog);
- },
refresh: function(watched) {
var ID, board, div, favicon, id, link, nodes, props, thread, x, _ref, _ref1;
@@ -7267,6 +7278,14 @@
favicon.src = ID in watched ? Favicon["default"] : Favicon.empty;
}
},
+ toggleWatcher: function() {
+ $.toggleClass(ThreadWatcher.sc, 'disabled');
+ if (ThreadWatcher.dialog.hidden) {
+ return ThreadWatcher.dialog.hidden = false;
+ } else {
+ return ThreadWatcher.dialog.hidden = true;
+ }
+ },
cb: {
toggle: function() {
return ThreadWatcher.toggle(Get.postFromNode(this).thread);
diff --git a/src/Monitoring/ThreadStats.coffee b/src/Monitoring/ThreadStats.coffee
index f99c53672..25ede304f 100644
--- a/src/Monitoring/ThreadStats.coffee
+++ b/src/Monitoring/ThreadStats.coffee
@@ -6,7 +6,8 @@ ThreadStats =
@dialog = sc = $.el 'span',
innerHTML: "0 / 0"
id: 'thread-stats'
- Header.addShortcut sc
+ $.ready =>
+ Header.addShortcut sc
else
@dialog = sc = UI.dialog 'thread-stats', 'bottom: 0px; right: 0px;',
"0 / 0
"
diff --git a/src/Monitoring/ThreadUpdater.coffee b/src/Monitoring/ThreadUpdater.coffee
index 6ed6b005b..d68cc09a1 100644
--- a/src/Monitoring/ThreadUpdater.coffee
+++ b/src/Monitoring/ThreadUpdater.coffee
@@ -8,7 +8,8 @@ ThreadUpdater =
@dialog = sc = $.el 'span',
innerHTML: ""
id: 'updater'
- Header.addShortcut sc
+ $.ready =>
+ Header.addShortcut sc
else
@dialog = sc = UI.dialog 'updater', 'bottom: 0px; left: 0px;',
""
diff --git a/src/Monitoring/ThreadWatcher.coffee b/src/Monitoring/ThreadWatcher.coffee
index 9a9e38e5a..310254bf9 100644
--- a/src/Monitoring/ThreadWatcher.coffee
+++ b/src/Monitoring/ThreadWatcher.coffee
@@ -1,12 +1,25 @@
ThreadWatcher =
init: ->
return unless Conf['Thread Watcher']
+ @sc = sc = $.el 'a',
+ textContent: 'Watcher'
+ id: 'watcher-link'
+ href: 'javascript:;'
+ className: 'disabled'
+
@dialog = UI.dialog 'watcher', 'top: 50px; left: 0px;',
'Thread Watcher
'
$.on d, 'QRPostSuccessful', @cb.post
- $.on d, '4chanXInitFinished', @ready
$.sync 'WatchedThreads', @refresh
+ $.on sc, 'click', @toggleWatcher
+
+
+ Header.addShortcut sc
+ $.ready =>
+ ThreadWatcher.refresh()
+ $.add d.body, ThreadWatcher.dialog
+ ThreadWatcher.dialog.hidden = true
Thread::callbacks.push
name: 'Thread Watcher'
@@ -23,18 +36,12 @@ ThreadWatcher =
ThreadWatcher.watch @
$.delete 'AutoWatch'
- ready: ->
- $.off d, '4chanXInitFinished', ThreadWatcher.ready
- return unless Main.isThisPageLegit()
- ThreadWatcher.refresh()
- $.add d.body, ThreadWatcher.dialog
-
refresh: (watched) ->
unless watched
$.get 'WatchedThreads', {}, (item) ->
ThreadWatcher.refresh item['WatchedThreads']
return
- nodes = [$('.move', ThreadWatcher.dialog)]
+ nodes = [$('.move', ThreadWatcher.dialog)]
for board of watched
for id, props of watched[board]
x = $.el 'a',
@@ -48,7 +55,7 @@ ThreadWatcher =
div = $.el 'div'
$.add div, [x, $.tn(' '), link]
nodes.push div
-
+
$.rmAll ThreadWatcher.dialog
$.add ThreadWatcher.dialog, nodes
@@ -61,6 +68,13 @@ ThreadWatcher =
Favicon.empty
return
+ toggleWatcher: ->
+ $.toggleClass ThreadWatcher.sc, 'disabled'
+ if ThreadWatcher.dialog.hidden
+ ThreadWatcher.dialog.hidden = false
+ else
+ ThreadWatcher.dialog.hidden = true
+
cb:
toggle: ->
ThreadWatcher.toggle Get.postFromNode(@).thread