-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunc.js
64 lines (56 loc) · 1.62 KB
/
func.js
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
var domSetAttributes = function ( node, attributes ) {
for ( attribute in attributes ) {
node.setAttribute( attribute, attributes[ attribute ] );
}
};
var getById = function ( arg ) {
return typeof this !== undefined && isDOM( this ) && this !== window ?
this.getElementById( arg ) :
document.getElementById( arg );
};
var getByClass = function ( arg ) {
return typeof this !== undefined && isDOM( this ) && this !== window ?
this.getElementsByClassName( arg ) :
document.getElementsByClassName( arg );
};
var isDOMNode = function ( arg ) {
return (
typeof Node === "object" ?
arg instanceof Node :
arg && typeof arg === "object" && typeof arg.nodeType === "number" && typeof arg.nodeName==="string"
);
};
var isDOMElement = function ( arg ) {
return (
typeof HTMLElement === "object" ?
arg instanceof HTMLElement :
arg && typeof arg === "object" && arg !== null && arg.nodeType === 1 && typeof arg.nodeName==="string"
);
};
var isDOM = function ( arg ) {
return isDOMNode( arg ) || isDOMElement( arg );
};
var makeClass = function ( name, constructor, properties ) {
name = constructor;
for ( var property in properties ) {
name[ property ] = properties[ property ];
}
name.prototype = name;
return name;
};
var Class = function ( args ) {
var constructor = args.constructor,
static = args.static,
prototype = args.prototype || Object.prototype;
// constructor.prototype = prototype;
for ( var property in static ) {
this[ property ] = static[ property ];
}
return constructor;
};
var isObject = function ( arg ) {
if ( (typeof A === "object") && (A !== null) ) {
return false;
}
return true;
}