OLD | NEW |
1 Platform | 1 # Platform.js <sup>v1.0.0</sup> |
2 ======== | |
3 | 2 |
4 Aggregated polyfills the Polymer platform. | 3 A platform detection library that works on nearly all JavaScript platforms<sup><
a name="fnref1" href="#fn1">1</a></sup>. |
| 4 |
| 5 ## Disclaimer |
| 6 |
| 7 Platform.js is for informational purposes only and **not** intended as a substit
ution for [feature detection/inference](http://allyoucanleet.com/post/1808721041
3/feature-testing-costs#screencast2) checks. |
| 8 |
| 9 ## BestieJS |
| 10 |
| 11 Platform.js is part of the BestieJS *"Best in Class"* module collection. This me
ans we promote solid browser/environment support, ES5 precedents, unit testing,
and plenty of documentation. |
| 12 |
| 13 ## Documentation |
| 14 |
| 15 The documentation for Platform.js can be viewed here: [/doc/README.md](https://g
ithub.com/bestiejs/platform.js/blob/master/doc/README.md#readme) |
| 16 |
| 17 For a list of upcoming features, check out our [roadmap](https://github.com/best
iejs/platform.js/wiki/Roadmap). |
| 18 |
| 19 ## Support |
| 20 |
| 21 Platform.js has been tested in at least Adobe AIR 3.1, Chrome 5-21, Firefox 1.5-
13, IE 6-9, Opera 9.25-12.01, Safari 3-6, Node.js 0.8.6, Narwhal 0.3.2, RingoJS
0.8, and Rhino 1.7RC5. |
| 22 |
| 23 ## Installation and usage |
| 24 |
| 25 In a browser or Adobe AIR: |
| 26 |
| 27 ```html |
| 28 <script src="platform.js"></script> |
| 29 ``` |
| 30 |
| 31 Via [npm](http://npmjs.org/): |
| 32 |
| 33 ```bash |
| 34 npm install platform |
| 35 ``` |
| 36 |
| 37 In [Node.js](http://nodejs.org/) and [RingoJS](http://ringojs.org/): |
| 38 |
| 39 ```js |
| 40 var platform = require('platform'); |
| 41 ``` |
| 42 |
| 43 In [Rhino](http://www.mozilla.org/rhino/): |
| 44 |
| 45 ```js |
| 46 load('platform.js'); |
| 47 ``` |
| 48 |
| 49 In an AMD loader like [RequireJS](http://requirejs.org/): |
| 50 |
| 51 ```js |
| 52 require({ |
| 53 'paths': { |
| 54 'platform': 'path/to/platform' |
| 55 } |
| 56 }, |
| 57 ['platform'], function(platform) { |
| 58 console.log(platform.name); |
| 59 }); |
| 60 ``` |
| 61 |
| 62 Usage example: |
| 63 |
| 64 ```js |
| 65 // on IE10 x86 platform preview running in IE7 compatibility mode on Windows 7 6
4 bit edition |
| 66 platform.name; // 'IE' |
| 67 platform.version; // '10.0' |
| 68 platform.layout; // 'Trident' |
| 69 platform.os; // 'Windows Server 2008 R2 / 7 x64' |
| 70 platform.description; // 'IE 10.0 x86 (platform preview; running in IE 7 mode) o
n Windows Server 2008 R2 / 7 x64' |
| 71 |
| 72 // or on an iPad |
| 73 platform.name; // 'Safari' |
| 74 platform.version; // '5.1' |
| 75 platform.product; // 'iPad' |
| 76 platform.manufacturer; // 'Apple' |
| 77 platform.layout; // 'WebKit' |
| 78 platform.os; // 'iOS 5.0' |
| 79 platform.description; // 'Safari 5.1 on Apple iPad (iOS 5.0)' |
| 80 |
| 81 // or parsing a given UA string |
| 82 var info = platform.parse('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7.2; en; rv
:2.0) Gecko/20100101 Firefox/4.0 Opera 11.52'); |
| 83 info.name; // 'Opera' |
| 84 info.version; // '11.52' |
| 85 info.layout; // 'Presto' |
| 86 info.os; // 'Mac OS X 10.7.2' |
| 87 info.description; // 'Opera 11.52 (identifying as Firefox 4.0) on Mac OS X 10.7.
2' |
| 88 ``` |
| 89 |
| 90 ## Author |
| 91 |
| 92 * [John-David Dalton](http://allyoucanleet.com/) |
| 93 [](https://twitter.com/jdalton "Follow @jdalton on Twitter") |
| 94 |
| 95 ## Contributors |
| 96 |
| 97 * [Mathias Bynens](http://mathiasbynens.be/) |
| 98 [](https://twitter.com/mathias "Follow @mathias on Twitter") |
OLD | NEW |