From baac2a1bcda3ee45e44ec5ff5873f3c3e3b652c0 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sun, 28 Aug 2011 02:36:13 +0200 Subject: [PATCH] Backlink formatting, close #124 --- 4chan_x.user.js | 12 ++++++++++-- script.coffee | 10 +++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 7a1800295..803539df3 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -113,6 +113,7 @@ }, flavors: ['http://regex.info/exif.cgi?url=', 'http://iqdb.org/?url=', 'http://google.com/searchbyimage?image_url=', '#http://tineye.com/search?url=', '#http://saucenao.com/search.php?db=999&url=', '#http://imgur.com/upload?url=', '#http://anonym.to/?'].join('\n'), time: '%m/%d/%y(%a)%H:%M', + backlink: '>>%id', hotkeys: { close: 'Esc', spoiler: 'ctrl+s', @@ -1075,7 +1076,7 @@ var arr, checked, description, dialog, hiddenNum, hiddenThreads, hidingul, html, input, key, li, main, obj, overlay, ul, _i, _len, _ref, _ref2; hiddenThreads = $.get("hiddenThreads/" + g.BOARD + "/", {}); hiddenNum = Object.keys(g.hiddenReplies).length + Object.keys(hiddenThreads).length; - html = "
| | |

:
Supported format specifiers:
  • Day: %a, %A, %d, %e
  • Month: %m, %b, %B
  • Year: %y, %Y
  • Hour: %k, %H, %l (lowercase L), %I (uppercase i)
  • Month: %M, %p, %P
ActionsKeybinds
Close Options or QR
Quick spoiler
Open QR with post number inserted
Open QR without post number inserted
Submit post
Select next reply
Select previous reply
See next thread
See previous thread
Jump to the next page
Jump to the previous page
Jump to page 0
Open thread in current tab
Open thread in new tab
Expand thread
Watch thread
Hide thread
Expand selected image
Expand all images
Update now
Reset the unread count to 0
"; + html = "
| | |

:
:
Supported format specifiers:
  • Day: %a, %A, %d, %e
  • Month: %m, %b, %B
  • Year: %y, %Y
  • Hour: %k, %H, %l (lowercase L), %I (uppercase i)
  • Month: %M, %p, %P
ActionsKeybinds
Close Options or QR
Quick spoiler
Open QR with post number inserted
Open QR without post number inserted
Submit post
Select next reply
Select previous reply
See next thread
See previous thread
Jump to the next page
Jump to the previous page
Jump to page 0
Open thread in current tab
Open thread in new tab
Expand thread
Watch thread
Hide thread
Expand selected image
Expand all images
Update now
Reset the unread count to 0
"; dialog = $.el('div', { id: 'options', innerHTML: html @@ -1109,6 +1110,7 @@ $.bind($('button', li), 'click', options.clearHidden); $.bind($('#flavors', dialog), 'change', $.cb.value); $.bind($('input[name=time]', dialog), 'keyup', options.time); + $.bind($('input[name=backlink]', dialog), 'keyup', options.backlink); _ref2 = $$('#keybinds input', dialog); for (_i = 0, _len = _ref2.length; _i < _len; _i++) { input = _ref2[_i]; @@ -1127,6 +1129,7 @@ $.append(overlay, dialog); $.append(d.body, overlay); options.time.call($('input[name=time]', dialog)); + options.backlink.call($('input[name=backlink]', dialog)); $.bind(overlay, 'click', function() { return $.rm(overlay); }); @@ -1156,6 +1159,11 @@ Time.foo(); Time.date = new Date(); return $('#timePreview').textContent = Time.funk(Time); + }, + backlink: function(e) { + $.set('backlink', this.value); + conf['backlink'] = this.value; + return $('#backlinkPreview').textContent = conf['backlink'].replace(/%id/, '123456789'); } }; cooldown = { @@ -2135,7 +2143,7 @@ link = $.el('a', { href: "#" + id, className: 'backlink', - textContent: ">>" + id + textContent: conf['backlink'].replace(/%id/, id) }); if (conf['Quote Preview']) { $.bind(link, 'mouseover', quotePreview.mouseover); diff --git a/script.coffee b/script.coffee index db2257eea..7e17b332d 100644 --- a/script.coffee +++ b/script.coffee @@ -53,6 +53,7 @@ config = '#http://anonym.to/?' ].join '\n' time: '%m/%d/%y(%a)%H:%M' + backlink: '>>%id' hotkeys: close: 'Esc' spoiler: 'ctrl+s' @@ -811,6 +812,7 @@ options =
+
:
:
Supported format specifiers:
    @@ -876,6 +878,7 @@ options = $.bind $('#flavors', dialog), 'change', $.cb.value $.bind $('input[name=time]', dialog), 'keyup', options.time + $.bind $('input[name=backlink]', dialog), 'keyup', options.backlink for input in $$ '#keybinds input', dialog input.value = conf[input.name] $.bind input, 'keydown', options.keybind @@ -891,6 +894,7 @@ options = $.append d.body, overlay options.time.call $('input[name=time]', dialog) + options.backlink.call $('input[name=backlink]', dialog) $.bind overlay, 'click', -> $.rm overlay $.bind dialog.firstElementChild, 'click', (e) -> e.stopPropagation() @@ -915,6 +919,10 @@ options = Time.foo() Time.date = new Date() $('#timePreview').textContent = Time.funk Time + backlink: (e) -> + $.set 'backlink', @value + conf['backlink'] = @value + $('#backlinkPreview').textContent = conf['backlink'].replace /%id/, '123456789' cooldown = #TODO merge into qr @@ -1687,7 +1695,7 @@ quoteBacklink = link = $.el 'a', href: "##{id}" className: 'backlink' - textContent: ">>#{id}" + textContent: conf['backlink'].replace /%id/, id if conf['Quote Preview'] $.bind link, 'mouseover', quotePreview.mouseover $.bind link, 'mousemove', ui.hover