Hello there,
We are doing in a custom page an integration with the vBulletin captcha, and we are almost done, but in special circunstances when we get an error from a progress we need to reload the captcha with ajax in the same form.
At this time, all the progress of captcha are made my the file vbulletin_ajax_imagereg.js, but it works with YUI, and to be honest I never use it before and I spend few hours and still I didnt get a easy way to reload the captcha calling a funcition in one line without press the default reload captcha link.
PHP Code:
/*======================================================================*\
|| #################################################################### ||
|| # vBulletin 4.1.2
|| # ---------------------------------------------------------------- # ||
|| # Copyright ?2000-2011 vBulletin Solutions Inc. All Rights Reserved. ||
|| # This file may not be redistributed in whole or significant part. # ||
|| # ---------------- VBULLETIN IS NOT FREE SOFTWARE ---------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html # ||
|| #################################################################### ||
\*======================================================================*/
function vB_AJAX_ImageReg()
{
this.init()
}
vB_AJAX_ImageReg.prototype.init = function ()
{
if (AJAX_Compatible && (typeof vb_disable_ajax == "undefined" || vb_disable_ajax < 2) && YAHOO.util.Dom.get("refresh_imagereg"))
{
YAHOO.util.Event.on("refresh_imagereg", "click", this.fetch_image, this, true);
YAHOO.util.Dom.removeClass("refresh_imagereg", "hidden");
YAHOO.util.Event.on("imagereg", "click", this.fetch_image, this, true)
}
};
vB_AJAX_ImageReg.prototype.fetch_image = function (A)
{
YAHOO.util.Event.stopEvent(A);
YAHOO.util.Dom.removeClass("progress_imagereg", "hidden");
YAHOO.util.Connect.asyncRequest("POST", "ajax.php?do=imagereg",
{
success : this.handle_ajax_response, failure : this.handle_ajax_error, timeout : vB_Default_Timeout,
scope : this
},
SESSIONURL + "securitytoken=" + SECURITYTOKEN + "&do=imagereg&hash=" + YAHOO.util.Dom.get("hash").getAttribute("value"));
return false;
};
vB_AJAX_ImageReg.prototype.handle_ajax_error = function (A)
{
vBulletin_AJAX_Error_Handler(A)
};
vB_AJAX_ImageReg.prototype.handle_ajax_response = function (B)
{
YAHOO.util.Dom.addClass("progress_imagereg", "hidden");
if (B.responseXML)
{
var A = B.responseXML.getElementsByTagName("error");
if (A.length) {
alert(A[0].firstChild.nodeValue)
}
else
{
var C = B.responseXML.getElementsByTagName("hash")[0].firstChild.nodeValue;
if (C)
{
YAHOO.util.Dom.get("hash").setAttribute("value", C);
YAHOO.util.Dom.get("imagereg").setAttribute("src", "image.php?" + SESSIONURL + "type=hv&hash=" + C)
}
}
}
};
function vB_AJAX_ImageReg_Init()
{
new vB_AJAX_ImageReg()
};
If we use a simple <a href="">, what we can call from inline to reload the captcha?
Thank you in advanced for any help.
--------------- Added [DATE]1299619304[/DATE] at [TIME]1299619304[/TIME] ---------------
Update:
Well, I tried this and works fine in FF and Chrome, but IE (as always sucks) return an error.
PHP Code:
function fakeClick(anchorObj) {
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window,
0, 0, 0, 0, 0, false, false, false, false, 0, null);
var allowDefault = anchorObj.dispatchEvent(evt);
}
Error in IE:
Quote:
Mensaje: El objeto no acepta esta propiedad o m?todo
|
In english something like: Error: Object doesn't support this action
If anyone can suggest me something better will be very nice.
--------------- Added [DATE]1299621670[/DATE] at [TIME]1299621670[/TIME] ---------------
Update:
Ok, I get solved with this:
PHP Code:
function robotClick(anchorObj) {
if (anchorObj.click) {
anchorObj.click()
}else{
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window,
0, 0, 0, 0, 0, false, false, false, false, 0, null);
var allowDefault = anchorObj.dispatchEvent(evt); }
}
And you can call it in your JS as easy as: robotClick(document.getElementById('refresh_imager eg'));
I somebody have a better solution ( I'm pretty sure that It could exist

please reply