Merge Zixaphir X

This commit is contained in:
Jordan Bates 2013-04-25 06:01:36 -07:00
commit 663dbe3bb2
8 changed files with 287 additions and 175 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -170,6 +170,10 @@ a[href="javascript:;"] {
text-decoration: none; text-decoration: none;
padding: 1px; padding: 1px;
} }
#header-bar input {
margin: 0;
vertical-align: bottom;
}
#shortcuts:empty { #shortcuts:empty {
display: none; display: none;
} }

View File

@ -46,7 +46,7 @@ Header =
type: 'header' type: 'header'
el: $.el 'span', el: $.el 'span',
textContent: 'Header' textContent: 'Header'
order: 105 order: 107
subEntries: [ subEntries: [
{el: barFixedToggler} {el: barFixedToggler}
{el: headerToggler} {el: headerToggler}

View File

@ -1,16 +1,18 @@
ThreadStats = ThreadStats =
init: -> init: ->
return if g.VIEW isnt 'thread' or !Conf['Thread Stats'] return if g.VIEW isnt 'thread' or !Conf['Thread Stats']
@dialog = UI.dialog 'thread-stats', 'bottom: 0; left: 0;', """ @dialog = sc = $.el 'span',
<div class=move><span id=post-count>0</span> / <span id=file-count>0</span></div> innerHTML: "<span id=post-count>0</span> / <span id=file-count>0</span></div>"
"""
@postCountEl = $ '#post-count', @dialog @postCountEl = $ '#post-count', sc
@fileCountEl = $ '#file-count', @dialog @fileCountEl = $ '#file-count', sc
Header.addShortcut sc
Thread::callbacks.push Thread::callbacks.push
name: 'Thread Stats' name: 'Thread Stats'
cb: @node cb: @node
node: -> node: ->
postCount = 0 postCount = 0
fileCount = 0 fileCount = 0
@ -20,11 +22,12 @@ ThreadStats =
ThreadStats.thread = @ ThreadStats.thread = @
ThreadStats.update postCount, fileCount ThreadStats.update postCount, fileCount
$.on d, 'ThreadUpdate', ThreadStats.onUpdate $.on d, 'ThreadUpdate', ThreadStats.onUpdate
$.add d.body, ThreadStats.dialog
onUpdate: (e) -> onUpdate: (e) ->
return if e.detail[404] return if e.detail[404]
{postCount, fileCount} = e.detail {postCount, fileCount} = e.detail
ThreadStats.update postCount, fileCount ThreadStats.update postCount, fileCount
update: (postCount, fileCount) -> update: (postCount, fileCount) ->
{thread, postCountEl, fileCountEl} = ThreadStats {thread, postCountEl, fileCountEl} = ThreadStats
postCountEl.textContent = postCount postCountEl.textContent = postCount

View File

@ -2,24 +2,47 @@ ThreadUpdater =
init: -> init: ->
return if g.VIEW isnt 'thread' or !Conf['Thread Updater'] return if g.VIEW isnt 'thread' or !Conf['Thread Updater']
html = '' checked = if Conf['Auto Update'] then 'checked' else ''
@dialog = sc = $.el 'span',
innerHTML: "
<input name='Auto Update This' type=checkbox #{checked}><span id=update-status></span> <span id=update-timer></span>"
@timer = $ '#update-timer', sc
@status = $ '#update-status', sc
$.on @timer, 'click', ThreadUpdater.update
$.on @status, 'click', ThreadUpdater.update
@checkPostCount = 0
Header.addShortcut sc
subEntries = []
for name, conf of Config.updater.checkbox for name, conf of Config.updater.checkbox
checked = if Conf[name] then 'checked' else '' checked = if Conf[name] then 'checked' else ''
html += "<div><label title='#{conf[1]}'><input name='#{name}' type=checkbox #{checked}> #{name}</label></div>" el = $.el 'label',
title: "#{conf[1]}"
innerHTML: "<input name='#{name}' type=checkbox #{checked}> #{name}"
input = el.firstElementChild
$.on input, 'change', $.cb.checked
if input.name is 'Scroll BG'
$.on input, 'change', ThreadUpdater.cb.scrollBG
ThreadUpdater.cb.scrollBG()
subEntries.push el: el
checked = if Conf['Auto Update'] then 'checked' else '' settings = $.el 'span',
html = """ innerHTML: '<a href=javascript:;>Interval</a>'
<div class=move><span id=update-status></span> <span id=update-timer></span></div>
#{html}
<div><label title='Controls whether *this* thread automatically updates or not'><input type=checkbox name='Auto Update This' #{checked}> Auto Update This</label></div>
<div><label><input type=number name=Interval class=field min=5 value=#{Conf['Interval']}> Refresh rate (s)</label></div>
<div><input value='Update' type=button name='Update'></div>
"""
@dialog = UI.dialog 'updater', 'bottom: 0; right: 0;', html $.on settings, 'click', @intervalShortcut
@timer = $ '#update-timer', @dialog
@status = $ '#update-status', @dialog subEntries.push el: settings
@checkPostCount = 0
$.event 'AddMenuEntry',
type: 'header'
el: $.el 'span',
textContent: 'Updater'
order: 110
subEntries: subEntries
Thread::callbacks.push Thread::callbacks.push
name: 'Thread Updater' name: 'Thread Updater'
@ -32,28 +55,19 @@ ThreadUpdater =
ThreadUpdater.outdateCount = 0 ThreadUpdater.outdateCount = 0
ThreadUpdater.lastModified = '0' ThreadUpdater.lastModified = '0'
for input in $$ 'input', ThreadUpdater.dialog ThreadUpdater.cb.interval.call $.el 'input', value: Conf['Interval']
if input.type is 'checkbox'
$.on input, 'change', $.cb.checked input = $ 'input', ThreadUpdater.dialog
switch input.name
when 'Scroll BG' $.on input, 'change', $.cb.checked
$.on input, 'change', ThreadUpdater.cb.scrollBG $.on input, 'change', ThreadUpdater.cb.autoUpdate
ThreadUpdater.cb.scrollBG() $.event 'change', null, input
when 'Auto Update This'
$.on input, 'change', ThreadUpdater.cb.autoUpdate
$.event 'change', null, input
when 'Interval'
$.on input, 'change', ThreadUpdater.cb.interval
ThreadUpdater.cb.interval.call input
when 'Update'
$.on input, 'click', ThreadUpdater.update
$.on window, 'online offline', ThreadUpdater.cb.online $.on window, 'online offline', ThreadUpdater.cb.online
$.on d, 'QRPostSuccessful', ThreadUpdater.cb.post $.on d, 'QRPostSuccessful', ThreadUpdater.cb.post
$.on d, 'visibilitychange', ThreadUpdater.cb.visibility $.on d, 'visibilitychange', ThreadUpdater.cb.visibility
ThreadUpdater.cb.online() ThreadUpdater.cb.online()
$.add d.body, ThreadUpdater.dialog
### ###
http://freesound.org/people/pierrecartoons1979/sounds/90112/ http://freesound.org/people/pierrecartoons1979/sounds/90112/
@ -151,6 +165,11 @@ ThreadUpdater =
else else
i i
intervalShortcut: ->
Settings.open 'Advanced'
settings = $.id 'fourchanx-settings'
$('input[name=Interval]', settings).focus()
set: (name, text, klass) -> set: (name, text, klass) ->
el = ThreadUpdater[name] el = ThreadUpdater[name]
if node = el.firstChild if node = el.firstChild

View File

@ -459,6 +459,13 @@ Settings =
</div> </div>
</fieldset> </fieldset>
<fieldset>
<legend>Thread Updater <span class=warning #{if Conf['Thread Updater'] then 'hidden' else ''}>is disabled.</span></legend>
<div>
Intervale: <input name=Interval value=#{Conf['Interval']}
</div>
</fieldset>
<fieldset> <fieldset>
<legend> <legend>
<label><input type=checkbox name='Custom CSS' #{if Conf['Custom CSS'] then 'checked' else ''}> Custom CSS</label> <label><input type=checkbox name='Custom CSS' #{if Conf['Custom CSS'] then 'checked' else ''}> Custom CSS</label>
@ -469,7 +476,7 @@ Settings =
""" """
items = {} items = {}
inputs = {} inputs = {}
for name in ['boardnav', 'time', 'backlink', 'fileInfo', 'favicon', 'sageEmoji', 'emojiPos', 'usercss'] for name in ['boardnav', 'time', 'backlink', 'fileInfo', 'favicon', 'sageEmoji', 'emojiPos', 'usercss', 'Interval']
input = $ "[name=#{name}]", section input = $ "[name=#{name}]", section
items[name] = Conf[name] items[name] = Conf[name]
inputs[name] = input inputs[name] = input
@ -497,11 +504,12 @@ Settings =
for key, val of items for key, val of items
input = inputs[key] input = inputs[key]
input.value = val input.value = val
unless ['usercss', 'emojiPos', 'archiver'].contains name unless ['usercss', 'emojiPos', 'archiver', 'Interval'].contains key
$.on input, event, Settings[key] $.on input, event, Settings[key]
Settings[key].call input Settings[key].call input
return return
$.on $('input[name=Interval]', section), 'input', ThreadUpdater.cb.interval
$.on $('input[name="Custom CSS"]', section), 'change', Settings.togglecss $.on $('input[name="Custom CSS"]', section), 'change', Settings.togglecss
$.on $.id('apply-css'), 'click', Settings.usercss $.on $.id('apply-css'), 'click', Settings.usercss
boardnav: -> boardnav: ->