There's a fair amount of duplication in mollom.js, I wanted to see if I could simplify things down. Patch to follow.

Comments

dave reid’s picture

Title: Simplify the JS code » Simplify the JS and captcha-fetching code

So we're also duplicating fetching captchas three different times too. That can and should be reduced down to one function.

dave reid’s picture

Status: Active » Needs review
StatusFileSize
new13.91 KB
dave reid’s picture

Summary of the patch:
1. Combines the JS function getAudioCaptcha() and getImageCaptcha() into getMollomCaptcha() which can automatically determine which CSS class is on the link (that has CSS class .mollom-switch-captcha). This should probably actually be abstracted out into a mollomSwitchCaptcha() and mollomGetCaptcha() functions.
2. Simplifies the PHP code for fetching a CAPTCHA into one function. Currently it was being done in three different places, so if you wanted to change the help text, you had to change it three times. Its now available as mollom_get_captcha($type, array $data = array()).

dave reid’s picture

We should really consider using the AHAH system in D7 for the captcha replacement as we really should provide different help text for each captcha type as well. That can probably be a follow-up issue.

dries’s picture

Status: Needs review » Active

This looks like a reasonable clean-up to me.

dave reid’s picture

Dries, did you set this to active because of #4? I'd love that to be a separate follow-up issue since I haven't actually played too much with AHAH.

dries’s picture

Status: Active » Needs review

I incorrectly changed the status. Back to 'needs review'.

dries’s picture

Status: Needs review » Fixed

Reviewed and looks good. Committed to CVS HEAD.

Should we backport this to D6?

dave reid’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev
Status: Fixed » Patch (to be ported)

Yep I can work on re-rolling for D6.

dave reid’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new11.42 KB

Patch re-rolled for D6, working on testing manually to confirm the JS changes.

dave reid’s picture

Manual testing worked great and passes locally for me.

dave reid’s picture

Status: Needs review » Fixed

Committed to DRUPAL-6--1 as well.
http://drupal.org/cvs?commit=363692

sun’s picture

To be able to use the AJAX framework for this in D7, #647228: Links are needlessly unable to fully participate in D7 AJAX framework features needs to be fixed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit 2bd8241 on master, fai6, 8.x-2.x, fbajs, actions by Dries:
    - Patch #788968 by Dave Reid: simplified the JS and captcha-fetching...

  • Commit 2bd8241 on master, fai6, 8.x-2.x, fbajs, actions by Dries:
    - Patch #788968 by Dave Reid: simplified the JS and captcha-fetching...