Edit readme: guide to contribute

This commit is contained in:
Faisal Salman 2016-11-09 23:41:57 +07:00
parent 2467a458e3
commit 1a4dab5829
2 changed files with 37 additions and 19 deletions

View File

@ -10,13 +10,15 @@ Lightweight JavaScript-based User-Agent string parser. Supports browser & node.j
* Demo : http://faisalman.github.io/ua-parser-js * Demo : http://faisalman.github.io/ua-parser-js
* Source : https://github.com/faisalman/ua-parser-js * Source : https://github.com/faisalman/ua-parser-js
## Features
# Features
Extract detailed type of web browser, layout engine, operating system, cpu architecture, and device type/model purely from user-agent string with relatively lightweight footprint (~11KB minified / ~4KB gzipped). Written in vanilla js, which means it doesn't depends on any other library. Extract detailed type of web browser, layout engine, operating system, cpu architecture, and device type/model purely from user-agent string with relatively lightweight footprint (~11KB minified / ~4KB gzipped). Written in vanilla js, which means it doesn't depends on any other library.
![It's over 9000](https://raw.githubusercontent.com/faisalman/ua-parser-js/gh-pages/images/over9000.jpg) ![It's over 9000](https://raw.githubusercontent.com/faisalman/ua-parser-js/gh-pages/images/over9000.jpg)
## Methods
# Methods
* `getBrowser()` * `getBrowser()`
* returns `{ name: '', version: '' }` * returns `{ name: '', version: '' }`
@ -95,7 +97,8 @@ ppc, sparc, sparc64
* `setUA(uastring)` * `setUA(uastring)`
* set & parse UA string * set & parse UA string
## Example
# Example
```html ```html
<!doctype html> <!doctype html>
@ -168,7 +171,7 @@ ppc, sparc, sparc64
</html> </html>
``` ```
### Using node.js ## Using node.js
```sh ```sh
$ npm install ua-parser-js $ npm install ua-parser-js
@ -189,7 +192,7 @@ http.createServer(function (req, res) {
console.log('Server running at http://127.0.0.1:1337/'); console.log('Server running at http://127.0.0.1:1337/');
``` ```
### Using requirejs ## Using requirejs
```js ```js
require(['ua-parser-js'], function(UAParser) { require(['ua-parser-js'], function(UAParser) {
@ -198,25 +201,25 @@ require(['ua-parser-js'], function(UAParser) {
}); });
``` ```
### Using component ## Using component
```sh ```sh
$ component install faisalman/ua-parser-js $ component install faisalman/ua-parser-js
``` ```
### Using bower ## Using bower
```sh ```sh
$ bower install ua-parser-js $ bower install ua-parser-js
``` ```
### Using meteor ## Using meteor
```sh ```sh
$ meteor add faisalman:ua-parser-js $ meteor add faisalman:ua-parser-js
``` ```
### Using jQuery/Zepto ($.ua) ## Using jQuery/Zepto ($.ua)
Although written in vanilla js (which means it doesn't depends on jQuery), this library will automatically detect if jQuery/Zepto is present and create `$.ua` object based on browser's user-agent (although in case you need, `window.UAParser` constructor is still present). To get/set user-agent you can use: `$.ua.get()` / `$.ua.set(uastring)`. Although written in vanilla js (which means it doesn't depends on jQuery), this library will automatically detect if jQuery/Zepto is present and create `$.ua` object based on browser's user-agent (although in case you need, `window.UAParser` constructor is still present). To get/set user-agent you can use: `$.ua.get()` / `$.ua.set(uastring)`.
@ -239,7 +242,7 @@ console.log($.ua.device); // {vendor: "Motorola", model: "Xoom", type:
console.log(parseInt($.ua.browser.version.split('.')[0], 10)); // 4 console.log(parseInt($.ua.browser.version.split('.')[0], 10)); // 4
``` ```
### Extending regex patterns ## Extending regex patterns
* `UAParser(uastring[, extensions])` * `UAParser(uastring[, extensions])`
@ -253,19 +256,34 @@ var parser = new UAParser(uaString, { browser: myOwnRegex });
console.log(parser.getBrowser()); // {name: "MyOwnBrowser", version: "1.3"} console.log(parser.getBrowser()); // {name: "MyOwnBrowser", version: "1.3"}
``` ```
## Development
Verify, test, & minify script # Development
## Contribute
* Fork and clone this repository
* Make some changes as required
* Write a unit test to showcase your feature
* Run the test suites to make sure the changes you made didn't break anything
```sh ```sh
$ npm run test $ npm run test
```
* Commit and push to your own repository
* Submit a pull request to this repository under `develop` branch
* Profit?
## Build
Build a minified & packed script
```sh
$ npm run build $ npm run build
``` ```
Then submit a pull request to https://github.com/faisalman/ua-parser-js under `develop` branch.
# License
## License
Dual licensed under GPLv2 & MIT Dual licensed under GPLv2 & MIT

View File

@ -275,10 +275,10 @@
/(comodo_dragon)\/([\w\.]+)/i // Comodo Dragon /(comodo_dragon)\/([\w\.]+)/i // Comodo Dragon
], [[NAME, /_/g, ' '], VERSION], [ ], [[NAME, /_/g, ' '], VERSION], [
/(MicroMessenger)\/([\w\.]+)/i // WeChat /(micromessenger)\/([\w\.]+)/i // WeChat
], [[NAME, 'WeChat'], VERSION], [ ], [[NAME, 'WeChat'], VERSION], [
/XiaoMi\/MiuiBrowser\/([\w\.]+)/i // MIUI Browser /xiaomi\/miuibrowser\/([\w\.]+)/i // MIUI Browser
], [VERSION, [NAME, 'MIUI Browser']], [ ], [VERSION, [NAME, 'MIUI Browser']], [
/\swv\).+(chrome)\/([\w\.]+)/i // Chrome WebView /\swv\).+(chrome)\/([\w\.]+)/i // Chrome WebView
@ -296,7 +296,7 @@
/(uc\s?browser)[\/\s]?([\w\.]+)/i, /(uc\s?browser)[\/\s]?([\w\.]+)/i,
/ucweb.+(ucbrowser)[\/\s]?([\w\.]+)/i, /ucweb.+(ucbrowser)[\/\s]?([\w\.]+)/i,
/JUC.+(ucweb)[\/\s]?([\w\.]+)/i /juc.+(ucweb)[\/\s]?([\w\.]+)/i
// UCBrowser // UCBrowser
], [[NAME, 'UCBrowser'], VERSION], [ ], [[NAME, 'UCBrowser'], VERSION], [
@ -306,7 +306,7 @@
/((?:android.+)crmo|crios)\/([\w\.]+)/i // Chrome for Android/iOS /((?:android.+)crmo|crios)\/([\w\.]+)/i // Chrome for Android/iOS
], [[NAME, 'Chrome'], VERSION], [ ], [[NAME, 'Chrome'], VERSION], [
/FBAV\/([\w\.]+);/i // Facebook App for iOS /;fbav\/([\w\.]+);/i // Facebook App for iOS
], [VERSION, [NAME, 'Facebook']], [ ], [VERSION, [NAME, 'Facebook']], [
/fxios\/([\w\.-]+)/i // Firefox for iOS /fxios\/([\w\.-]+)/i // Firefox for iOS