mirror of
https://github.com/faisalman/ua-parser-js.git
synced 2025-09-27 16:08:47 +03:00
213 lines
6.1 KiB
HTML
213 lines
6.1 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<title>UA-Parser.js - Lightweight JavaScript-based User Agent String Parser</title>
|
|
<meta name="author" content="Faisalman" />
|
|
<meta name="description" content="UA-Parser.js is a lightweight JavaScript-based user-agent string parser library" />
|
|
<meta name="keywords" content="user agent, parser, javascript, detect, details, new, browser, engine, mobile, device, operating system" />
|
|
<link href='http://fonts.googleapis.com/css?family=Ubuntu+Mono|Varela|Varela+Round' rel='stylesheet' type='text/css'>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
html, input, select {
|
|
font: 14px/20px Varela, Georgia, Helvetica, Ubuntu, Arial, sans-serif;
|
|
color: #333;
|
|
}
|
|
body {
|
|
background: #fff;
|
|
margin: 0 auto;
|
|
padding: 50px 20px 20px;
|
|
width: 960px;
|
|
text-align: center;
|
|
}
|
|
header, section, footer {
|
|
padding: 20px 0 0;
|
|
position: relative;
|
|
}
|
|
h1 a {
|
|
text-decoration: none;
|
|
color: #333;
|
|
}
|
|
h1 {
|
|
margin-bottom: 30px;
|
|
font-size: 4em;
|
|
}
|
|
h1, h2, th, .ua {
|
|
font-family: 'Varela Round', Helvetica, Ubuntu, Arial, sans-serif;
|
|
}
|
|
.share {
|
|
position: absolute;
|
|
width: 100px;
|
|
height: 20px;
|
|
top: 60px;
|
|
right: 0;
|
|
}
|
|
pre {
|
|
margin: 0 0 20px;
|
|
padding: 10px;
|
|
background: #f0f0f0;
|
|
white-space: pre-wrap;
|
|
overflow: auto;
|
|
}
|
|
table {
|
|
border-spacing: 0;
|
|
margin: auto;
|
|
width: 100%;
|
|
}
|
|
th {
|
|
font-size: 2em;
|
|
}
|
|
th, td {
|
|
border-left: 1px solid #fff;
|
|
border-top: 1px solid #fff;
|
|
min-width: 100px;
|
|
padding: 20px;
|
|
text-align: center;
|
|
}
|
|
tr:last-child th, tr:last-child td {
|
|
border-bottom: 1px solid #ccc;
|
|
}
|
|
th:last-child, td:last-child {
|
|
border-right: 1px solid #fff;
|
|
}
|
|
td {
|
|
color: red;
|
|
}
|
|
select, input, .grey {
|
|
color: #777;
|
|
width: 100%;
|
|
}
|
|
select, input {
|
|
border: 1px solid #ccc;
|
|
height: 30px;
|
|
box-shadow: inset 0 0 10px #ccc;
|
|
}
|
|
hr {
|
|
border: 0;
|
|
margin: 20px 0;
|
|
}
|
|
p {
|
|
margin: 10px 0;
|
|
}
|
|
pre, code {
|
|
font-family: 'Ubuntu Mono', monospace;
|
|
}
|
|
.ua {
|
|
font-size: 1.5em;
|
|
}
|
|
</style>
|
|
<script src="ua-parser.js"></script>
|
|
<script src="ua-list-example.js"></script>
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<h1><a href="">UA-Parser.js</a></h1>
|
|
<h2>Lightweight JavaScript-based User-Agent String Parser</h2>
|
|
<hr />
|
|
<p class="share">
|
|
<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>
|
|
</p>
|
|
</header>
|
|
<section>
|
|
<pre>
|
|
</pre>
|
|
<table>
|
|
<tr>
|
|
<th>Browser</th>
|
|
<th>Engine</th>
|
|
<th>OS</th>
|
|
<th>Device</th>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td></td>
|
|
<td></td>
|
|
<td></td>
|
|
</tr>
|
|
<td></td>
|
|
<td></td>
|
|
<td></td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</section>
|
|
<section>
|
|
<p>Wanna test other UA string? Select a user-agent string to be tested:</p>
|
|
<select>
|
|
<option>Pick one</option>
|
|
</select>
|
|
<p>Wanna test more? Enter any user-agent string you want to test here:</p>
|
|
<input type="text" />
|
|
</section>
|
|
<footer>
|
|
<hr />
|
|
<p>
|
|
<span class="ua">UA-Parser.js</span> © 2012 Faisalman. <br/>
|
|
Dual licensed under GPLv2 & MIT license<br/>
|
|
Source: <a href="https://github.com/faisalman/ua-parser-js">https://github.com/faisalman/ua-parser-js</a><br/>
|
|
Node.js package: <a href="https://npmjs.org/package/ua-parser-js">https://npmjs.org/package/ua-parser-js</a>
|
|
</p>
|
|
</footer>
|
|
<script>
|
|
var pre = document.getElementsByTagName('pre')[0];
|
|
var sel = document.getElementsByTagName('select')[0];
|
|
var txt = document.getElementsByTagName('input')[0];
|
|
var parser = new UAParser();
|
|
var fill = function(el, prop){
|
|
if(prop !== undefined){
|
|
el.innerHTML = prop;
|
|
el.style.color = "red";
|
|
} else {
|
|
el.innerHTML = "No data";
|
|
el.style.color = "#aaa";
|
|
}
|
|
}
|
|
for(var i = 0; i < uaExampleList.length; i++){
|
|
var opt = document.createElement('option');
|
|
opt.innerHTML = uaExampleList[i];
|
|
sel.appendChild(opt);
|
|
}
|
|
var fillTable = function(uastring){
|
|
parser.setUA(uastring);
|
|
var browser = parser.getBrowser();
|
|
var engine = parser.getEngine();
|
|
var os = parser.getOS();
|
|
var device = parser.getDevice();
|
|
var tbl = document.getElementsByTagName('td');
|
|
fill(tbl[0], browser.name);
|
|
fill(tbl[1], engine.name);
|
|
fill(tbl[2], os.name);
|
|
fill(tbl[3], device.name);
|
|
fill(tbl[4], browser.version);
|
|
fill(tbl[5], engine.version);
|
|
fill(tbl[6], os.version);
|
|
fill(tbl[7], device.version);
|
|
pre.innerHTML = 'Result for <span style="color:red">' + (uastring ? uastring.replace(/</g,'<') : 'your browser\'s user-agent string') + ' :</span>';
|
|
}
|
|
fillTable();
|
|
sel.addEventListener('change', function(){
|
|
fillTable(sel.children[sel.selectedIndex].value);
|
|
});
|
|
txt.addEventListener('keydown', function(e){
|
|
if(e.keyCode == 13){
|
|
fillTable(this.value);
|
|
return false;
|
|
}
|
|
});
|
|
</script>
|
|
<script type="text/javascript">
|
|
var _gaq = _gaq || [];
|
|
_gaq.push(['_setAccount', 'UA-3767301-5']);
|
|
_gaq.push(['_trackPageview']);
|
|
(function() {
|
|
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
|
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
|
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
|
})();
|
|
</script>
|
|
</body>
|
|
</html>
|