I found following in javascript code
function calculateURI(uri) {
return (namespace.push.configuration.uriPrefix || '') + uri + (namespace.push.configuration.uriSuffix || '');
}
also I found in other place
ice.push.configuration.contextPath = 'something';
So, I wonder, how these assignments relate? Does 'namespace' identifier have special meaning? Or it is just a name like 'ice'?
Thanks
UPDATE
People saying that 'namespace' means nothing special.
But I am trying to set 'namespace.push.configuration.uriPrefix' as I see it in Firebug debugger. First it was '' and was need it to contain some path. Initially I have assigned
namespace.push.configuration.uriPrefix = ice.push.configuration.contextPath + '/';
but it was remanining empty.
Then I tried to assign
ice.push.configuration.uriPrefix = ice.push.configuration.contextPath + '/';
and have 'namespace.push.configuration.uriPrefix' filled!
How can it be if 'namespace' have no special meaning???
UPDATE 2
May be they did some overloading? The overal structure of their script looks like the following
if (!window.ice) {
window.ice = new Object;
}
if (!window.ice.icepush) {
(function(namespace) {
window.ice.icepush = true;
//....
// a lot of functions
// ....
})(window.ice);
}
everywhere in the functions 'namespace' is used and never it is spelled as 'ice'.
Can this patterd do some overloading of 'namespace' variable?
Seeing as I can't comment on your original question, I'll put this here.
There area two main ways of setting up a name space, Objects { } and Functions (like above)
What they are doing is just wrapping all of their code in an anonymous function and then calling it (this sets the scope or the namespace)
( function(variable) {
/* Code to execute using 'variable' */
} )(item_to_fill_variable)
Which is basically the same as:
function withNameSpace( namespace ) {
/* Code to execute using 'namespace' */
}
withNameSpace( window.ice );
This sets (in your example) "namespace" to "window.ice"
Now while inside of the anonymous function, you can use "namespace" to access "window.ice".
When outside of the anonymous function, "namespace" will be undefined and you wont be able to set it. This is more than likely what you were doing when trying to set namespace.push.configuration.uriPrefix = ice.push.configuration.contextPath + '/';