Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> JavaScript
Author Message
scorpious
Worker
Worker



Joined: Dec 03, 2005
Posts: 153

PostPosted: Mon Aug 15, 2011 3:53 am Reply with quote

Hi All

This is the first time for me to use a javascript, so, I am not sure which is the best way to include it.

I have a countdown script, countdown.js

Which is the best way to include it within a module. I have noticed that all the js scripts are in the includes/jquery folder.

How can I call the countdown.js

Cheers
Scorp
 
View user's profile Send private message
neralex
Site Admin



Joined: Aug 22, 2007
Posts: 1775

PostPosted: Mon Aug 15, 2011 5:11 am Reply with quote

at 1st you must upload your js-files. i maked a folder in my theme. my most js-scripts works only with the selected themes. i don't use the jquery-folder in the includes to store my own js-files. its a RN core system folder.

if you want the script in all areas of your nuke, then must load the js script into your header. open the directory /includes/custom_files/ and make a file called custom_head.php. here can load your js- or css-files into your header before the body was started. now open this file and put this line into it:

Code:
<script type="text/javascript" src="yourscript.js"></script>

the alternative way to load your js-file only with a module. open your module index.php or the module file of your choice. go to start the file and serach for:

Code:
$module_name = basename(dirname(__FILE__)); 


add after this to load your file into the header:
Code:
addJSToHead('modules/".$module_name."/scripts/yourscript.js','file');


add after this to load your file into the body:
Code:
addJSToBody('modules/".$module_name."/scripts/yourscript.js','file');


check the RN-Wiki for more details: http://rnwiki.ravennuke.com/wiki/RavenNuke2:Loading_CSS_and_JavaScript

Wink
 
View user's profile Send private message
scorpious







PostPosted: Wed Aug 17, 2011 2:34 am Reply with quote

Hi neralex,

Cheers for the reply, the first script I had would not work when called from a js file, it will work if I include
Code:
<script>....</scritp>
within the file, I have found another javascript and it works by using the
Code:
<script type="text/javascript" src="yourscript.js"></script>


Cheers for the info

Scorp
 
killing-hours
RavenNuke(tm) Development Team



Joined: Oct 01, 2010
Posts: 438
Location: Houston, Tx

PostPosted: Wed Aug 17, 2011 9:24 am Reply with quote

@Scorpious


The easiest way to add the script into a module with the addJSToHead() function.

Within your module folder... make a folder called "js" or w/e you want to name it. Put your javascript file in there.

Then, on the page you want the javascript file to be loaded.... add this

Code:
addJSToHead('modules/YOUR_MODULE/js/YOUR_JS.js','file');



just after the "!defined('MODULE_FILE')". That will load your javascript file on the page you want it to be loaded on and not elsewhere as it's not needed. This way, for me, has worked in ALL occurrences I've used it with all the scripts I've ever tried. If you need help with it... let me know and I'll set you up with a working file for your files so you can see it in action.

_________________
Money is the measurement of time - Me
"You can all go to hell…I’m going to Texas" -Davy Crockett 
View user's profile Send private message
scorpious







PostPosted: Wed Aug 17, 2011 10:34 am Reply with quote

Hi killing-hours

Cheers for that, If I get stuck I give you a shout.

Cheers
scorp
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> JavaScript

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©