Merge pull request #1218 from carboncopy/dice

Dice
This commit is contained in:
Mayhem 2013-08-08 00:57:22 -07:00
commit 23b9459fa4
4 changed files with 23 additions and 0 deletions

View File

@ -1,3 +1,4 @@
- Added dice monitoring on /tg/
- Fix impossibility to create new threads when in dead threads.
### 3.5.7 - *2013-07-13*

View File

@ -13,6 +13,7 @@ Config =
'Index Navigation': [false, 'Add buttons to navigate between threads.']
'Reply Navigation': [false, 'Add buttons to navigate to top / bottom of thread.']
'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':
'Anonymize': [false, 'Make everyone Anonymous.']
'Filter': [true, 'Self-moderation placebo.']

View File

@ -114,6 +114,7 @@ Main =
initFeature 'Thread Watcher', ThreadWatcher
initFeature 'Index Navigation', Nav
initFeature 'Keybinds', Keybinds
initFeature 'Dice Checker', Dice
# c.timeEnd 'All initializations'
$.on d, 'AddCallback', Main.addCallback

View File

@ -0,0 +1,20 @@
Dice =
init: ->
return if g.VIEW is 'catalog' or !Conf['Show Dice Rolled']
# or !Conf['Show dice being rolled']
return if g.BOARD.ID isnt 'tg'
Post::callbacks.push
name: 'Dice roller'
cb: @node
node: ->
return if @isClone
email = @info.email
dicestats = /dice\W(\d+)d(\d+)/.exec(email)
return if not dicestats
roll = ($$("b",@nodes.comment).filter (elem)->elem.innerHTML.lastIndexOf("Rolled", 0) == 0)[0]
return if not roll
rollResults = roll.innerHTML.slice 7
dicestr = dicestats[1]+"d"+dicestats[2]
roll.innerHTML = "Rolled " + dicestr + " and got " + rollResults