Hi. I have about 2000 lines of javascript code for my application. A lot of this is user interaction / jQuery. Don't worry, it all works fine :)
But it's getting dificult to keep track of the code base. So I have split up the file into five files.
I thought that if I load all files, they all reside in memory and the can communicate with each other. but it does not look like it. Because, in file A, I have var currentPage = getURLvar('slpage'); and in file B I have if ( currentPage == 'someName').
But file B does not recognize the variable currentPage.
Also I have som general scripts in file C which file A nd B can use. But I guess that's not possible to cal leither?
Any advice is much appreciated.
UPDATE
My javascript start s like this:
// FILE A
jQuery(document).ready(function() {
var currentPage = getURLvar('slpage');
if ( (currentPage == 'Aa') || (currentPage == 'Bb') ) {
init_AA();
}
else if ( (currentPage == 'Cc') || (currentPage == 'Dd') ) {
init_BB();
} else if ( (currentPage == 'Ee') || (currentPage == 'Ff') ) {
init_CC();
}
(...)
// FILE B
function init_AA()
{
(...)
}
function getURLvar(name)
{
//Gets the URL and returns the value of specified paramter.
}