Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

readme.md 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <p align="center">
  2. <img src="https://raw.githubusercontent.com/faisalman/ua-parser-js/gh-pages/images/logo.png" width="256" height="256">
  3. </p>
  4. <p align="center">
  5. <a href="https://travis-ci.org/faisalman/ua-parser-js"><img src="https://travis-ci.org/faisalman/ua-parser-js.svg?branch=master"></a>
  6. <a href="https://www.npmjs.com/package/ua-parser-js"><img src="https://img.shields.io/npm/v/ua-parser-js.svg"></a>
  7. <a href="https://www.npmjs.com/package/ua-parser-js"><img src="https://img.shields.io/npm/dw/ua-parser-js.svg"></a>
  8. <a href="https://www.jsdelivr.com/package/npm/ua-parser-js"><img src="https://data.jsdelivr.com/v1/package/npm/ua-parser-js/badge"></a>
  9. <a href="https://cdnjs.com/libraries/UAParser.js"><img src="https://img.shields.io/cdnjs/v/UAParser.js.svg"></a>
  10. </p>
  11. # UAParser.js
  12. JavaScript library to detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data with relatively small footprint (~17KB minified, ~6KB gzipped) that can be used either in browser (client-side) or node.js (server-side).
  13. * Author : Faisal Salman <<f@faisalman.com>>
  14. * Demo : http://faisalman.github.io/ua-parser-js
  15. * Source : https://github.com/faisalman/ua-parser-js
  16. # Documentation
  17. ## Constructor
  18. * `new UAParser([uastring][,extensions])`
  19. * returns new instance
  20. * `UAParser([uastring][,extensions])`
  21. * returns result object `{ ua: '', browser: {}, cpu: {}, device: {}, engine: {}, os: {} }`
  22. ## Methods
  23. * `getBrowser()`
  24. * returns `{ name: '', version: '' }`
  25. ```sh
  26. # Possible 'browser.name':
  27. 2345Explorer, 360 Browser, Amaya, Android Browser, Arora, Avant, Avast, AVG,
  28. BIDUBrowser, Baidu, Basilisk, Blazer, Bolt, Brave, Bowser, Camino, Chimera,
  29. Chrome Headless, Chrome WebView, Chrome, Chromium, Comodo Dragon, Dillo,
  30. Dolphin, Doris, Edge, Electron, Epiphany, Facebook, Falkon, Fennec, Firebird,
  31. Firefox [Reality], Flock, Flow, GSA, GoBrowser, ICE Browser, IE, IEMobile, IceApe,
  32. IceCat, IceDragon, Iceweasel, Instagram, Iridium, Iron, Jasmine, K-Meleon,
  33. Kindle, Konqueror, LBBROWSER, Line, Links, Lunascape, Lynx, MIUI Browser,
  34. Maemo Browser, Maemo, Maxthon, MetaSr Midori, Minimo, Mobile Safari, Mosaic,
  35. Mozilla, NetFront, NetSurf, Netfront, Netscape, NokiaBrowser, Oculus Browser,
  36. OmniWeb, Opera Coast, Opera [Mini/Mobi/Tablet], PaleMoon, PhantomJS, Phoenix,
  37. Polaris, Puffin, QQ, QQBrowser, QQBrowserLite, Quark, QupZilla, RockMelt, Safari,
  38. Sailfish Browser, Samsung Browser, SeaMonkey, Silk, Skyfire, Sleipnir, Slim,
  39. SlimBrowser, Swiftfox, Tesla, Tizen Browser, UCBrowser, Vivaldi, Waterfox, WeChat,
  40. Weibo, Yandex, baidu, iCab, w3m, Whale Browser...
  41. # 'browser.version' determined dynamically
  42. ```
  43. * `getDevice()`
  44. * returns `{ model: '', type: '', vendor: '' }`
  45. ```sh
  46. # Possible 'device.type':
  47. console, mobile, tablet, smarttv, wearable, embedded
  48. # Possible 'device.vendor':
  49. Acer, Alcatel, Amazon, Apple, Archos, ASUS, AT&T, BenQ, BlackBerry, Dell,
  50. Essential, Fairphone, GeeksPhone, Google, HP, HTC, Huawei, Jolla, Lenovo, LG,
  51. Meizu, Microsoft, Motorola, Nexian, Nintendo, Nokia, Nvidia, OnePlus, OPPO, Ouya,
  52. Palm, Panasonic, Pebble, Polytron, Realme, RIM, Samsung, Sharp, Siemens,
  53. Sony[Ericsson], Sprint, Tesla, Vivo, Vodafone, Xbox, Xiaomi, Zebra, ZTE, ...
  54. # 'device.model' determined dynamically
  55. ```
  56. * `getEngine()`
  57. * returns `{ name: '', version: '' }`
  58. ```sh
  59. # Possible 'engine.name'
  60. Amaya, Blink, EdgeHTML, Flow, Gecko, Goanna, iCab, KHTML, Links, Lynx, NetFront,
  61. NetSurf, Presto, Tasman, Trident, w3m, WebKit
  62. # 'engine.version' determined dynamically
  63. ```
  64. * `getOS()`
  65. * returns `{ name: '', version: '' }`
  66. ```sh
  67. # Possible 'os.name'
  68. AIX, Amiga OS, Android, Arch, Bada, BeOS, BlackBerry, CentOS, Chromium OS,
  69. Contiki, Fedora, Firefox OS, FreeBSD, Debian, DragonFly, Fuchsia, Gentoo, GNU,
  70. Haiku, Hurd, iOS, Joli, KaiOS, Linpus, Linux, Mac OS, Mageia, Mandriva, MeeGo,
  71. Minix, Mint, Morph OS, NetBSD, Nintendo, OpenBSD, OpenVMS, OS/2, Palm, PC-BSD,
  72. PCLinuxOS, Plan9, PlayStation, QNX, Raspbian, RedHat, RIM Tablet OS, RISC OS,
  73. Sailfish, Series40, Slackware, Solaris, SUSE, Symbian, Tizen, Ubuntu, Unix,
  74. VectorLinux, WebOS, Windows [Phone/Mobile], Zenwalk, ...
  75. # 'os.version' determined dynamically
  76. ```
  77. * `getCPU()`
  78. * returns `{ architecture: '' }`
  79. ```sh
  80. # Possible 'cpu.architecture'
  81. 68k, amd64, arm[64/hf], avr, ia[32/64], irix[64], mips[64], pa-risc, ppc, sparc[64]
  82. ```
  83. * `getResult()`
  84. * returns `{ ua: '', browser: {}, cpu: {}, device: {}, engine: {}, os: {} }`
  85. * `getUA()`
  86. * returns UA string of current instance
  87. * `setUA(uastring)`
  88. * set UA string to be parsed
  89. * returns current instance
  90. # Usage
  91. ## Using HTML
  92. ```html
  93. <!doctype html>
  94. <html>
  95. <head>
  96. <script src="ua-parser.min.js"></script>
  97. <script>
  98. var parser = new UAParser();
  99. console.log(parser.getResult());
  100. /*
  101. /// This will print an object structured like this:
  102. {
  103. ua: "",
  104. browser: {
  105. name: "",
  106. version: "",
  107. major: "" //@deprecated
  108. },
  109. engine: {
  110. name: "",
  111. version: ""
  112. },
  113. os: {
  114. name: "",
  115. version: ""
  116. },
  117. device: {
  118. model: "",
  119. type: "",
  120. vendor: ""
  121. },
  122. cpu: {
  123. architecture: ""
  124. }
  125. }
  126. */
  127. // Default result depends on current window.navigator.userAgent value
  128. // Now let's try a custom user-agent string as an example
  129. var uastring1 = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.2 (KHTML, like Gecko) Ubuntu/11.10 Chromium/15.0.874.106 Chrome/15.0.874.106 Safari/535.2";
  130. parser.setUA(uastring1);
  131. var result = parser.getResult();
  132. // You can also use UAParser constructor directly without having to create an instance:
  133. // var result = UAParser(uastring1);
  134. console.log(result.browser); // {name: "Chromium", version: "15.0.874.106"}
  135. console.log(result.device); // {model: undefined, type: undefined, vendor: undefined}
  136. console.log(result.os); // {name: "Ubuntu", version: "11.10"}
  137. console.log(result.os.version); // "11.10"
  138. console.log(result.engine.name); // "WebKit"
  139. console.log(result.cpu.architecture); // "amd64"
  140. // Do some other tests
  141. var uastring2 = "Mozilla/5.0 (compatible; Konqueror/4.1; OpenBSD) KHTML/4.1.4 (like Gecko)";
  142. console.log(parser.setUA(uastring2).getBrowser().name); // "Konqueror"
  143. console.log(parser.getOS()); // {name: "OpenBSD", version: undefined}
  144. console.log(parser.getEngine()); // {name: "KHTML", version: "4.1.4"}
  145. var uastring3 = 'Mozilla/5.0 (PlayBook; U; RIM Tablet OS 1.0.0; en-US) AppleWebKit/534.11 (KHTML, like Gecko) Version/7.1.0.7 Safari/534.11';
  146. console.log(parser.setUA(uastring3).getDevice().model); // "PlayBook"
  147. console.log(parser.getOS()) // {name: "RIM Tablet OS", version: "1.0.0"}
  148. console.log(parser.getBrowser().name); // "Safari"
  149. </script>
  150. </head>
  151. <body>
  152. </body>
  153. </html>
  154. ```
  155. ## Using node.js
  156. ```sh
  157. $ npm install ua-parser-js
  158. ```
  159. ```js
  160. var http = require('http');
  161. var parser = require('ua-parser-js');
  162. http.createServer(function (req, res) {
  163. // get user-agent header
  164. var ua = parser(req.headers['user-agent']);
  165. // write the result as response
  166. res.end(JSON.stringify(ua, null, ' '));
  167. })
  168. .listen(1337, '127.0.0.1');
  169. console.log('Server running at http://127.0.0.1:1337/');
  170. ```
  171. ## Using TypeScript
  172. ```sh
  173. $ npm install --save @types/ua-parser-js
  174. # Download TS type definition from DefinitelyTyped repository:
  175. # https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ua-parser-js
  176. ```
  177. ## Using jQuery/Zepto ($.ua)
  178. Although written in vanilla js, this library will automatically detect if jQuery/Zepto is present and create `$.ua` object (with values based on its User-Agent) along with `window.UAParser` constructor. To get/set user-agent you can use: `$.ua.get()` / `$.ua.set(uastring)`.
  179. ```js
  180. // Say we are in a browser with default user-agent: 'Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; Sprint APA7373KT Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0':
  181. // Get the details
  182. console.log($.ua.device); // {vendor: "HTC", model: "Evo Shift 4G", type: "mobile"}
  183. console.log($.ua.os); // {name: "Android", version: "2.3.4"}
  184. console.log($.ua.os.name); // "Android"
  185. console.log($.ua.get()); // "Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; Sprint APA7373KT Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0"
  186. // Now lets try to reset to another custom user-agent
  187. $.ua.set('Mozilla/5.0 (Linux; U; Android 3.0.1; en-us; Xoom Build/HWI69) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13');
  188. // Test again
  189. console.log($.ua.browser.name); // "Safari"
  190. console.log($.ua.engine.name); // "Webkit"
  191. console.log($.ua.device); // {vendor: "Motorola", model: "Xoom", type: "tablet"}
  192. console.log(parseInt($.ua.browser.version.split('.')[0], 10)); // 4
  193. // Add class to <body> tag
  194. // <body class="ua-browser-safari ua-devicetype-tablet">
  195. $('body').addClass('ua-browser-' + $.ua.browser.name + ' ua-devicetype-' + $.ua.device.type);
  196. ```
  197. ## Using Extension
  198. * `UAParser([uastring,] extensions)`
  199. ```js
  200. // Example:
  201. var myOwnListOfBrowsers = [
  202. [/(mybrowser)\/([\w\.]+)/i], [UAParser.BROWSER.NAME, UAParser.BROWSER.VERSION]
  203. ];
  204. var myParser = new UAParser({ browser: myOwnListOfBrowsers });
  205. var myUA = 'Mozilla/5.0 MyBrowser/1.3';
  206. console.log(myParser.setUA(myUA).getBrowser()); // {name: "MyBrowser", version: "1.3"}
  207. ```
  208. # Development
  209. ## Sponsors
  210. <a href="https://opencollective.com/ua-parser-js"><img src="https://opencollective.com/ua-parser-js/tiers/backers.svg?avatarHeight=64" height="80"/></a> <a href="https://opencollective.com/ua-parser-js"><img src="https://opencollective.com/ua-parser-js/tiers/sponsors.svg?avatarHeight=64" height="80"/></a>
  211. <a href="https://www.paypal.me/faisalman/"><img src="https://cdn.rawgit.com/twolfson/paypal-github-button/1.0.0/dist/button.svg" height="40"></a>
  212. ## Contributors
  213. <a href="https://github.com/faisalman/ua-parser-js/graphs/contributors">
  214. <img src="https://contrib.rocks/image?repo=faisalman/ua-parser-js" />
  215. </a>
  216. Made with [contributors-img](https://contrib.rocks).
  217. ## How To Contribute
  218. * Fork and clone this repository
  219. * Make some changes as required
  220. * Write unit test to showcase its functionality
  221. * Run the test suites to make sure it's not breaking anything `$ npm test`
  222. * Submit a pull request under `develop` branch
  223. # License
  224. MIT License
  225. Copyright (c) 2012-2021 Faisal Salman <<f@faisalman.com>>
  226. Permission is hereby granted, free of charge, to any person obtaining a copy
  227. of this software and associated documentation files (the "Software"), to deal
  228. in the Software without restriction, including without limitation the rights
  229. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  230. copies of the Software, and to permit persons to whom the Software is
  231. furnished to do so, subject to the following conditions:
  232. The above copyright notice and this permission notice shall be included in all
  233. copies or substantial portions of the Software.
  234. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  235. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  236. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  237. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  238. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  239. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  240. SOFTWARE.