diff options
author | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2011-03-15 02:22:40 +0100 |
---|---|---|
committer | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2011-03-15 02:22:40 +0100 |
commit | 2e4f9782e13b613b1a2a7e525ba57e6f7062317d (patch) | |
tree | 776269d956831c25a4bddf4e014173ec325283b8 /static-files/js | |
parent | bf95e292f148f5c42bf834a64e42bf04154403bf (diff) |
Fix Hashcash support.
Diffstat (limited to 'static-files/js')
-rw-r--r-- | static-files/js/comment-submission.js | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/static-files/js/comment-submission.js b/static-files/js/comment-submission.js index 13c3849..59db100 100644 --- a/static-files/js/comment-submission.js +++ b/static-files/js/comment-submission.js @@ -13,28 +13,32 @@ jQuery(function($) { var form_augmented_p = false; $('.comment-form').submit(function() { var form = $(this); - $.ajax({ - url: "/RPC/generate-transaction-key", - dataType: 'json', - success: function(tkey) { - if (!form_augmented_p) { + if (!form_augmented_p) { + $.ajax({ + url: "/RPC/generate-transaction-key", + dataType: 'json', + success: function(tkey) { form.find(':submit').attr("disabled", true); var salt = 0; - var text = form.find('textarea'); + var text = form.find('textarea').val().replace(/\s+/g, ""); while (!acceptable_cashhash(Sha256.hash(text + ":" + tkey + ":" + salt))) { salt++; } form.prepend('<input type="hidden" name="transaction-key" value="' + tkey + '" />'); form.prepend('<input type="hidden" name="salt" value="' + salt + '" />'); form_augmented_p = true; + form.find(':submit').removeAttr("disabled"); + $('.comment-form').submit(); form.submit(); - return false; - } else { - return true; + console.log("tkey = " + tkey); + console.log("salt = " + salt); + console.log("Submitted!"); } - } - }); - return false; + }); + return false; + } else { + return true; + } }); $('.spam-detection-method').text("Hashcash"); $('.irrelevant-for-hashcash').text(''); |