-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtool.html
More file actions
601 lines (543 loc) · 20.4 KB
/
Copy pathtool.html
File metadata and controls
601 lines (543 loc) · 20.4 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
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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="author" content="HongShaoRou"/>
<title>公用组件</title>
<style>
* {
-webkit-tap-highlight-color: transparent;
}
body, html {
font-size: 62.5%;
height: 100%;
padding: 0;
margin: 0;
background-color: #fff;
font-family: STHeitiSC-Light, Helvetica-Light, arial, sans-serif, 'Droid Sans Fallback';
}
input {
-webkit-user-select: auto;
-webkit-appearance: none;
appearance: none;
outline: 0;
}
::-webkit-input-placeholder {
color: #999;
}
li, ul {
list-style: none;
}
a {
text-decoration: none;
color: #4c4c4c;
}
em {
font-style: normal;
}
.show {
display: block !important;
}
.hide {
display: none !important;
}
.bold {
font-weight: bold !important;
}
.fixed {
position: fixed !important;
}
.bdn {
border: none !important;
}
.cb {
clear: both !important;
}
html, body {
width: 100%;
max-width: 768px;
margin: 0 auto;
}
button {
display: block;
width: 80%;
margin: 1rem auto;
background: #ef4454;
color: #fff;
border: none;
border-radius: 5px;
text-align: center;
padding: .6rem 0
}
a.js_to_h {
display: block;
width: 80%;
margin: 1rem auto;
background: #fff;
color: #ef4454;
border: none;
border-radius: 5px;
text-align: center;
padding: .6rem 0;
border: 1px solid #ef4454;
font-size: 1.4rem
}
label {
font-size: 1.6rem;
}
.time-frame {
margin: 1rem 0;
text-align: center
}
.time-frame input {
width: 50%;
border: 1px solid #d0d0d0;
padding: 0.3rem 0;
font-size: 1.6rem;
}
.time-frame label {
margin-right: 1rem;
}
img {
width: 100%
}
.js_img_frame {
width: 100%;
height: 10rem;
overflow: hidden;
}
</style>
<link rel="stylesheet" type="text/css" href="style/mobile_tool.css">
<link rel="stylesheet" type="text/css" href="style/mobile_time.css"/>
</head>
<body>
<div class="time-frame">
<label>活动时间</label><input type="text" placeholder="点击添加时间" id="time"/>
</div>
<div class="mocm_frame">
<a href="javascript:;" class="mocm_btn_full" id="showToast1">点击已完成</a>
</div>
<div class="mocm_frame">
<a href="javascript:;" class="mocm_btn_prime" id="showToast2">点击加载中</a>
</div>
<div class="mocm_frame">
<a href="javascript:;" class="mocm_btn_prime" id="showToast3">点击提示</a>
</div>
<div class="mocm_frame">
<div class="mocm_cells_title">原图</div>
<div><img src="images/mg_g4.jpg" alt=""></div>
</div>
<div class="mocm_frame">
<div class="mocm_cells_title mocm_prime_bgcolor">调整后图</div>
<div><img class="js_img_ad" src="images/mg_g4.jpg" alt=""></div>
</div>
<button id="popup">点击弹出框</button>
<button id="edgeTop">边缘弹出框上</button>
<button id="edgeBottom">边缘弹出框下</button>
<div class="mocm_frame">
<div class="mocm_cells_title mocm_prime_bgcolor">BOX功能测试</div>
<div class="mocm_cells">
<div class="mocm_cell" id="emailTest">
<div class="mocm_cell_bd mocm_cell_primary">
<p>123456@qq.com</p>
</div>
<div class="mocm_cell_ft">
</div>
</div>
<div class="mocm_cell" id="emailTest2">
<div class="mocm_cell_bd mocm_cell_primary">
<p>12345689</p>
</div>
<div class="mocm_cell_ft">
</div>
</div>
<div class="mocm_cell" id="phoneTest">
<div class="mocm_cell_bd mocm_cell_primary">
<p>15236251489</p>
</div>
<div class="mocm_cell_ft">
</div>
</div>
<div class="mocm_cell" id="phoneTest2">
<div class="mocm_cell_bd mocm_cell_primary">
<p>12345678910</p>
</div>
<div class="mocm_cell_ft">
</div>
</div>
<div class="mocm_cell" id="ipText">
<div class="mocm_cell_bd mocm_cell_primary">
<p>192.168.1.254</p>
</div>
<div class="mocm_cell_ft">
</div>
</div>
<div class="mocm_cell" id="ipText2">
<div class="mocm_cell_bd mocm_cell_primary">
<p>1256.1</p>
</div>
<div class="mocm_cell_ft">
</div>
</div>
<div class="mocm_cell" id="telText">
<div class="mocm_cell_bd mocm_cell_primary">
<p>010-87654321</p>
</div>
<div class="mocm_cell_ft">
</div>
</div>
<div class="mocm_cell" id="telText2">
<div class="mocm_cell_bd mocm_cell_primary">
<p>8653258</p>
</div>
<div class="mocm_cell_ft">
</div>
</div>
<div class="mocm_cell" id="urlText">
<div class="mocm_cell_bd mocm_cell_primary">
<p>http://www.cc.com</p>
</div>
<div class="mocm_cell_ft">
</div>
</div>
<div class="mocm_cell" id="urlText2">
<div class="mocm_cell_bd mocm_cell_primary">
<p>ccc.cn</p>
</div>
<div class="mocm_cell_ft">
</div>
</div>
<div class="mocm_cell" id="chineseText">
<div class="mocm_cell_bd mocm_cell_primary">
<p>哈哈</p>
</div>
<div class="mocm_cell_ft">
</div>
</div>
<div class="mocm_cell" id="chineseText2">
<div class="mocm_cell_bd mocm_cell_primary">
<p>ccc</p>
</div>
<div class="mocm_cell_ft">
</div>
</div>
<div class="mocm_cell" id="isNickname">
<div class="mocm_cell_bd mocm_cell_primary">
<p>ccc</p>
</div>
<div class="mocm_cell_ft">
</div>
</div>
<div class="mocm_cell" id="isNickname2">
<div class="mocm_cell_bd mocm_cell_primary">
<p>ccc??</p>
</div>
<div class="mocm_cell_ft">
</div>
</div>
<div class="mocm_cell" id="isAccount">
<div class="mocm_cell_bd mocm_cell_primary">
<p>ccc456</p>
</div>
<div class="mocm_cell_ft">
</div>
</div>
<div class="mocm_cell" id="isAccount2">
<div class="mocm_cell_bd mocm_cell_primary">
<p>ccc??</p>
</div>
<div class="mocm_cell_ft">
</div>
</div>
<div class="mocm_cell" id="isJSON">
<div class="mocm_cell_bd mocm_cell_primary">
<p>"@qwwe"</p>
</div>
<div class="mocm_cell_ft">
</div>
</div>
<div class="mocm_cell" id="isJSON2">
<div class="mocm_cell_bd mocm_cell_primary">
<p>boa()</p>
</div>
<div class="mocm_cell_ft">
</div>
</div>
<div class="mocm_cell" id="iscard">
<div class="mocm_cell_bd mocm_cell_primary">
<p>330702194706165014</p>
</div>
<div class="mocm_cell_ft">
</div>
</div>
<div class="mocm_cell" id="iscard2">
<div class="mocm_cell_bd mocm_cell_primary">
<p>123565858565354158</p>
</div>
<div class="mocm_cell_ft">
</div>
</div>
<div class="mocm_cell" id="Stringlength">
<div class="mocm_cell_bd mocm_cell_primary">
<p>ssssss</p>
</div>
<div class="mocm_cell_ft">
</div>
</div>
<div class="mocm_cell" id="isCHS">
<div class="mocm_cell_bd mocm_cell_primary">
<p>男女</p>
</div>
<div class="mocm_cell_ft">
</div>
</div>
<div class="mocm_cell" id="isCHS2">
<div class="mocm_cell_bd mocm_cell_primary">
<p>sss</p>
</div>
<div class="mocm_cell_ft">
</div>
</div>
<div class="mocm_cell" id="subCHString">
<div class="mocm_cell_bd mocm_cell_primary">
<p>sssss</p>
</div>
<div class="mocm_cell_ft">
</div>
</div>
<div class="mocm_cell" id="overFlowText">
<div class="mocm_cell_bd mocm_cell_primary">
<p>sss一</p>
</div>
<div class="mocm_cell_ft">
</div>
</div>
<div class="mocm_cell" id="overFlowText2">
<div class="mocm_cell_bd mocm_cell_primary">
<p>sssss</p>
</div>
<div class="mocm_cell_ft">
</div>
</div>
</div>
</div>
<!-- 由于在tool.js中对于移动端引入fastClick使用JSONP 所以需要放在底部 -->
<script src="js/jquery-2.2.3.js"></script>
<script src="js/tool.js"></script>
<script src="js/tool_time.js"></script>
<script type="text/template" id="example">
<a class="js_to_h" href="#{{link}}">
{{name}}
</a>
</script>
<script>
$(document).ready(function () {
/*emali*/
var emailTest = toolKit.box.isEmail($("#emailTest").find("p").text());
$("#emailTest").find(".mocm_cell_ft").html(emailTest + " " + " " + "(email)");
var emailTest2 = toolKit.box.isEmail($("#emailTest2").find("p").text());
$("#emailTest2").find(".mocm_cell_ft").html(emailTest2 + "");
/*phone*/
var phoneText = toolKit.box.isMobile($("#phoneTest").find("p").text());
$("#phoneTest").find(".mocm_cell_ft").html(phoneText + " " + " " + "(phone)");
var phoneText2 = toolKit.box.isMobile($("#phoneTest2").find("p").text());
$("#phoneTest2").find(".mocm_cell_ft").html(phoneText2 + "");
/*ipv4地址*/
var ipText = toolKit.box.isIp($("#ipText").find("p").text());
$("#ipText").find(".mocm_cell_ft").html(ipText + " " + " " + "(ip)");
var ipText2 = toolKit.box.isIp($("#ipText2").find("p").text());
$("#ipText2").find(".mocm_cell_ft").html(ipText2 + "");
/*tel*/
var telText = toolKit.box.isTel($("#telText").find("p").text());
$("#telText").find(".mocm_cell_ft").html(telText + " " + " " + "(tel)");
var telText2 = toolKit.box.isTel($("#telText2").find("p").text());
$("#telText2").find(".mocm_cell_ft").html(telText2 + "");
/*Url*/
var urlText = toolKit.box.isUrl($("#urlText").find("p").text());
$("#urlText").find(".mocm_cell_ft").html(urlText + " " + " " + "(url)");
var urlText2 = toolKit.box.isUrl($("#urlText2").find("p").text());
$("#urlText2").find(".mocm_cell_ft").html(urlText2 + "");
/*中文*/
var chineseText = toolKit.box.isChinese($("#chineseText").find("p").text());
$("#chineseText").find(".mocm_cell_ft").html(chineseText + " " + " " + "(中文)");
var chineseText2 = toolKit.box.isChinese($("#chineseText2").find("p").text());
$("#chineseText2").find(".mocm_cell_ft").html(chineseText2 + "");
/*判断只是 字母 数字 下划线*/
var isNickname = toolKit.box.isNickname($("#isNickname").find("p").text());
$("#isNickname").find(".mocm_cell_ft").html(isNickname + " " + " " + "(文字下划线)");
var isNickname2 = toolKit.box.isNickname($("#isNickname2").find("p").text());
$("#isNickname2").find(".mocm_cell_ft").html(isNickname2 + "");
/*判断只是 字母 数字 下划线*/
var isAccount = toolKit.box.isAccount($("#isNickname").find("p").text());
$("#isAccount").find(".mocm_cell_ft").html(isAccount + " " + " " + "(文字下划线)");
var isAccount2 = toolKit.box.isAccount($("#isAccount2").find("p").text());
$("#isAccount2").find(".mocm_cell_ft").html(isAccount2 + "");
/*Json*/
var isJSON = toolKit.box.isJSON($("#isJSON").find("p").text());
$("#isJSON").find(".mocm_cell_ft").html(isJSON + " " + " " + "(Json)");
var isJSON2 = toolKit.box.isJSON($("#isJSON2").find("p").text());
$("#isJSON2").find(".mocm_cell_ft").html(isJSON2 + "");
/*检查身份证号,0为合法,0为合法,0为合法,重要的事情说三遍*/
/*返回值:0 1 2 3 4 0为合法,0为合法,0为合法,重要的事情说三遍*/
var iscard = toolKit.box.checkIDCard($("#iscard").find("p").text());
$("#iscard").find(".mocm_cell_ft").html(iscard + " " + " " + "(身份证)");
var iscard2 = toolKit.box.checkIDCard($("#iscard2").find("p").text());
$("#iscard2").find(".mocm_cell_ft").html(iscard2 + "");
/*获取页面上的url*/
var urla = "http://www.xunbao178.com?ask=100";
var urlb = "ask";
var getQueryText = toolKit.box.getQuery(urlb, urla);
/*$("#getQueryText").find(".mocm_cell_ft").html(getQueryText +" "+" "+"(获取页面上的url)");*/
console.log(getQueryText)
/*去掉除字符串中的HTML标签*/
var strremove = '<span>111</span>';
var removeHTMLTagText = toolKit.box.removeHTMLTag(strremove);
/* $("#removeHTMLTagText").find(".mocm_cell_ft").html(removeHTMLTagText +" "+" "+"(去掉除字符串中的HTML标签)");*/
console.log(removeHTMLTagText)
/*json对象转换为字符串*/
var Jsonobj = {"time": 14, "age": 18};
var Jsonobjs = $("#addid13").text(); //undefined类型时
var objToStrText = toolKit.box.objToStr(Jsonobj);
/* $("#objToStrText").find(".mocm_cell_ft").html(objToStrText +" "+" "+"(json对象转换为字符串)"); */
console.log(objToStrText);
/*计算字符串长度,汉字是长度算1,英文算0.5个字符*/
var Stringlength = $("#Stringlength").find("p").text();
$("#Stringlength").find(".mocm_cell_ft").html(Stringlength.strLen() + " " + " " + "计算字符串长度");
//var asp = "男女";
//console.log(asp.strLen());
/*判断某个字符是否是汉字*/
var isCHS = $("#isCHS").find("p").text();
$("#isCHS").find(".mocm_cell_ft").html(isCHS.isCHS() + " " + " " + "判断字符是否是汉字");
var isCHS2 = $("#isCHS2").find("p").text();
$("#isCHS2").find(".mocm_cell_ft").html(isCHS2.isCHS() + " " + " " + "判断字符是否是汉字");
/*将字符串拆成字符,并存到数组中*/
var strToChars = "的撒大声地";
console.log(strToChars.strToChars());
/*截取字符串*/
var subCHString = $("#subCHString").find("p").text();
//console.log(subCHString.subCHStr(1,3)+" "+" "+"截取字符串");
$("#subCHString").find(".mocm_cell_ft").html(subCHString.subCHStr(1, 3) + " " + " " + "截取字符串");
/*截取字符串*/
var overFlowText = $("#overFlowText").find("p").text();
$("#overFlowText").find(".mocm_cell_ft").html(overFlowText.overFlowText(2) + " " + " " + "截取字符串");
//console.log(overFlowText.overFlowText(-2))
var overFlowText2 = $("#overFlowText2").find("p").text();
$("#overFlowText2").find(".mocm_cell_ft").html(overFlowText2.overFlowText(-1) + " " + " " + "截取字符串");
$('#showToast1').on('click', function () {
toolKit.toastOK();
});
$('#showToast3').on('click', function () {
toolKit.toast("这才是提示");
});
$('#showToast2').on('click', function () {
var ing = toolKit.toasting("hahah");
setTimeout(function () {
$("#" + ing).remove();
}, 3000)
});
/* 弹框示例 */
$('#popup').on('click', function () {
// btn与callback一一对应 switch为回调开关
var setting = {
"closeIcon": true,
"callback": [],
"autoClose": true
}
toolKit.pop(setting);
});
/* 上弹框实例 */
$('#edgeTop').on('click', function () {
// btn与callback一一对应 switch为回调开关
var setting = {
"htmlCode": "<h1>哈哈哈哈哈</h1>",
"callback": [function () {
alert("success!")
}, function () {
alert("failure!")
}],
"popPosition": "top"
};
toolKit.edge(setting);
});
/* 下弹框实例 */
$('#edgeBottom').on('click', function () {
// btn与callback一一对应 switch为回调开关
var setting = {
"title": "写个标题",
"htmlCode": "<h1>哈哈哈哈哈</h1>",
"btn": ["下载", "取消"],
"callback": [function () {
alert("success!")
}],
"closeIcon": true,
"popPosition": "bottom",
"isAnimate": true
};
toolKit.edge(setting);
});
console.log(toolKit.box.objToStr([{key: 1, v: 2}]));
/* template示例 */
var temp = toolKit.template($("#example").text(), {link: "aaa", name: "模板示例"});
$("body").append(temp);
$(document).on("tap", "a.js_to_h", function (e) {
toolKit.pop({message: $(this).text()});
e.preventDefault();
return false;
});
/*$(document).on("click","a",function(e){
console.log("a click");
e.preventDefault();
return false;
});*/
$(document).on("swipeLeft", "a.js_to_h", function () {
var popid = toolKit.pop({message: "向左走~~"});
console.log(popid);
return false;
});
/* array map 示例 */
var users = [
{name: "张含韵", "email": "zhang@email.com"},
{name: "江一燕", "email": "jiang@email.com"},
{name: "李小璐", "email": "li@email.com"}
];
var emails = users.map(function (user) {
return user.email;
});
console.log(emails.join(", "));
/* 节流示例 */
window.onresize = toolKit.throttle(function () {
console.log("节流触发")
}, 1000);
var winw = $(window).width();
//console.log(winw);
$(".js_img_ad").each(function (index, el) {
toolKit.adjustImage(el, winw, 100);
});
/* 时间插件实例 */
(function ($) {
var date = new Date();
var currYear = date.getFullYear();
var opt = {};
var $time = $("#time");
opt.datetime = {preset: 'date'};
opt._default = {
theme: 'android-ics light', //皮肤样式
display: 'modal', //显示方式
mode: 'scroller', //日期选择模式
dateFormat: 'yyyy年mm月dd日',
lang: 'zh',
minDate: date,//最小日期
startYear: currYear - 1, //开始年份
endYear: currYear //结束年份
};
var optDateTime = $.extend(opt['datetime'], opt['_default']);//将自定义的属性放进去
$time.mobiscroll(optDateTime).datetime(optDateTime);
})(jQuery)
})
</script>
</body>
</html>