webfn
v0.1.1
Published
A function package for web development
Downloads
2
Readme
Fn.js
Install
> Download the file
> Get it by npm/cnpm
npm install webfn
Usage
> Import as a single file
Create a script tag and insert it in the HTML file,just like:
<script src="fn.js">
> Import as a es6/node module
import it in the javascript file
import 'fn.js'
let ua = require('webfn/lib/ua')
Sample
The default namespace is "fn",you can use the function as this example
var ua = fn.ua()
//return an object whihc contains some user agent info
{
isPC:false,
isMobile:true,
platform:'iphone', //pc | iphone | ipad ..
browser:'wx', //browser name
version:6 //browser version
}
When you use it as a single file,if the "fn" is existed,or you just wanna change another name,you can do like this:
var ___ = fn.conflict()
__.ua()
Reference
ua()
return a ojbect which contains the user agent info,and add some classes to html elementresponse([opts])
define the response rules for window size,add some classes to the html element by the custom optionresetREM([designSize])
rewrite the REM base size(modify the html font-size) refer to the design sizeparam(key)
get the value of the specified key in the urlrandomColor()
return a random color string by hexadecimal code,just like"#00CCFF"preLoadImage(srcArr,[cb])
load some images and exec a callback functiontypeOf(o)
judge the type of the target,return a string,just like "string"