ThreadUpdater.disconnect()

This commit is contained in:
Zixaphir 2014-01-07 16:30:18 -07:00
parent 32641549f2
commit 798ab20f35
7 changed files with 252 additions and 131 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -408,6 +408,8 @@ Header =
$.add shortcut, el
$.prepend Header.shortcuts, shortcut
rmShortcut: (el) ->
$.rm el.parentElement
menuToggle: (e) ->
Header.menu.toggle e, @, g

View File

@ -257,71 +257,67 @@ Main =
<%= grunt.file.read('src/General/css/photon.css').replace(/\s+/g, ' ').trim() %>
"""
features:
'Polyfill': Polyfill
'Emoji': Emoji
'Style': Style
'Mascots': MascotTools
'Rice': Rice
'Banner': Banner
'Announcements': GlobalMessage
'Archive Redirection': Redirect
'Header': Header
'Catalog Links': CatalogLinks
'Settings': Settings
'Index Generator': Index
'Announcement Hiding': PSAHiding
'Fourchan thingies': Fourchan
'Color User IDs': IDColor
'Custom CSS': CustomCSS
'Linkify': Linkify
'Reveal Spoilers': RemoveSpoilers
'Resurrect Quotes': Quotify
'Filter': Filter
'Thread Hiding Buttons': ThreadHiding
'Reply Hiding Buttons': PostHiding
'Recursive': Recursive
'Strike-through Quotes': QuoteStrikeThrough
'Quick Reply': QR
'Menu': Menu
'Report Link': ReportLink
'Thread Hiding (Menu)': ThreadHiding.menu
'Reply Hiding (Menu)': PostHiding.menu
'Delete Link': DeleteLink
'Filter (Menu)': Filter.menu
'Download Link': DownloadLink
'Archive Link': ArchiveLink
'Quote Inlining': QuoteInline
'Quote Previewing': QuotePreview
'Quote Backlinks': QuoteBacklink
'Mark Quotes of You': QuoteYou
'Mark OP Quotes': QuoteOP
'Mark Cross-thread Quotes': QuoteCT
'Anonymize': Anonymize
'Time Formatting': Time
'Relative Post Dates': RelativeDates
'File Info Formatting': FileInfo
'Fappe Tyme': FappeTyme
'Gallery': Gallery
'Gallery (menu)': Gallery.menu
'Sauce': Sauce
'Image Expansion': ImageExpand
'Image Expansion (Menu)': ImageExpand.menu
features:
'Polyfill': Polyfill
'Redirect': Redirect
'Header': Header
'Catalog Links': CatalogLinks
'Settings': Settings
'Index Generator': Index
'Announcement Hiding': PSAHiding
'Fourchan thingies': Fourchan
'Emoji': Emoji
'Color User IDs': IDColor
'Custom CSS': CustomCSS
'Linkify': Linkify
'Reveal Spoilers': RemoveSpoilers
'Resurrect Quotes': Quotify
'Filter': Filter
'Thread Hiding Buttons': ThreadHiding
'Reply Hiding Buttons': PostHiding
'Recursive': Recursive
'Strike-through Quotes': QuoteStrikeThrough
'Quick Reply': QR
'Menu': Menu
'Report Link': ReportLink
'Thread Hiding (Menu)': ThreadHiding.menu
'Reply Hiding (Menu)': PostHiding.menu
'Delete Link': DeleteLink
'Filter (Menu)': Filter.menu
'Download Link': DownloadLink
'Archive Link': ArchiveLink
'Quote Inlining': QuoteInline
'Quote Previewing': QuotePreview
'Quote Backlinks': QuoteBacklink
'Mark Quotes of You': QuoteYou
'Mark OP Quotes': QuoteOP
'Mark Cross-thread Quotes': QuoteCT
'Anonymize': Anonymize
'Time Formatting': Time
'Relative Post Dates': RelativeDates
'File Info Formatting': FileInfo
'Fappe Tyme': FappeTyme
'Gallery': Gallery
'Gallery (menu)': Gallery.menu
'Sauce': Sauce
'Image Expansion': ImageExpand
'Image Expansion (Menu)': ImageExpand.menu
'Reveal Spoiler Thumbnails': RevealSpoilers
'Image Loading': ImageLoader
'Image Hover': ImageHover
'Thread Expansion': ExpandThread
'Thread Excerpt': ThreadExcerpt
'Favicon': Favicon
'Unread': Unread
'Quote Threading': QuoteThreading
'Thread Updater': ThreadUpdater
'Thread Stats': ThreadStats
'Thread Watcher': ThreadWatcher
'Thread Watcher (Menu)': ThreadWatcher.menu
'Index Navigation': Nav
'Keybinds': Keybinds
'Show Dice Roll': Dice
'Image Loading': ImageLoader
'Image Hover': ImageHover
'Thread Expansion': ExpandThread
'Thread Excerpt': ThreadExcerpt
'Favicon': Favicon
'Unread': Unread
'Quote Threading': QuoteThreading
'Thread Stats': ThreadStats
'Thread Updater': ThreadUpdater
'Thread Watcher': ThreadWatcher
'Thread Watcher (Menu)': ThreadWatcher.menu
'Index Navigation': Nav
'Keybinds': Keybinds
'Show Dice Roll': Dice
'Banner': Banner
clean: ->
delete g.posts[id] for id of g.posts

View File

@ -24,6 +24,7 @@ UI = do ->
constructor: (@type) ->
# Doc here: https://github.com/MayhemYDG/4chan-x/wiki/Menu-API
$.on d, 'AddMenuEntry', @addEntry
$.on d, 'rmMenuEntry', @rmEntry
@entries = []
makeMenu: ->
@ -189,6 +190,12 @@ UI = do ->
@parseEntry entry
@entries.push entry
rmEntry: (e) =>
entry = e.detail
return if entry.type isnt @type
index = @entries.indexOf entry
@entries.splice index, 1
parseEntry: (entry) ->
{el, subEntries} = entry
$.addClass el, 'entry'

View File

@ -1,7 +1,10 @@
ThreadUpdater =
init: ->
return if g.VIEW isnt 'thread' or !Conf['Thread Updater']
ThreadUpdater.connect.call @
connect: ->
if Conf['Updater and Stats in Header']
@dialog = sc = $.el 'span',
innerHTML: "<span id=update-status></span><span id=update-timer title='Update now'></span>"
@ -22,10 +25,10 @@ ThreadUpdater =
@status = $ '#update-status', sc
@isUpdating = Conf['Auto Update']
$.on @timer, 'click', ThreadUpdater.update
$.on @status, 'click', ThreadUpdater.update
$.on @timer, 'click', @update
$.on @status, 'click', @update
subEntries = []
@subEntries = []
for name, conf of Config.updater.checkbox
checked = if Conf[name] then 'checked' else ''
el = $.el 'label',
@ -34,20 +37,20 @@ ThreadUpdater =
input = el.firstElementChild
$.on input, 'change', $.cb.checked
if input.name is 'Scroll BG'
$.on input, 'change', ThreadUpdater.cb.scrollBG
ThreadUpdater.cb.scrollBG()
$.on input, 'change', @cb.scrollBG
@cb.scrollBG()
else if input.name is 'Auto Update'
$.on input, 'change', ThreadUpdater.cb.update
$.on input, 'change', @cb.update
subEntries.push el: el
settings = $.el 'span',
@settings = $.el 'span',
innerHTML: '<a href=javascript:;>Interval</a>'
$.on settings, 'click', @intervalShortcut
$.on @settings, 'click', @intervalShortcut
subEntries.push el: settings
$.event 'AddMenuEntry',
$.event 'AddMenuEntry', @entry =
type: 'header'
el: $.el 'span',
textContent: 'Updater'
@ -57,6 +60,35 @@ ThreadUpdater =
Thread.callbacks.push
name: 'Thread Updater'
cb: @node
disconnect: ->
if Conf['Updater and Stats in Header']
Header.rmShortcut @dialog
else
$.rmClass doc, 'float'
$.rm @dialog
$.off @timer, 'click', @update
$.off @status, 'click', @update
for entry in @entry.subEntries
{el} = entry
input = el.firstElementChild
$.off input, 'change', $.cb.checked
$.off input, 'change', @cb.scrollBG
$.off input, 'change', @cb.update
$.off @settings, 'click', @intervalShortcut
$.event 'rmMenuEntry', @entry
delete @checkPostCount
delete @timer
delete @status
delete @isUpdating
delete @entry
Thread.callbacks.rm 'Thread Updater'
node: ->
ThreadUpdater.thread = @

View File

@ -2,7 +2,7 @@ Unread =
init: ->
return if g.VIEW isnt 'thread' or !Conf['Unread Count'] and !Conf['Unread Favicon'] and !Conf['Desktop Notifications']
Unread.connect()
Unread.connect.call this
connect: ->
@db = new DataBoard 'lastReadPosts', @sync
@ -21,12 +21,12 @@ Unread =
Unread.db.disconnect()
$.rm hr, parent if parent = (hr = Unread.hr).parentElement
delete Unread[name] for name in ['db', 'hr', 'posts', 'postsQuotingYou', 'thread', 'title', 'lastReadPost']
delete @[name] for name in ['db', 'hr', 'posts', 'postsQuotingYou', 'thread', 'title', 'lastReadPost']
$.off d, '4chanXInitFinished', Unread.ready
$.off d, 'ThreadUpdate', Unread.onUpdate
$.off d, 'scroll visibilitychange', Unread.read
$.off d, 'visibilitychange', Unread.setLine if Conf['Unread Line']
$.off d, '4chanXInitFinished', @ready
$.off d, 'ThreadUpdate', @onUpdate
$.off d, 'scroll visibilitychange', @read
$.off d, 'visibilitychange', @setLine if Conf['Unread Line']
Thread.callbacks.rm 'Unread'