Created
November 10, 2011 04:49
-
-
Save aokolish/1354144 to your computer and use it in GitHub Desktop.
Run page JS without switch statement
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var LTD = {}; | |
LTD.product = (function() { | |
//private functions | |
function somethingHandy() { | |
... | |
} | |
return { | |
//public functions... | |
init: function () { | |
//event handlers and such... | |
} | |
} | |
})(); | |
LTD.global = (function() { | |
//same idea as LTD.product | |
... | |
})(); | |
$(function() { | |
var location = $('body').attr("id").split("-"), | |
section = location[0], | |
subsection = location[1]; | |
//always run global stuff | |
LTD.global.init(); | |
//run code for the relevant page | |
LTD[section].init(); | |
LTD[section][subsection].init(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment