-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjavascript.json
276 lines (271 loc) · 11 KB
/
javascript.json
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
{
// Place your snippets for javascript here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
//自定义注释第一版=============================
//自定义注释第一版=============================
//自定义注释第一版=============================
//代码块介绍 不带参数
"notes_code": {
"prefix": "notes_modular_name nmn",
"body":"//xb:codeBlockDescribe:$0",
"description": "不带参代码块介绍"
},
//代码块介绍 带参数
"notes_code_parameter": {
"prefix": "notes_modular nm",
"body":"/**xb:\n codeBlockDescribe:$1\n data:$2 \n**/",
"description": "带参代码块介绍"
},
//跟随鼠标移动
"MouseMovement": {
"prefix": "$code_mousemovement $cmm",
"body":["//xb:跟随鼠标移动",
"//xb:codeBlockDescribe:MommBox==Mouse movement box",
"var MommBox=document.getElementById(\"MommBox\")",
"document.getElementById(\"MommBox\").onmousedown=function(ev){",
"//codeBlockDescribe:兼容各个浏览器///IE等浏览器则可以直接使用event或者window.event得到事件本身",
"var oevent = ev || event;",
"var distanceX = oevent.clientX - MommBox.offsetLeft;",
"var distanceY = oevent.clientY - MommBox.offsetTop;",
"//xb:codeBlockDescribe:事件会在鼠标指针移动时发生",
"document.onmousemove = function(ev){",
" var oevent = ev || event;",
" MommBox.style.left = oevent.clientX - distanceX + \"px\";",
" MommBox.style.top = oevent.clientY - distanceY + \"px\"; ",
"};",
"//xb:codeBlockDescribe:事件会在鼠标按键被松开时发生。",
"document.onmouseup = function(){",
" document.onmousemove = null;",
" document.onmouseup = null;",
"};",
"}"],
"description": "跟随鼠标移动"
},
//代码块 jQuery 常用代码模板=====================================
//代码块 jQuery 常用代码模板=====================================
//代码块 jQuery 常用代码模板=====================================
//正则表达式 常用下拉
"$.RegExp_s": {
"prefix": "$code_regexp $regexp $re",
"body":"var telMeg =${1|公司常用手机验证/^0?1[3\\|4\\|5\\|8\\|7][0-9]\\d{8}\\$/,手机验证/^1[3\\|4\\|5\\|8\\|7][0-9]\\d{8}\\$/|};",
"description": "正则表达式 常用下拉"
},
//js自动实时修改rem自适应
"$.rem": {
"prefix": "$code_rem $rem",
"body":[
"//xb:codeBlockDescribe:屏幕宽度",
"var xb_width1=document.documentElement.getBoundingClientRect().width;",
"//js rem自适应代码 自动加载",
"(function (doc, win) {",
" var docEl = doc.documentElement;",
" var width = docEl.getBoundingClientRect().width;",
" // if(width<=1280){",
" var rem = width * 75 / 750;",
" docEl.style.fontSize = rem + 'px'",
" // }",
" //xb:codeBlockDescribe:屏幕宽度发生改变 实时更新rem",
" window.onresize = function(){",
" var docEl = doc.documentElement;",
" var width = docEl.getBoundingClientRect().width;",
" var rem = width * 75 / 750;",
" docEl.style.fontSize = rem + 'px'",
" }",
"})(document, window);"],
"description": "js自动实时修改rem自适应 "
},
//IE兼容相关
"$.ie_version": {
"prefix": "$code_ieversion $ieversion $ie",
"body":"if ($.browser.msie && ($.browser.version <= \"9.0\")){}",
"description": "IE兼容判断当前版本号小于9.0"
},
// input placeholder ie兼容
"$.ie_input_placeholder": {
"prefix": "$code_ie_input $code_inputie",
"body":[
"/**xb:",
" codeBlockDescribe: input ie兼容",
" data:",
"**/",
"$(\".xbm_pubFormBox input\").focus(function(){",
" if($(this).val()==$(this).attr(\"placeholder\"))",
" {",
" $(this).val(\"\");",
" }",
" else if($(this).val()==\"\"){",
" $(this).val($(this).attr(\"placeholder\"));",
" }",
"})",
"$(\".xbm_pubFormBox input\").blur(function(){",
" if($(this).val()==\"\"){",
" $(this).val($(this).attr(\"placeholder\"));",
" }",
"})"],
"description": "input placeholder ie兼容"
},
//判断是手机还是pc
"$.PC/iPhone/Android": {
"prefix": "$code_pc $pciphone $pcandroid",
"body":["if(/Android|webOS|iPhone|iPod|BlackBerry/i.test,(navigator.userAgent)) {",
" alert(\"手机端\");",
" } else {",
" alert(\"PC\")",
" }"],
"description": "判断是手机还是pc"
},
//动画跳转到顶部
"$.scrollTop": {
"prefix": "$code_scrolltop $scrolltop",
"body":["$(\".xb_a1\").click(function(){",
" $(\"${1:body,html\").animate({scrollTop:$(\"$0\").offset().top},500)",
" })"],
"description": "动画跳转到顶部"
},
//数组元素删除
"$.arryRemove": {
"prefix": "$arryRemove $aRemove",
"body":["//xb:codeBlockDescribe:splice 添加删除 inArray 返回索引",
"arr1.splice($.inArray(arr2),1);"],
"description": "数组元素删除(位置下标)"
},
//字体轮播上下滚动
"$.fontCarousel": {
"prefix": "$code_fontCarousel $fontCarousel",
"body":[
"setInterval(FunFontCarousel, 1000)",
"function FunFontCarousel() {",
" //codeBlockDescribe:添加动画效果",
" //codeBlockDescribe:动态移动",
" //类名为ul",
" var names=\"\";",
" var mTop=25;",
" $(names).animate({",
" \"margin-top\": \"-\"+mTop+\"px\"",
" }, function() {",
" $(names).find(\"li\").eq(0).appendTo($(names))",
" $(names).css({",
" \"margin-top\": \"0px\"",
" })",
" })",
"}"
],
"description": "字体轮播上下滚动"
},
//表单提交默认模板
"$.formPostt": {
"prefix": "$code_formpost $formpost 表单提交",
"body":[
"//xb:codeBlockDescribe:表单提交",
"function FunFormSubmit(){",
" //codeBlockDescribe:获取表格内容",
" var name=$(\".xbm_main form .xb_inp1\").val();",
" var mobile=$(\".xbm_main form .xb_inp2\").val();",
" var eara=$(\".xbm_main form .xb_inp3\").val();",
" var cellname=$(\".xbm_main form .xb_inp4\").val();",
" var txt=\"\";",
" //xb:codeBlockDescribe:判断是否为空",
" if(name.length<1){",
" alert(\"称呼不能为空\")",
" return ;",
" }",
" var telMeg = /^0?1[3|4|5|7|8|9][0-9]\\d{8}\\$/;",
" if (mobile != \"\") {",
" if (!telMeg.test(mobile)) {",
" alert(\"联系方式格式有误\");",
" return ;",
" }",
" } else {",
" alert(\"手机号不能为空\");",
" return false;",
" }",
" $.post(\"/home/news/bprice\",{cityid:cityid,eara:eara,name:name,mobile:mobile,cellname:'',aparment:'',house:'',style:'',txt:txt,url:'',lyurl:''},function (result) {",
" if(result.code == 200){",
" }else{",
" alert(result.msg) ",
" }",
" $('.xbm_main form')[0].reset();",
" })",
"}"
],
"description": "表单提交默认模板 获取 判断 提交 返回"
},
//定时计算时间差然后改变数字
"$.timedifference": {
"prefix": "$code_timedifference $timedifference",
"body":[
"function m5_theNumberOf() {",
" //codeBlockDescribe:每日增加的个数",
" var day_addnum=50;",
" //codeBlockDescribe:时间差,比如每天只有13个小时计算",
" var day_timeDif=13;",
" var m5_newdate= new Date();",
" var m5_Hours=m5_newdate.getHours(); //当前小时",
" var m5_newday = m5_newdate.getDate(); //当前天",
" var m5_newMonth = m5_newdate.getMonth()+1; //当前月",
" var m5_newYeas=m5_newdate.getFullYear();//当前年",
" var m5_time_start = m5_newdate.getTime();",
" //codeBlockDescribe:基数,最少的基数",
" var BeginNum=0;",
" //设定目标时间,然后计算当前时间到起始时间之间的时间差",
" var m5_time_end = new Date(\"2018/1/13 10:00:00\").getTime(); ",
" var m5_time_end2 = new Date(\"\"+m5_newYeas+\"/\"+m5_newMonth+\"/\"+m5_newday+\" 00:00:00\").getTime(); ",
" // 计算时间差 ",
" var m5_time_distance = m5_time_start-m5_time_end;",
" // 天",
" var int_day = Math.floor(m5_time_distance / 86400000)",
" m5_time_distance -= int_day * 86400000;",
" // 时",
" var int_hour = Math.floor(m5_time_distance / 3600000)",
" m5_time_distance -= int_hour * 3600000;",
" // 分",
" var int_minute = Math.floor(m5_time_distance / 60000)",
" m5_time_distance -= int_minute * 60000;",
" // 秒 ",
" var int_second = Math.floor(m5_time_distance / 1000)",
" //只在10点到22点之间增加值",
" if(m5_Hours>=10&&m5_Hours<=22){",
" //计算每天没小时每分钟没秒增加数目",
" var numa=Math.floor(Number(int_day*day_addnum)+Number(int_hour*(day_addnum/day_timeDif))+Number(int_minute*(day_addnum/day_timeDif/60))+Number(int_second*(day_addnum/day_timeDif/60/60)));",
" console.log(Number(int_day*day_addnum)+Number(int_hour*(day_addnum/day_timeDif))+Number(int_minute*(day_addnum/day_timeDif/60))+Number(int_second*(day_addnum/day_timeDif/60/60)));",
" $(\"$1\").text(numa+BeginNum);",
" }",
" else if(m5_Hours<10){",
" $(\"$1\").text(Number(int_day)*day_addnum+BeginNum);",
" }",
" else if(m5_Hours>22){",
" $(\"$1\").text(Number(int_day+1)*day_addnum+BeginNum);",
" }",
"}",
"setInterval(m5_theNumberOf,1000);"
],
"description": "时间差改变数据"
},
//动态添加客户信息
"$.dynamicInfo": {
"prefix": "$code_info $info",
"body":[
"XBFunDynamicInfor();",
"function XBFunDynamicInfor(){",
" //姓氏变量",
" var xb_surName='李王张刘陈杨赵黄周吴徐孙胡朱高林何郭马罗梁宋郑谢韩唐冯于董萧程曹袁邓许傅沈曾彭吕苏卢蒋蔡贾丁魏薛叶阎余潘杜戴夏钟汪田任姜范方石姚谭廖邹熊金陆郝孔白崔康毛邱秦江史顾侯邵孟龙万段漕钱汤尹黎易常武乔贺赖龚文';",
" //尊称",
" var xb_nickName=['先生','女士'];",
" //手机号码",
" var iphoneNum='34578'",
" //随机数 Math.floor(Math.random()*10+1)",
" function xbsuiji(num1,num2){return Math.floor(Math.random()*num1+num2);}",
" //以下部分为添加html内容",
" var xbi=0",
" while (xbi<30){",
" \\$('$1').append(\"<li>\"+xb_surName[xbsuiji(100,0)]+\"\"+xb_nickName[xbsuiji(2,0)]+\"成功报价1\"+iphoneNum[xbsuiji(5,0)]+\"\"+xbsuiji(10,0)+\"*****\"+xbsuiji(899,100)+\"面积\"+xbsuiji(110,80)+\"</li>\");",
" xbi++;",
" }",
"}"
],
"description": "动态添加客户信息"
},
}