-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
291 lines (281 loc) · 9.34 KB
/
index.html
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>onavojs库</title>
<!-- <script type="text/javascript" src="onavo.js"></script> -->
<!-- <script type="text/javascript" src="onavo.min.js"></script> -->
<script type="text/javascript" src="onavo.hex.js"></script>
<style type="text/css">
#id {
width: 100px;
height: 100px;
background: #ff00ff;
display: inline-block;
}
#id3,
#id5 {
width: 200px;
height: 30px;
background: #ff00ff;
}
#textarea-log {
display: inline-block;
}
</style>
</head>
<body>
<!-- id -->
<h2>
<div id="id">1.id : $$('id')
<div id="id2"></div>
</div>
<br/>
<textarea id="textarea-log" cols="60" rows="5"></textarea>
<div id="id3">id3</div><input type="button" id="button" value="清除自定义alert事件" />
<div id="id5">id5</div>
</h2>
<script type="text/javascript">
$$('id')
</script>
<!-- id -->
<hr/>
<!-- jsload, cssload -->
<h2>2.jsload, cssload: $$T.jsload , $$T.cssload</h2>
<script type="text/javascript">
$$T.cssload('http://mat1.gtimg.com/www/base/base.css', function() {
//console.log('base.css ok')
});
$$T.jsload('http://mat1.gtimg.com/www/js/newsapp/jsapi/news.js?_tsid=1', function() {
//检测系统新闻app/微信/浏览器
var CheckSystem = {
UA: navigator.userAgent.toLowerCase(),
isNewsApp: function() {
try {
if (CheckSystem.UA.match(/qqnews/i) == 'qqnews') {
return true;
} else {
return fasle;
}
} catch (e) {}
},
isWeixin: function() {
try {
if (CheckSystem.UA.match(/MicroMessenger/i) == 'micromessenger') {
return true;
} else {
return fasle;
}
} catch (e) {}
},
isiPhone: function() {
try {
if (CheckSystem.UA.match(/iphone/i) == 'iphone') {
return true;
} else {
return fasle;
}
} catch (e) {}
}
}
});
</script>
<!-- jsload, cssload -->
<!-- 判断浏览器 -->
<hr/>
<h2>3.判断浏览器: $$TB.B , $$TB.IE() , $$TB.weixin(),$$TB.cookie().set(), $$TB.cookie.get(), $$TB.cookie().remove()</h2>
<script type="text/javascript">
$$TB.B
var flag = $$TB.IE();
if (flag) {
//alert("11")
} else {
//alert('22')
}
$$TB.cookie().set('name', 'myname', 1)
//$$TB.cookie.del('name')
//console.log($$TB.cookie.read('name'))
</script>
<!-- 判断浏览器 -->
<!-- 数组方法 -->
<hr/>
<h2>4.数组方法: $$A $$A.unique() , $$A.random() , $$A.shuffle(), $$A.contains() , $$A.removeAt(), $$A.remove() , $$A.compact() , $$A.pluck() , $$A.union(), $$A.intersect() , $$A.diff(), $$A.max() , $$A.min()</h2>
<script type="text/javascript">
var arr = [2, 3, 3, '收到', '阿萨德', 12, '阿萨德', 13, 2, 1, 2, 30];
//$$A.unique(arr) //数组去重
//$$A.random(); //在数组中随机取一个
</script>
<!-- 数组方法 -->
<!-- 字符串方法 -->
<hr/>
<h2>5.字符串方法: $$S $$S.camelize() , $$S.byteLen() , $$S.capitalize() , $$S.contains(), $$S.containsClass() , $$S.dasherize() , $$S.endsWith(), $$S.startsWith(), $$S.fillZero, $$S.print() , $$S.repeat(), $$S.stripTags(), $$S.trim(), $$S.truncate()</h2>
<script type="text/javascript">
var string_xx = "margin-top-padding-niu--hin-top-padding-niu--hi";
var string_2xx = "HI";
var ddx = {
name: 21323,
adssa: 32213
}
//获得字符串字节长度
$$S.byteLen(string_xx, "utf-8")
//驼峰转化
$$S.camelize(string_xx)
//首字母大写
$$S.capitalize(string_xx)
//一个字符串是否包含另一个字符串
$$S.contains(string_xx, string_2xx)
//参2是参1的结尾么
$$S.endsWith(string_xx, string_2xx, true);
$$S.fillZero(string_2xx, 100);
$$S.print(string_2xx)
$$S.repeat(string_xx, 22)
$$S.repeat(string_xx, 22)
$$S.truncate(string_xx)
</script>
<!-- 字符串方法 -->
<!-- dom方法 -->
<hr/>
<h2 id="id4">6.dom方法 : $$D.setStyle(), $$D.curStyle() , $$D.getClientRect(), $$D.getRect(),$$D.contains(), $$D.getScrollLeft(), $$D.getScrollTop() ,$$D.nextB() ,$$D.nextB() , $$D.nextBs(), $$D.prevBs(), $$D.getType() </h2>
<script type="text/javascript">
var id = $$('id');
var id2 = $$('id2');
var id3 = $$('id3');
var id4 = $$('id4');
$$D.getScrollTop(id);
$$D.contains(id, id2)
$$D.contains(id2, id3)
$$D.getRect(id)
$$D.curStyle(id).backgroundColor
$$D.curStyle(id2).height
//$$D.setStyle(id,'height','10px')
//$$D.setStyle(id, {
// position: "absolute",
// visibility: "hidden",
// display: "block",
// zIndex: 99,
// margin: 0});
//$$D.setStyle(id,{})
//$$D.getSize(id).width
//
</script>
<!-- dom方法 -->
<!-- 原型方法 -->
<hr/>
<h2>7.原型方法 $$.extend() , $$.deepextend(), $$.warpp()</h2>
<!-- 原型方法 -->
<hr/>
<h2>8.对象检测 $$.type.getType() ,$$.type.isArray(), $$.type.isBoolen() ,$$.type.isFunction() , $$.type.isNull() , $$.type.isObject() , $$.type.isString() , $$.type.isUndefined()</h2>
<!-- ajax -->
<hr/>
<h2>9.Ajax扩展: $$jx 【$$jx.load('file',function(res){},'filetype','type');】</h2>
<script type="text/javascript">
$$jx.load('json.json', function(data) {
//console.log(data)
}, 'json', 'get');
$$jx.load('data.xml', function(xmlDoc) {
//console.log(xmlDoc)
}, "XML");
</script>
<!-- ajax -->
<!-- Function -->
<hr/>
<h2>10.Function方法 :$$F.bind() ,$$F.bindAsEventListener()</h2>
<script type="text/javascript">
var id5 = $$("id5");
//$$E.addEvent(id5,'click',id5fun)
//function id5fun(e){
// function _newobj(){
// console.log('xx')
// };
// this._name = 'jjj';
// this._name2 = {
// dd : function(){
// console.log('dd');
// }
// }
// $$F.bind( fnClick(), this);
// console.log(e.srcElement._name)
// console.log(e.srcElement.outerText)
// console.log(e.target)
//};
var in2 = function(){
console.log('in22')
};
var textarea = $$("textarea-log");
$$E.addEvent(textarea, 'click', function(){
console.log('textarea')
});
function T(c) {
this.id = "双击";
this.out = "移开";
this.dom = $$("id5");
this.dom2 = $$("textarea-log")
}
T.prototype = {
init: function() {
this.dom.onclick = function() {
console.log(this.id);
}
this.dom.ondblclick = function() {
console.log(this.id);
$$F.bindAsEventListener(dom2 ,this)
}.bind(this);
this.dom.onmouseout = function() {
$$F.bind(in2() ,this)
console.log(this);
}.bind(this)
}
};
new T().init()
</script>
<!-- Function -->
<!-- Event -->
<hr/>
<h2>12.Event方法 :$$E.addEvent(),$$E.removeEvent() , $$E.fixEvent()</h2>
<script type="text/javascript">
//http://www.w3school.com.cn/jsref/dom_obj_event.asp
var logEl = $$('textarea-log');
//fix ie
function logEvent(type) {
logEl.innerHTML = logEl.innerHTML + '\n' + new Date().toLocaleTimeString() + ' - ' + type;
logEl.scrollTop = logEl.scrollHeight;
}
$$E.addEvent(id, 'touchstart', function(event) {
logEvent(event)
});
$$E.addEvent(id, 'click', function(event) {
$$E.fixEvent(event)
logEvent("click")
});
</script>
<!-- Event -->
<!-- CustomEvent -->
<hr/>
<h2>13.DOM CustomEvent: $$CE.addEvent() , $$CE.removeEvent(), $$CE.fireEvent(), $$CE.clearEvent()</h2>
<script type="text/javascript">
var fnClick = function() {
alert('自定义click!')
},
funAlert1 = function() {
alert("自定义alert事件弹出!");
},
funAlert2 = function() {
alert("自定义alert事件再次弹出!");
};
$$CE.addEvent(id3, 'click', fnClick);
$$CE.addEvent(id3, 'ww', fnClick);
$$CE.addEvent(id3, 'alert', funAlert1);
$$CE.addEvent(id3, 'alert', funAlert2);
var button = $$("button");
$$CE.addEvent(button, "click", function() {
$$CE.removeEvent(id3, "alert", funAlert1)
$$CE.removeEvent(id3, "alert", funAlert2);
alert("清除成功!");
});
//$$CE.fireEvent(id3, 'alert')
//$$CE.fireEvent(id3, 'ww')
//$$CE.fireEvent(button, 'click')
</script>
<!-- CustomEvent -->
</body>
</html>