HTML and CSS Reference
In-Depth Information
}
});
/**
* Set up the local storage by checking to see whether
* the favorites item exists
*/
if(!localStorage.getItem('favorites')){
// if it doesn't, create an empty array and assign it to the storage
var favorites = [];
localStorage.favorites = JSON.stringify(favorites);
}
return {
/**
* Create an accessor for the controller,
* which accepts a string representation of the
* controller's namespace
*/
getController: function(name){
/**
* Split the string into an array using the .
* character to separate the string
*/
var parts = name.split('.');
/**
* Initially set the returned controller to null
*/
var returnController = null;
/**
* If the number of parts is greater than 0
*/
if(parts.length > 0){
/**
* Set the return controller to the parent object
*/
returnController = _controller;
/**
* Loop through each part, gradually assigning the action to the
* return controller
*/
for(var i = 0; i < parts.length; i++){
returnController = returnController[parts[i]];
}
}
Search WWH ::




Custom Search