Tweak Dice code. #1218
This commit is contained in:
parent
23b9459fa4
commit
8c95fe1995
@ -1,4 +1,5 @@
|
|||||||
- Added dice monitoring on /tg/
|
- **New feature**: `Show Dice Roll`
|
||||||
|
- Shows dice that were entered into the email field on /tg/.
|
||||||
- Fix impossibility to create new threads when in dead threads.
|
- Fix impossibility to create new threads when in dead threads.
|
||||||
|
|
||||||
### 3.5.7 - *2013-07-13*
|
### 3.5.7 - *2013-07-13*
|
||||||
|
|||||||
@ -12,8 +12,8 @@ Config =
|
|||||||
'Thread Expansion': [true, 'Add buttons to expand threads.']
|
'Thread Expansion': [true, 'Add buttons to expand threads.']
|
||||||
'Index Navigation': [false, 'Add buttons to navigate between threads.']
|
'Index Navigation': [false, 'Add buttons to navigate between threads.']
|
||||||
'Reply Navigation': [false, 'Add buttons to navigate to top / bottom of thread.']
|
'Reply Navigation': [false, 'Add buttons to navigate to top / bottom of thread.']
|
||||||
|
'Show Dice Roll': [true, 'Show dice that were entered into the email field.']
|
||||||
'Check for Updates': [true, 'Notify when updated versions of <%= meta.name %> are available.']
|
'Check for Updates': [true, 'Notify when updated versions of <%= meta.name %> are available.']
|
||||||
'Show Dice Rolled': [true, 'Show dice that were entered into the email field.']
|
|
||||||
'Filtering':
|
'Filtering':
|
||||||
'Anonymize': [false, 'Make everyone Anonymous.']
|
'Anonymize': [false, 'Make everyone Anonymous.']
|
||||||
'Filter': [true, 'Self-moderation placebo.']
|
'Filter': [true, 'Self-moderation placebo.']
|
||||||
|
|||||||
@ -114,7 +114,7 @@ Main =
|
|||||||
initFeature 'Thread Watcher', ThreadWatcher
|
initFeature 'Thread Watcher', ThreadWatcher
|
||||||
initFeature 'Index Navigation', Nav
|
initFeature 'Index Navigation', Nav
|
||||||
initFeature 'Keybinds', Keybinds
|
initFeature 'Keybinds', Keybinds
|
||||||
initFeature 'Dice Checker', Dice
|
initFeature 'Show Dice Roll', Dice
|
||||||
# c.timeEnd 'All initializations'
|
# c.timeEnd 'All initializations'
|
||||||
|
|
||||||
$.on d, 'AddCallback', Main.addCallback
|
$.on d, 'AddCallback', Main.addCallback
|
||||||
|
|||||||
@ -1,20 +1,16 @@
|
|||||||
Dice =
|
Dice =
|
||||||
init: ->
|
init: ->
|
||||||
return if g.VIEW is 'catalog' or !Conf['Show Dice Rolled']
|
return if g.BOARD.ID isnt 'tg' or g.VIEW is 'catalog' or !Conf['Show Dice Roll']
|
||||||
# or !Conf['Show dice being rolled']
|
|
||||||
return if g.BOARD.ID isnt 'tg'
|
|
||||||
Post::callbacks.push
|
Post::callbacks.push
|
||||||
name: 'Dice roller'
|
name: 'Show Dice Roll'
|
||||||
cb: @node
|
cb: @node
|
||||||
node: ->
|
node: ->
|
||||||
return if @isClone
|
return if @isClone or not dicestats = @info.email?.match /dice\+(\d+)d(\d+)/
|
||||||
email = @info.email
|
# Use the text node directly, as the <b> has two <br>.
|
||||||
dicestats = /dice\W(\d+)d(\d+)/.exec(email)
|
roll = $('b', @nodes.comment).firstChild
|
||||||
return if not dicestats
|
# Stop here if it looks like this:
|
||||||
roll = ($$("b",@nodes.comment).filter (elem)->elem.innerHTML.lastIndexOf("Rolled", 0) == 0)[0]
|
# Rolled 44
|
||||||
return if not roll
|
# and not this:
|
||||||
rollResults = roll.innerHTML.slice 7
|
# Rolled 9, 8, 10, 3, 5 = 35
|
||||||
dicestr = dicestats[1]+"d"+dicestats[2]
|
return unless rollResults = roll.textContent.match /^Rolled (\d+)$/
|
||||||
roll.innerHTML = "Rolled " + dicestr + " and got " + rollResults
|
roll.textContent = "Rolled #{dicestats[1]}d#{dicestats[2]} and got #{rollResults[1]}"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user