PDA

View Full Version : Integration with vBulletin - Fix vBulletin JS to work with prototype/scriptaculous


YogiTW
02-11-2007, 10:00 PM
There is a problem with some of the for loops in vBulletin's javascript (or it's a problem with prototype.js, depends who you talk to :))

The problem is vB's use of the for/in loop: for (var i in array_var) { }

When you alter the array prototype, those new values show up as i. For example:


Array.prototype.wtf = function() { }

var s = new Array("1", "2", "3");

for (var i in s) {
alert(i);
}


you will get pop ups that say 1, 2, 3, and wtf.

The solution is to add a little line of code in each of these loops to test the typeof on array_var[i] and see if it == 'function'. If so, continue.

I wrote a perl script that will scan all the js files in your client script directory and insert this check.

Unzip the attached zip file and there is a perl script inside. Upload the script to your server and edit the line at the top that read:


my $dir = "CHANGEME"


set this variable to be the ABSOLUTE path to your clientscript directory. It will create backup files.

Hopefully some will find this helpfull :)

MaTraX
02-12-2007, 02:12 PM
Thank you. Will try this fix soon :)

HOST-KSA.COM
02-12-2007, 07:05 PM
Has the server enable the Pl to do it ?

YogiTW
02-12-2007, 11:24 PM
Yeah you need perl, it's run from the command line so you need shell access. I can't upload fixed .js files due to the license

SimplyBen
02-20-2007, 03:45 PM
[2007-02-20 17:42:52]: error: file is writable by others: (/home/ben225/public_html/fixfor.pl)
[2007-02-20 17:39:47]: error: file is writable by others: (/home/ben225/public_html/forums/clientscript/fixfor.pl)
[2007-02-20 17:38:51]: error: file has no execute permission: (/home/ben225/public_html/forums/clientscript/fixfor.pl)
[2007-02-20 17:35:11]: error: file has no execute permission: (/home/ben225/public_html/fixfor.pl)
[2007-02-20 17:33:44]: error: file has no execute permission: (/home/ben225/public_html/fixfor.pl)



Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@ben225.hostultra.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

I got these errors and am not sure the problem. I have perl 5.8.6 on my paid webhost.

Any clue what the prob might be?

YogiTW
02-22-2007, 08:02 PM
You don't run it over the web, you run it at the command line.

nexialys
02-22-2007, 08:41 PM
for the benefit of everybody, please provide a PHP version of your script, or a list of FIND/REPLACE so everybody can handle this modification as it is supposed to be...

most of the users here have no idea how to handle that kind of script...

nevetS
03-01-2007, 07:53 AM
It appears that this misses a few instances - inlinemod.js, vbulletin_ajax_namesugg.js, vbulletin_multi_quote.js, and vbulletin_thrdpostlist.js.

I simply changed "for (i in var)" to "for (i=0; i< var.length;i++)

I'll report back if it doesn't work momentarily.

Edit... This seems to be the fix for vbulletin_inline_mod.js - I haven't tested the others quite yet.

RoughJunk
04-19-2007, 03:33 AM
It appears that this misses a few instances - inlinemod.js, vbulletin_ajax_namesugg.js, vbulletin_multi_quote.js, and vbulletin_thrdpostlist.js.

I simply changed "for (i in var)" to "for (i=0; i< var.length;i++)

I'll report back if it doesn't work momentarily.

Edit... This seems to be the fix for vbulletin_inline_mod.js - I haven't tested the others quite yet.

did you test the other ones?

ROTPAR
05-16-2007, 10:08 AM
I attached a modified version of the script that also replaces those missed for's
Quick hack, but it worked for me...
Btw this is not only for Prototype users, Mootools also works fine after this fix.. and probably other libraries too.

liquidx
05-22-2007, 10:06 AM
Mootools uses prototype =)

Thank you so much for this.

You might consider releasing some diff patches instead? Perhaps with a patcher application.

Using a patcher app you could make it so anyone can patch their clientscripts just by downloading them, run the patch, upload them. All fixed =)

TheMilkCarton
07-20-2007, 03:22 AM
Can FIND/REPLACE instructions or a PHP version (if that's possible) please be made? Not everyone has command line access.

I would really like to add some nice effects to my boards, but now I'm currently limited to what pages I can use the Mootools JS on.

Ian Cunningham
10-16-2007, 12:50 PM
I'm really stuck on this too, could you explain a little about what the script does pleaseand I'll do it manually?

Thankyou :)

Ventrixius
10-25-2007, 10:07 AM
Hi, i'd really like to be able to use this, but i do not know how to run the script via perl shell. Please provide a php version of this?

Michael Morris
10-29-2007, 04:59 AM
For in is not the only incompatibility between vb and prototype, just the most noticeable. I'm about 1/3 of the way through the only truly workable approach to this problem - replacing the stock javascript entirely, and with it most of the vb templates that are laced to the gills with javascript calls.

For in also appears in a couple of templates - which this will not correct. (I don't remember which ones off hand but remember seeing them).

rezilient
01-06-2008, 01:45 AM
We ran this patch in an attempt to fix an issue with using Script.aculo.us (and Prototype). This fixed an issue with bad entries in Fonts and Sizes dropdown which occurred in FireFox.

But we still have an issue with problems switching to Standard Editor and problems Cancelling and Saving in QuickEdit... Problem only seems to occur in IE (both 6 and 7). FireFox appears to be working fine now.

Any idea why FireFox 2 would be working but IE6 and IE7 is not working?

Ian Cunningham
02-08-2008, 02:24 PM
Has anyone managed to get this working on 3.7, as neither script seems to work on it :(

PyroNET
02-09-2008, 10:17 PM
Doesn't seem to work... I'd be willing to pay if somebody could find a solution.

testes
05-01-2008, 08:02 PM
the only ajax api compatible to the rest is jQuery... i testet it on vb 3.7.0... it works and doesn't ++++ up the vbulletin scripts using YUI. ;) the problematic issue here is namespaces and jquery got its own. the rest is using the same and this is whats killing your scripts.

use jQuery and your stuff runs fine... :cool:

AWJunkies
05-09-2008, 04:08 AM
3.7 they changed and made this edit I see you guys doing if I am mistaken let me know. But there is still issue with IE6 and IE7. Please I need this fixes asap as a portion of my mod requires prototype.

ArchangelX
07-27-2008, 01:49 AM
AWESOME...thanks...that worked great! Much oblidged!