From 2cbf3d909d251755924f43dcea4a44a580fc9f26 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Thu, 8 Aug 2013 17:24:46 +0200 Subject: [PATCH] Tweak dice code further. #1218 Also use `data` instead of `textContent` as it performs faster. --- src/Miscellaneous/Dice.coffee | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Miscellaneous/Dice.coffee b/src/Miscellaneous/Dice.coffee index 67559eca4..93bdb06cd 100644 --- a/src/Miscellaneous/Dice.coffee +++ b/src/Miscellaneous/Dice.coffee @@ -5,12 +5,7 @@ Dice = name: 'Show Dice Roll' cb: @node node: -> - return if @isClone or not dicestats = @info.email?.match /dice\+(\d+)d(\d+)/ + return if @isClone or not dicestats = @info.email?.match /dice[+\s](\d+)d(\d+)/ # Use the text node directly, as the has two
. roll = $('b', @nodes.comment).firstChild - # Stop here if it looks like this: - # Rolled 44 - # and not this: - # Rolled 9, 8, 10, 3, 5 = 35 - return unless rollResults = roll.textContent.match /^Rolled (\d+)$/ - roll.textContent = "Rolled #{dicestats[1]}d#{dicestats[2]} and got #{rollResults[1]}" + roll.data = "Rolled #{dicestats[1]}d#{dicestats[2]} and got #{roll.data.slice 7}"