Created
April 23, 2010 03:12
-
-
Save kyo-ago/376127 to your computer and use it in GitHub Desktop.
url dispatcher
This file contains 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 dispatcher = function (path, func) { | |
if (func) return dispatcher.path_func.push([path, func]); | |
$.each(dispatcher.path_func, function () { | |
if (path.match(this[0])) return this[1](); | |
}); | |
}; | |
dispatcher.path_func = []; | |
setTimeout(function () { dispatcher(location.pathname); }, 0); | |
dispatcher('.', function () { | |
// 全URLで使う内容 | |
}); | |
dispatcher('/hoge', function () { | |
// /hogeで使う内容 | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment