fe-utils
collect all kinds of utility functions that are often used by us.
Installation
In a browser:
<script src="fe-utils.js"></script>
Using npm:
$ npm i -g npm
$ npm i --save fe-utils
Usage:
var cookie = require('fe-utils/cookie')
var date = require('fe-utils/date')
...
allMethods:
- NumberToChinese
NumberToChinese(12345) // '一万二千三百四十五'
NumberToChinese(12345, true) // '壹万贰仟叁佰肆十伍'
- cookie
setCookie(name, domain, domain, expiredays)
getCookie(name)
delCookie(name, domain)
- date
dateFormat() // dateFormat(new Date(), 'YYYY年MM月DD日 hh:mm:ss')
- detectedInfos
- isAndroid / isIOS / isWindowPhone / isWX / isWeibo / isMobile / isPC
- preventViewScroll
- urlQuery
queryOne // queryOne('name', ['http://xx.com?name=kevin']) -> 'kevin'
queryAll // queryOne('http://xx.com?name=kevin&age=18') -> {name: 'kevin', age: 18}
- toRoman
- getVersionOfIOS
getVersionOfIOS() // '10.3'
- relProtocol
relProtocol('http://xxx.com') // '//xxx.com'
- logger
- mediaError
mediaError(video / audio, (code, msg) => { ... }) // for error-listener-callback of audio and video