vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.6 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=194)
-   -   Integration with vBulletin - Fix vBulletin JS to work with prototype/scriptaculous (https://vborg.vbsupport.ru/showthread.php?t=139175)

YogiTW 02-11-2007 10:00 PM

Fix vBulletin JS to work with prototype/scriptaculous
 
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:

Code:

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:

Code:

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

Quote:

Originally Posted by nevetS (Post 1193195)
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.


All times are GMT. The time now is 02:41 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01018 seconds
  • Memory Usage 1,739KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete