( function() {
// namespaceオブジェクト
var NSOBJ = {};
NSOBJ.common = {};
var initFunc = [];
function init() {
initFunc.sort( function(a, b) {
return a[1] - b[1];
});
for ( var i = 0, ilen = initFunc.length; i < ilen; i++) {
initFunc[i][0]();
}
}
// init登録用関数
function setInit(f, order) {
var a = [];
a[0] = f;
a[1] = (order != null ? parseInt(order) : 9999);
initFunc.push(a);
}
// DOMContentLoadedでinit登録
// 別にonloadでもよいけど
jQuery(document).ready( function() {
init();
});
NSOBJ.common.setInit = setInit;
})();hoge.js
( function() {
function hoge1func() {
・・・
}
function hoge2func() {
・・・
}
function hoge3func() {
・・・
}
// 関数登録
NSOBJ.common.setInit(hoge1func, 10);
NSOBJ.common.setInit(hoge2func, 30);
NSOBJ.common.setInit(hoge3func, 100);
})();
0 件のコメント:
コメントを投稿