vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   RESOLVED: Vbulletin Variable / Array names in Javascript? (https://vborg.vbsupport.ru/showthread.php?t=229644)

vaskies 12-12-2009 04:38 PM

PHP Code:

strip_quotes();
htmlspecialchars_uni();
fetch_censored_text();
strip_bbcode(); 

Those are all vbulletin functions, yeah? For simple testing, I tried using just the strip_quotes function on its own:
PHP Code:

$lastxdevel1[pagetext] = strip_quotes($lastxdevel1[pagetext]); 

That line of code has no effect on how the javascript mouseover handles $lastxdevel1[pagetext]. As if the function weren't doing anything at all. To test this, I'm using a thread that has all normal characters in the title, but a single quote at the beginning of the post.

Does strip_quotes(); need to be redefined from within the plugin?

kh99 12-12-2009 05:36 PM

Well to be honest I don't know the details of what any of those functions do, just thought since (I believe) it's doing something like what you're trying, maybe something would be useful.

As it turns out, it looks like "strip_quotes" (which is in functions.php) strips [quote] tags out of the text. So I guess it had nothing to do with your quote problem, sorry about that.

Maybe you can use the php str_replace function to replace ' with \' (put a backslash in front of it)? I'm afraid I'm not much help at this point - maybe worse than none if I lead you astray. :)

vaskies 12-15-2009 01:01 PM

-Phew- First of all, thanks for pointing me to functions.php. It's really helping me to begin understanding how vbulletin works.

After a lot of learning (particularly noteworthy is the php str_replace) as well as furthering my understanding of vbulletin's functions, I've managed to create a working concept. Any character I throw at it it replaces with a javascript-friendly version.

I set up a live example here.

You'll see though in the example that the thread on the right doesn't show the tooltip. This is because the post preview (pagetext) has a line break in it. To remedy this problem, I did the following:

PHP Code:

$placeholders = array("'""<br />");
$fixup = array("\'"" ");

$saPreview2 str_replace($placeholders$fixup$lastxdevel2['pagetext']); 

What's odd is, if you view the source you will indeed see that the <br /> has been properly replaced with a space. Yet there is still a line break, and more importantly, the tooltip still does not work.

So my question is, why would a line break in pagetext cause the tooltip to cease functioning? Is there something about how vbulletin handles line breaks in pagetext that I'm unaware of? Or is this a javascript syntax conflict? I know that javascript ignores whitespace so I'm leaning towards the possibility this is more a vbulletin issue than a javascript one...

kh99 12-15-2009 01:30 PM

Hmm...I think what you have is an actual newline character in the string which I don't think is allowed in a javascript string constant. Maybe try replacing "\n" with "\\n" (which will hopefully put "\n" in the javascript string instead of the actual newline).

vaskies 12-15-2009 01:57 PM

:D Aweeesome. I was not aware of this newline character. Interesting.

Well, it took over a week but we did it! Thanks so much for your time and help. You have no idea. :)

Thankfully the rest of the site's development will involve mostly CSS and HTML, which I'm much more adept at. After I get a solid handling of PHP functions and loops though, I plan to learn javascript as well as other programming languages. My feeling is, once I get a firm grasp of one, the rest will be much easier to learn as I've become accustomed to typical programming language syntax.


All times are GMT. The time now is 12:53 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.01134 seconds
  • Memory Usage 1,736KB
  • 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
  • (3)bbcode_php_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
  • (5)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