mirror of
https://github.com/faisalman/ua-parser-js.git
synced 2025-09-27 16:08:47 +03:00
Update code to new method & add some mobile devices ua to examples
This commit is contained in:
parent
d1c68cf71b
commit
1998b5e582
17
index.html
17
index.html
@ -99,7 +99,6 @@
|
|||||||
<h1>UA-Parser.js</h1>
|
<h1>UA-Parser.js</h1>
|
||||||
<h2>JavaScript-based User-Agent Parser</h2>
|
<h2>JavaScript-based User-Agent Parser</h2>
|
||||||
<hr />
|
<hr />
|
||||||
<p class="grey">A small, quick & dirty script, which aims to extract a long piece of information about the details of the system contained in a user-agent string, into some small yet valuable pieces of commonly needed information such as the name of the browser & operating system along with the version</p>
|
|
||||||
<p class="share">
|
<p class="share">
|
||||||
<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="fyzlman">Tweet</a>
|
<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="fyzlman">Tweet</a>
|
||||||
<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
|
<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
|
||||||
@ -113,15 +112,18 @@
|
|||||||
<th>Browser</th>
|
<th>Browser</th>
|
||||||
<th>Engine</th>
|
<th>Engine</th>
|
||||||
<th>OS</th>
|
<th>OS</th>
|
||||||
|
<th>Device</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</section>
|
</section>
|
||||||
@ -136,7 +138,7 @@
|
|||||||
<footer>
|
<footer>
|
||||||
<hr />
|
<hr />
|
||||||
<p>
|
<p>
|
||||||
<span class="ua">UA-Parser.js</span> © 2012 Faisalman. Licensed under GPLv2. Download & Fork @
|
<span class="ua">UA-Parser.js</span> © 2012 Faisalman. Licensed under GPLv2 & MIT. Download & Fork @
|
||||||
<a href="https://github.com/faisalman/ua-parser-js">https://github.com/faisalman/ua-parser-js</a>
|
<a href="https://github.com/faisalman/ua-parser-js">https://github.com/faisalman/ua-parser-js</a>
|
||||||
</p>
|
</p>
|
||||||
</footer>
|
</footer>
|
||||||
@ -150,17 +152,20 @@
|
|||||||
sel.appendChild(opt);
|
sel.appendChild(opt);
|
||||||
}
|
}
|
||||||
var fillTable = function(uastring){
|
var fillTable = function(uastring){
|
||||||
var parser = new uaparser(uastring);
|
var parser = UAParser.setUA(uastring);
|
||||||
var browser = parser.getBrowser();
|
var browser = parser.getBrowser();
|
||||||
var engine = parser.getEngine();
|
var engine = parser.getEngine();
|
||||||
var os = parser.getOS();
|
var os = parser.getOS();
|
||||||
|
var device = parser.getDevice();
|
||||||
var tbl = document.getElementsByTagName('td');
|
var tbl = document.getElementsByTagName('td');
|
||||||
tbl[0].innerText = browser.name;
|
tbl[0].innerText = browser.name;
|
||||||
tbl[1].innerText = engine.name;
|
tbl[1].innerText = engine.name;
|
||||||
tbl[2].innerText = os.name;
|
tbl[2].innerText = os.name;
|
||||||
tbl[3].innerText = browser.version;
|
tbl[3].innerText = device.name;
|
||||||
tbl[4].innerText = engine.version;
|
tbl[4].innerText = browser.version;
|
||||||
tbl[5].innerText = os.version;
|
tbl[5].innerText = engine.version;
|
||||||
|
tbl[6].innerText = os.version;
|
||||||
|
tbl[7].innerText = device.version;
|
||||||
pre.innerHTML = 'Result for <strong>' + (uastring ? uastring.replace(/</g,'<') : 'your browser\'s user-agent string') + ' :</strong>';
|
pre.innerHTML = 'Result for <strong>' + (uastring ? uastring.replace(/</g,'<') : 'your browser\'s user-agent string') + ' :</strong>';
|
||||||
}
|
}
|
||||||
fillTable();
|
fillTable();
|
||||||
|
@ -1,6 +1,19 @@
|
|||||||
// Only used for testing purpose
|
// Only used for testing purpose
|
||||||
|
|
||||||
var uaExampleList = [
|
var uaExampleList = [
|
||||||
|
"Mozilla/5.0 (Linux; U; Android 3.0.1; de-de; Transformer TF101 Build/HRI66) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13",
|
||||||
|
"Nokia5238/40.9.003 (SymbianOS/9.4; U; Series60/5.0 Mozilla/5.0; Profile/MIDP-2.1 Configuration/CLDC-1.1 ) AppleWebKit/525 (KHTML, like Gecko) Safari/525 3gpp-gba",
|
||||||
|
"Mozilla/5.0 (Linux; U; Android 2.2.1; zh-cn; ZTE Jewe Build/1D7C2) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
|
||||||
|
"Mozilla/5.0 (iPad; CPU OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.0.2 Mobile/9A5259f Safari/6533.18.5",
|
||||||
|
"Mozilla/5.0 (Linux; U; Android 3.1; en-us; Xoom Build/HMJ37) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13",
|
||||||
|
"Mozilla/5.0 (BlackBerry; U; BlackBerry 9860; en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/6.1.0.76 Mobile Safari/534.11+",
|
||||||
|
"Mozilla/5.0 (Linux; U; Android 2.2.1; en-us; Dell Streak 7 Build/FRG83) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
|
||||||
|
"Mozilla/5.0 (hp-tablet; Linux; hpwOS/3.0.0; U; en-US) AppleWebKit/534.6 (KHTML, like Gecko) wOSBrowser/233.48 Safari/534.6 TouchPad/1.0",
|
||||||
|
"Mozilla/5.0 (Linux; U; Android 2.2; ja-jp; E140 Build/Froyo) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1ACER_E140/1.0",
|
||||||
|
"Mozilla/4.0 (compatible: MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; SAMSUNG; SGH-i917)",
|
||||||
|
"Mozilla/5.0 (Linux; U; Android 2.3.5; en-us; Nexus S 4G Build/GRJ90) AppleWebKit/533.1+ (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
|
||||||
|
"Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; NOKIA; Lumia 800)",
|
||||||
|
"Mozilla/5.0 (webOS/1.0; U; en-US) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/1.0 Safari/525.27.1 Pre/1.0",
|
||||||
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en; rv:1.9.0.19) Gecko/2010111021 Camino/2.0.6 (MultiLang) (like Firefox/3.0.19)",
|
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en; rv:1.9.0.19) Gecko/2010111021 Camino/2.0.6 (MultiLang) (like Firefox/3.0.19)",
|
||||||
"Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/534.20 (KHTML, like Gecko) Chrome/11.0.672.2 Safari/534.20",
|
"Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/534.20 (KHTML, like Gecko) Chrome/11.0.672.2 Safari/534.20",
|
||||||
"Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.7 (KHTML, like Gecko) Ubuntu/11.10 Chromium/16.0.912.21 Chrome/16.0.912.21 Safari/535.7",
|
"Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.7 (KHTML, like Gecko) Ubuntu/11.10 Chromium/16.0.912.21 Chrome/16.0.912.21 Safari/535.7",
|
||||||
@ -40,4 +53,4 @@ var uaExampleList = [
|
|||||||
"Mozilla/4.5 (compatible; iCab 2.9.1; Macintosh; U; PPC)",
|
"Mozilla/4.5 (compatible; iCab 2.9.1; Macintosh; U; PPC)",
|
||||||
"Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.10pre) Gecko/2009041814 Firefox/3.0.10pre (Swiftfox)",
|
"Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.10pre) Gecko/2009041814 Firefox/3.0.10pre (Swiftfox)",
|
||||||
"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; Avant Browser; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)"
|
"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; Avant Browser; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)"
|
||||||
];
|
];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user