Skip to content

Commit a915443

Browse files
committed
js change to md
1 parent 076a6a4 commit a915443

File tree

14 files changed

+97
-46
lines changed

14 files changed

+97
-46
lines changed

Native-JavaScript/ajax.js renamed to Native-JavaScript/ajax.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
###### ajax request
2+
````js
13
/**
24
* @function ajax request
35
* @fields ajaxName:请求名称,method:请求方法,headers:setRequestHeader自定义部分,url:接口地址,async:是否异步请求,withCredentials:是否支持跨域发送cookie,dataType:数据类型 ,data:post请求参数
@@ -115,3 +117,4 @@ function ajaxPostData (ajaxName, requestUrl, params, async, callBack, contentTyp
115117
}
116118
})
117119
}
120+
````

Native-JavaScript/cancel-bubble.js renamed to Native-JavaScript/cancel-bubble.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
###### 传入event则阻止冒泡
2+
````js
13
/**
24
* 可以传入event则阻止冒泡,不传不阻止
35
* @param event
@@ -9,4 +11,5 @@ function someClick (event) {
911
window.event.cancelBubble = true // IE
1012
}
1113
// TODO 需要阻止冒泡的事件
12-
}
14+
}
15+
````

Native-JavaScript/data-handle.js renamed to Native-JavaScript/data-handle.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
###### 保留小数并千分位格式化
2+
````js
13
/**
24
* 保留小数并千分位格式化
35
* @param number
@@ -21,7 +23,10 @@ function thousandsFormateTofixed (number, digit, showZero) {
2123
}
2224
return result
2325
}
26+
````
2427

28+
###### 递归遍历数组对象,将结果去重
29+
````js
2530
/**
2631
* 递归遍历数组对象,将结果去重
2732
* @returns {*}
@@ -190,7 +195,10 @@ var getAllType = function () {
190195
}, [])
191196
return result
192197
}
198+
````
193199

200+
###### 数字单位格式化
201+
````js
194202
/**
195203
* 数字单位格式化
196204
* @param number
@@ -208,7 +216,10 @@ function formatterNumberUnit (number) {
208216
}
209217
return result
210218
}
219+
````
211220

221+
###### 获取对象长度
222+
````js
212223
/**
213224
* 获取对象长度
214225
* @param obj
@@ -223,3 +234,4 @@ function getObjectLength (obj) {
223234
}
224235
return count
225236
}
237+
````

Native-JavaScript/data-type-handle.js renamed to Native-JavaScript/data-type-handle.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
###### 合并两个函数
2+
````js
13
/**
24
* 合并两个函数
35
* @param functionA 先执行
@@ -13,7 +15,10 @@ function mergeFunction (functionA, functionB) {
1315
})()
1416
return functionB = merge
1517
}
18+
````
1619

20+
###### 深度比较两个对象是否相等
21+
````js
1722
/**
1823
* 深度比较两个对象是否相等
1924
* @type {{compare: compareObj.compare, isObject: (function(*=): boolean), isArray: (function(*=): boolean)}}
@@ -57,4 +62,5 @@ var compareObj = {
5762
isArray: function (arr) {
5863
return Object.prototype.toString.call(arr) === '[object Array]'
5964
}
60-
}
65+
}
66+
````

Native-JavaScript/dom-handle.js renamed to Native-JavaScript/dom-handle.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
// DOM 相关处理
1+
###### 监听浏览器标签页的显示与隐藏
22

3+
````js
34
/**
45
* 监听浏览器标签页的显示与隐藏
56
*/
@@ -60,4 +61,30 @@ navChange.linsternVisibility(
6061
() => {
6162
// TODO 浏览器标签页处于显示状态时,执行的方法
6263
}
63-
)
64+
)
65+
66+
````
67+
68+
###### 监听dom变化
69+
````js
70+
/**
71+
* 监听dom变化
72+
* @param callback
73+
*/
74+
function monitorDomChange (callback) {
75+
var mutationObserver = new MutationObserver(function (mutations) {
76+
mutations.forEach(function (mutation) {
77+
callback(mutation)
78+
})
79+
})
80+
// 开始侦听页面的根 HTML 元素中的更改。
81+
mutationObserver.observe(document.documentElement, {
82+
attributes: true,
83+
characterData: true,
84+
childList: true,
85+
subtree: true,
86+
attributeOldValue: true,
87+
characterDataOldValue: true
88+
})
89+
}
90+
````

Native-JavaScript/encryption-decryption/base64.js renamed to Native-JavaScript/encryption-decryption/base64.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
###### abse64
2+
````js
13
/**
24
* @function decode encode base64 string
35
* @constructor Base64Function
@@ -97,3 +99,4 @@ function Base64Function () {
9799

98100
const Base64 = new Base64Function()
99101
export default {encode: Base64.encode, decode: Base64.decode}
102+
````
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
// Json字符串格式化
1+
###### Json字符串格式化
2+
````js
23
function jsonFormat (string) {
34
if (string === "") {
45
return ""
56
}
67
var result = JSON.parse(string)
78
return JSON.stringify(result, null, 4)
8-
}
9+
}
10+
````

Native-JavaScript/monitor-dom-change.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

Native-JavaScript/scroll-handle.js renamed to Native-JavaScript/scroll-handle.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// 滚动条位置处理
1+
###### 滚动条位置处理
2+
````js
23
var scrollPosition = {
34
// 位置
45
result: 0,
@@ -20,4 +21,5 @@ var scrollPosition = {
2021
setPostion: function () {
2122
window.scrollTo(document.body.scrollWidth, scrollPosition.result)
2223
}
23-
}
24+
}
25+
````

Native-JavaScript/url-param.js renamed to Native-JavaScript/url-param.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
###### 获取hash或者search参数值
2+
````js
13
/**
24
* 获取hash或者search参数值
35
* @param paramName
@@ -10,3 +12,4 @@ function getParam (paramName) {
1012
var reg = new RegExp("(^|&)" + paramName + "=([^&]*)(&|$)", "i")
1113
return result.match(reg) !== null ? decodeURI(result.match(reg)[2]) : null
1214
}
15+
````

0 commit comments

Comments
 (0)