Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
  #1  
Old 12-14-2012, 02:34 PM
Easy5s.net Easy5s.net is offline
 
Join Date: Jun 2011
Posts: 201
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How to input vbphrase in js

We can use vbphrase in js file like?
$vbphrase or {vb: rawphrase}

I've tried two ways but not working
Reply With Quote
  #2  
Old 12-14-2012, 02:43 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Since the js runs on the client browser, it won't have access to the vb variables. But what the vb code does is it creates js variables to makes some values available. If you look in the headinclude template you'll see a section like this:

Code:
	var SESSIONURL = "{vb:raw session.sessionurl_js}";
	var SECURITYTOKEN = "{vb:raw bbuserinfo.securitytoken}";
	var IMGDIR_MISC = "{vb:stylevar imgdir_misc}";
	var IMGDIR_BUTTON = "{vb:stylevar imgdir_button}";
//etc...

If you are including your js file in a vbulletin template (or in html that's output by a vbulletin "powered" script) you can do something similar. You might be able to use $template_hook['headinclude_javascript'] to include it in the headinclude template, depending on your situation.
Reply With Quote
  #3  
Old 12-14-2012, 03:26 PM
Easy5s.net Easy5s.net is offline
 
Join Date: Jun 2011
Posts: 201
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here is a snippet of the file. js, and I want to use alternative vbpharse Thank

Code:
        if(x.readyState==4&&x.status==200)
		{
            el.innerHTML='';
            el=document.getElementById(id);
            el.innerHTML=x.responseText;
			document.getElementById(id2).innerHTML = "thank";
            if (eval_str) eval(eval_str);
            }
        }
Reply With Quote
  #4  
Old 12-14-2012, 03:29 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Where is that js file being included? It must be in a template or in html somewhere, right?
Reply With Quote
  #5  
Old 12-14-2012, 03:32 PM
Easy5s.net Easy5s.net is offline
 
Join Date: Jun 2011
Posts: 201
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, it is located in one *.js file and I hook it to $template_hook ['headinclude_javascript']
Reply With Quote
  #6  
Old 12-14-2012, 03:42 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, so I guess now you have something like:
Code:
$template_hook['headinclude_javascript'] .= '<script type="text/javascript" src="something.js" ></script>';

So add something to the beginning, like this:
Code:
$template_hook['headinclude_javascript'] .= '<script type="text/javascript">
var thanks_phrase = \'' . addslashes_js($vbphrase['thanks']) . '\';
</script>
<script type="text/javascript" src="something.js" ></script>';

then in your js file use thanks_phrase, like:
Code:
el.innerHTML=x.responseText;
			document.getElementById(id2).innerHTML = thanks_phrase;
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:51 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03853 seconds
  • Memory Usage 2,200KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (5)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete