Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 25 Aug 2011, 11:21
Frosty Frosty is offline
 
Join Date: Apr 2011
CYB Chatbox external javascript

Hey everyone,
Is there any way we can put the javascript of the CYB Chatbox in a file? It would surely decrease the page load, and source of the page wouldn't be so messy either.

I tried to do it myself, but it wouldn't load the Chatbox, I assume it's because it loads it like a normal js file, and variables probably can't work.

Any ideas? Thanks...
Reply With Quote
  #2  
Old 25 Aug 2011, 13:05
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
I'm not a js expert, but I think you should just be able to put the code in a file and put a <script> tag in the html. Did you put <script...> in the same place you took out the code?
Reply With Quote
  #3  
Old 25 Aug 2011, 13:40
Frosty Frosty is offline
 
Join Date: Apr 2011
Yeah, of course. But the problem is that js has variables, and when you put it in a file and go directly to it, variables won't work - obviously!


It works if it isn't external. :/

Last edited by Frosty; 05 Oct 2011 at 06:15.
Reply With Quote
  #4  
Old 25 Aug 2011, 14:41
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Oh, you mean that it has template conditionals and PHP variables (javascript also has it's own variables, so I didn't understand what you were getting at).

What you can do is find all the PHP variables it uses, then put them in a template that outputs js code that simply sets a js variable to that value. Then change the js code (that you're trying to move to a file) to use the js variables, and change the template conditionals to js 'if' statements.

Another way would be to set the src of the scirpt tag to a php file that renders the template and returns the js. But that way you wouldn't be able to allow the browser to cache the output which I guess is the point of doing this.

Edit: The headinclude template already has a section that sets js variables, it looks like this:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


You could add yours there, but you'd probably want to have some sort of template conditional around it so you weren't putting it in every page (like maybe <if condition="THIS_SCRIPT == 'misc'">)

Last edited by kh99; 25 Aug 2011 at 15:02.
Reply With Quote
Reply

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chat Modifications Cyb - ChatBox Valter vBulletin 3.7 Add-ons 1244 03 Feb 2016 13:36
Chat Modifications Chatbox Rules in cyb chatbox title Hornstar vBulletin 3.7 Template Modifications 15 23 Apr 2011 16:57



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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


New To Site? Need Help?

All times are GMT. The time now is 13:27.

Layout Options | Width: Wide Color: