-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmethodzero.js
More file actions
131 lines (106 loc) · 2.58 KB
/
methodzero.js
File metadata and controls
131 lines (106 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
//
// methodzero.js 0.0.0.1
// 2013.07.15.
// kang hwan ki
//
;(function(){
// -------------------------------------------------
// private
// namespace : '_mz_'
// -------------------------------------------------
var _mz_ = _mz_ || {};
_mz_.toString = function(o) {
return Object.prototype.toString.call(o);
};
_mz_.now = function(fmt) {
var dt = new Date();
fmt = fmt || "YYYY/MM/DD HH:MI:SS:MS";
return fmt.replace("YYYY",dt.getFullYear())
.replace("YY",dt.getFullYear().toString().substring(2))
.replace("MM",(dt.getMonth() + 1))
.replace("DD",dt.getDate())
.replace("HH",dt.getHours())
.replace("MI",dt.getMinutes())
.replace("SS",dt.getSeconds())
.replace("MS",dt.getMilliseconds());
};
_mz_.document = function() {
return _mz_.doc = _mz_.doc || (window ? window.document : undefined);
};
// -------------------------------------------------
var root = this;
var mz = {
VERSION : "0.0.0.1",
};
// logger
mz.log = {
level:0,
DEBUG:1,
INFO:2,
WARN:3,
ERROR:4,
FATAL:5
};
mz.log.level = function(level) {
};
mz.log.debug = function(){
var arg = arguments,
print = function(data) {
console.log(data);
};
console.groupCollapsed("[DEBUG]"+ _mz_.now(" MM월DD일 HH시MI분"));
mz.core.each(arg, print);
console.groupEnd();
};
// --------------------------------------------------
// core
// --------------------------------------------------
mz.core = {
BREAK : {}
};
//
mz.core.each = function(collection, filter, context) {
if(collection.length === collection.length+0) {
for(var i=0,l=collection.length; i<l; i++) {
if (filter.call(context, collection[i], i, collection) === mz.core.BREAK)
return;
}
} else {
for(var key in collection) {
if (filter.call(context, collection[key], key, collection) === mz.core.BREAK)
return;
}
}
};
//
mz.core.typeof = function(object,target){
return _mz_.toString(object).indexOf(target) > 0;
};
mz.core.each(
["Object","String","Number","Array","Boolean"],
function(data){
mz.core["is"+data] = function(target) {
return mz.core.typeof(target, data);
};
}
);
// - alias -----------------------------------------
mz.core.each(mz.core, function(v,k){ mz[k] = v; }, mz);
mz.debug = mz.log.debug;
root.mz = mz;
// -------------------------------------------------
// document
// -------------------------------------------------
mz.doc = {};
//
mz.doc.get = function(s) {
var doc = _mz_.document();
var el = doc.getElementById(s);
if(el) return el;
el = doc.getElementsByName(s);
if(el.length>0) return el;
el = doc.getElementsByTagName(s);
if(el.length>0) return el;
return null;
};
}).call(this);