diff --git a/4chan_x.coffee b/4chan_x.coffee
index 7da1eeb57..6950bc5df 100644
--- a/4chan_x.coffee
+++ b/4chan_x.coffee
@@ -2,7 +2,7 @@
#todo: remove stupid 'obj', arr el, make hidden an object, smarter xhr, text(), @this, images, clear hidden
#todo: watch - add board in updateWatcher?, redundant move divs?, redo css / hiding, manual clear
#
-#TODO tampermonkey, use makeDialog
+#TODO tampermonkey
config =
'Thread Hiding': true
@@ -156,16 +156,6 @@ n = (tag, props) -> #new
el.addEventListener event, funk, true
(el[key] = val) for key, val of props
el
-position = (el) ->
- id = el.id
- if left = GM_getValue("#{id}Left", '0px')
- el.style.left = left
- else
- el.style.right = '0px'
- if top = GM_getValue("#{id}Top", '0px')
- el.style.top = top
- else
- el.style.bottom = '0px'
remove = (el) ->
el.parentNode.removeChild(el)
replace = (root, el) ->
@@ -327,12 +317,8 @@ options = ->
if div = $('#options')
remove(div)
else
+ div = AEOS.makeDialog 'options', 'center'
hiddenNum = hiddenReplies.length + hiddenThreads.length
- div = n 'div', {
- id: 'options'
- className: 'reply'
- }
- position(div)
html = '
4chan X
'
div.innerHTML = html
- $('div', div).addEventListener('mousedown', AEOS.move, true)
+ $('div.move', div).addEventListener('mousedown', AEOS.move, true)
$('input[type="button"]', div).addEventListener('click', clearHidden, true)
$('a[name="save"]', div).addEventListener('click', optionsSave, true)
$('a[name="cancel"]', div).addEventListener('click', close, true)
@@ -511,11 +497,7 @@ autohide = ->
quickReply = (e) ->
unless qr = $('#qr')
#make quick reply dialog
- qr = n 'div', {
- id: 'qr'
- className: 'reply'
- }
- position(qr)
+ qr = AEOS.makeDialog 'qr', 'topleft'
div = n 'div', {
innerHTML: 'Quick Reply '
@@ -812,12 +794,8 @@ if getConfig('Quick Report')
if getConfig('Thread Watcher')
#create watcher
- watcher = n 'div', {
- innerHTML: 'Thread Watcher
'
- className: 'reply'
- id: 'watcher'
- }
- position(watcher)
+ watcher = AEOS.makeDialog 'watcher', 'topleft'
+ watcher.innerHTML = 'Thread Watcher
'
$('div', watcher).addEventListener('mousedown', AEOS.move, true)
addTo d.body, watcher
watcherUpdate()
diff --git a/4chan_x.js b/4chan_x.js
index 4ac770f6a..63e1babba 100644
--- a/4chan_x.js
+++ b/4chan_x.js
@@ -1,5 +1,5 @@
(function() {
- var $, $$, AEOS, BOARD, DAY, PAGENUM, REPLY, _i, _j, _len, _len2, _ref, _ref2, a, addTo, arr, as, autoWatch, autohide, b, board, callback, callbacks, clearHidden, close, config, cutoff, d, delform, down, el, expandComment, expandThread, favEmpty, favNormal, favicon, getConfig, getTime, head, hiddenReplies, hiddenThreads, hide, hideReply, hideThread, href, html, i, i1, id, iframe, iframeLoad, iframeLoop, img, inAfter, inBefore, input, inputs, l, l1, lastChecked, magic, n, navtopr, nodeInserted, nop, now, omitted, onloadComment, onloadThread, options, optionsSave, parseResponse, position, quickReply, r, remove, replace, replyNav, report, show, showReply, showThread, slice, span, src, stopPropagation, submit, text, textContent, thread, threadF, threads, tn, up, watch, watchX, watched, watcher, watcherUpdate, x, xhrs;
+ var $, $$, AEOS, BOARD, DAY, PAGENUM, REPLY, _i, _j, _len, _len2, _ref, _ref2, a, addTo, arr, as, autoWatch, autohide, b, board, callback, callbacks, clearHidden, close, config, cutoff, d, delform, down, el, expandComment, expandThread, favEmpty, favNormal, favicon, getConfig, getTime, head, hiddenReplies, hiddenThreads, hide, hideReply, hideThread, href, html, i, i1, id, iframe, iframeLoad, iframeLoop, img, inAfter, inBefore, input, inputs, l, l1, lastChecked, magic, n, navtopr, nodeInserted, nop, now, omitted, onloadComment, onloadThread, options, optionsSave, parseResponse, quickReply, r, remove, replace, replyNav, report, show, showReply, showThread, slice, span, src, stopPropagation, submit, text, textContent, thread, threadF, threads, tn, up, watch, watchX, watched, watcher, watcherUpdate, x, xhrs;
var __slice = Array.prototype.slice, __hasProp = Object.prototype.hasOwnProperty;
config = {
'Thread Hiding': true,
@@ -198,16 +198,6 @@
}
return el;
};
- position = function(el) {
- var id, left, top;
- id = el.id;
- if (left = GM_getValue("" + (id) + "Left", '0px')) {
- el.style.left = left;
- } else {
- el.style.right = '0px';
- }
- return (top = GM_getValue("" + (id) + "Top", '0px')) ? (el.style.top = top) : (el.style.bottom = '0px');
- };
remove = function(el) {
return el.parentNode.removeChild(el);
};
@@ -378,12 +368,8 @@
if (div = $('#options')) {
return remove(div);
} else {
+ div = AEOS.makeDialog('options', 'center');
hiddenNum = hiddenReplies.length + hiddenThreads.length;
- div = n('div', {
- id: 'options',
- className: 'reply'
- });
- position(div);
html = '4chan X
';
div.innerHTML = html;
- $('div', div).addEventListener('mousedown', AEOS.move, true);
+ $('div.move', div).addEventListener('mousedown', AEOS.move, true);
$('input[type="button"]', div).addEventListener('click', clearHidden, true);
$('a[name="save"]', div).addEventListener('click', optionsSave, true);
$('a[name="cancel"]', div).addEventListener('click', close, true);
@@ -576,11 +562,7 @@
quickReply = function(e) {
var _i, _len, _ref2, _ref3, autohideB, clone, closeB, div, form, input, qr, script, selection, text, textarea, xpath;
if (!(qr = $('#qr'))) {
- qr = n('div', {
- id: 'qr',
- className: 'reply'
- });
- position(qr);
+ qr = AEOS.makeDialog('qr', 'topleft');
div = n('div', {
innerHTML: 'Quick Reply ',
className: 'move',
@@ -921,12 +903,8 @@
});
}
if (getConfig('Thread Watcher')) {
- watcher = n('div', {
- innerHTML: 'Thread Watcher
',
- className: 'reply',
- id: 'watcher'
- });
- position(watcher);
+ watcher = AEOS.makeDialog('watcher', 'topleft');
+ watcher.innerHTML = 'Thread Watcher
';
$('div', watcher).addEventListener('mousedown', AEOS.move, true);
addTo(d.body, watcher);
watcherUpdate();