vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   How to input vbphrase in js (https://vborg.vbsupport.ru/showthread.php?t=292982)

Easy5s.net 12-14-2012 01:34 PM

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

kh99 12-14-2012 01:43 PM

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.

Easy5s.net 12-14-2012 02:26 PM

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);
            }
        }


kh99 12-14-2012 02:29 PM

Where is that js file being included? It must be in a template or in html somewhere, right?

Easy5s.net 12-14-2012 02:32 PM

Yes, it is located in one *.js file and I hook it to $template_hook ['headinclude_javascript']

kh99 12-14-2012 02:42 PM

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;



All times are GMT. The time now is 03:47 AM.

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.01537 seconds
  • Memory Usage 1,718KB
  • 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
  • (5)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete