Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit fd082080c0ea43c67f51032ee0a383f0ea65fef4 @LeaVerou committed Jun 10, 2013
@@ -0,0 +1 @@
+dpi.lv
@@ -0,0 +1,149 @@
+var hashRegex = /^#(\d+)[x×](\d+)(@(\d*\.?\d+)["″])?|(\d*\.?\d+)["″]$/;
+
+width.value = screen.width;
+height.value = screen.height;
+
+var output = $('output');
+
+function update() {
+ var w = width.value,
+ h = height.value;
+
+ d = Math.sqrt(w*w + h*h);
+
+ var dpi = dimension.value == 'd'? d : dimension.value == 'w'? w : h;
+
+ dpi /= physical.value;
+
+ result.textContent = Math.round(dpi);
+
+ // Size the output to have the same aspect ratio as the screen
+ var ratio = w/h;
+
+ output.style.minWidth = result.parentNode.offsetWidth;
+
+ if (ratio > 1) {
+ output.style.width = '';
+ }
+ else {
+ output.style.width = '10em';
+ }
+
+ output.style.height = output.offsetWidth / ratio + 'px';
+}
+
+dimension.onchange = update;
+
+$$('fieldset input').forEach(function(element) {
+ (element.oninput = function () {
+ this.style.width = this.value.length + 'ch';
+ update();
+ }).call(element);
+});
+
+$$('#resolutions a, #diagonals a').forEach(function(a) {
+ a.href = '#' + a.textContent;
+});
+
+$u.xhr({
+ url: 'screens.json',
+ callback: function (xhr) {
+ window.Devices = JSON.parse(xhr.responseText);
+
+ var fragment = document.createDocumentFragment();
+
+ Devices.forEach(function (device) {
+ deviceRow(device, fragment);
+ });
+
+ var tbody = $('table tbody', devices);
+
+ tbody.innerHTML = '';
+
+ tbody.appendChild(fragment);
+ }
+});
+
+function deviceRow(device, fragment) {
+ return $u.element.create('tr', {
+ contents: [
+ {
+ tag: 'th',
+ contents: {
+ tag: 'a',
+ properties: {
+ href: '#' + device.w + '×' + device.h + '@' + device.d + ''
+ },
+ contents: device.name
+ }
+ }, {
+ tag: 'td',
+ contents: device.d + ''
+ }, {
+ tag: 'td',
+ contents: device.w + '×' + device.h
+ }, {
+ tag: 'td',
+ contents: device.ppi
+ }
+ ],
+ inside: fragment
+ });
+}
+
+
+(window.onhashchange = function() {
+ if (hashRegex.test(location.hash)) {
+ var matches = location.hash.match(hashRegex);
+
+ if (matches[1]) {
+ width.value = matches[1]
+ width.oninput();
+ }
+
+ if (matches[2]) {
+ height.value = matches[2];
+ height.oninput();
+ }
+
+ if (matches[3] || matches[5]) {
+ if (matches[3]) {
+ physical.value = matches[4];
+ }
+
+ if (matches[5]) {
+ physical.value = matches[5];
+ }
+
+ dimension.value = 'd';
+ physical.oninput();
+ }
+ }
+})();
+
+search.oninput = function() {
+ if (!window.Devices) {
+ return;
+ }
+
+ var term = this.value;
+
+ var fragment = document.createDocumentFragment(),
+ results = 0;
+
+ Devices.forEach(function (device) {
+ for (var i in device) {
+ if ((device[i] + '').toLowerCase().indexOf(term.toLowerCase()) > -1) {
+ deviceRow(device, fragment);
+ results++;
+ return;
+ }
+ }
+ });
+
+ var tbody = $('table tbody', devices);
+
+ tbody.innerHTML = results? '' : '<tr><td colspan="4">No results</td></tr>';
+
+ tbody.appendChild(fragment);
+};
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="utf-8"?>
+<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 270 250">
+
+<defs>
+ <rect stroke="white" stroke-width="2" stroke-miterlimit="10" width="16" height="16" id="base-pixel" />
+
+ <use xlink:href="#base-pixel" fill="white" id="glow-pixel" />
+ <use xlink:href="#base-pixel" fill="red" id="pixel" />
+
+ <circle cx="102" cy="100" r="83" fill="none" id="magnifier" />
+</defs>
+
+<!-- Heart -->
+<path fill="red" d="M200.71,34.103c-9.912,0-19.285,2.294-27.624,6.376c10.402,15.617,16.47,34.371,16.47,54.542
+ c0,52.631-41.273,95.623-93.219,98.376l48.5,48.501l99.101-99.098c0.862-0.816,1.698-1.653,2.513-2.514l6.139-7.58
+ c6.979-10.137,11.074-22.413,11.074-35.648C263.663,62.289,235.479,34.103,200.71,34.103z"/>
+
+<use xlink:href="#pixel" x="40" y="69" />
+<use xlink:href="#pixel" x="40" y="85" />
+<use xlink:href="#pixel" x="40" y="101" />
+<use xlink:href="#pixel" x="40" y="117" />
+
+<use xlink:href="#pixel" x="56" y="53" />
+<use xlink:href="#pixel" x="56" y="69" />
+<use xlink:href="#pixel" x="56" y="85" />
+<use xlink:href="#pixel" x="56" y="101" />
+<use xlink:href="#pixel" x="56" y="117" />
+<use xlink:href="#pixel" x="56" y="133" />
+
+<use xlink:href="#pixel" x="72" y="37"/>
+<use xlink:href="#pixel" x="72" y="53" />
+<use xlink:href="#glow-pixel" x="72" y="69" />
+<use xlink:href="#glow-pixel" x="72" y="85" />
+<use xlink:href="#pixel" x="72" y="101" />
+<use xlink:href="#pixel" x="72" y="117" />
+<use xlink:href="#pixel" x="72" y="133" />
+<use xlink:href="#pixel" x="72" y="149" />
+
+
+<use xlink:href="#pixel" x="88" y="37"/>
+<use xlink:href="#pixel" x="88" y="53" />
+<use xlink:href="#glow-pixel" x="88" y="69" />
+<use xlink:href="#glow-pixel" x="88" y="85" />
+<use xlink:href="#pixel" x="88" y="101" />
+<use xlink:href="#pixel" x="88" y="117" />
+<use xlink:href="#pixel" x="88" y="133" />
+<use xlink:href="#pixel" x="88" y="149" />
+<use xlink:href="#pixel" x="88" y="165" />
+
+<use xlink:href="#pixel" x="104" y="37"/>
+<use xlink:href="#pixel" x="104" y="53" />
+<use xlink:href="#pixel" x="104" y="69" />
+<use xlink:href="#pixel" x="104" y="85" />
+<use xlink:href="#pixel" x="104" y="101" />
+<use xlink:href="#pixel" x="104" y="117" />
+<use xlink:href="#pixel" x="104" y="133" />
+<use xlink:href="#pixel" x="104" y="149" />
+<use xlink:href="#pixel" x="104" y="165" />
+
+<use xlink:href="#pixel" x="120" y="53" />
+<use xlink:href="#pixel" x="120" y="69" />
+<use xlink:href="#pixel" x="120" y="85" />
+<use xlink:href="#pixel" x="120" y="101" />
+<use xlink:href="#pixel" x="120" y="117" />
+<use xlink:href="#pixel" x="120" y="133" />
+<use xlink:href="#pixel" x="120" y="149" />
+<use xlink:href="#pixel" x="120" y="165" />
+
+<use xlink:href="#pixel" x="136" y="69" />
+<use xlink:href="#pixel" x="136" y="85" />
+<use xlink:href="#pixel" x="136" y="101" />
+<use xlink:href="#pixel" x="136" y="117" />
+<use xlink:href="#pixel" x="136" y="133" />
+<use xlink:href="#pixel" x="136" y="149" />
+
+<use xlink:href="#pixel" x="152" y="53" />
+<use xlink:href="#pixel" x="152" y="69" />
+<use xlink:href="#pixel" x="152" y="85" />
+<use xlink:href="#pixel" x="152" y="101" />
+<use xlink:href="#pixel" x="152" y="117" />
+<use xlink:href="#pixel" x="152" y="133" />
+<use xlink:href="#pixel" x="152" y="149" />
+
+<use xlink:href="#pixel" x="168" y="69" />
+<use xlink:href="#pixel" x="168" y="85" />
+<use xlink:href="#pixel" x="168" y="101" />
+<use xlink:href="#pixel" x="168" y="117" />
+
+<use xlink:href="#magnifier" stroke="white" stroke-width="24" />
+<use xlink:href="#magnifier" stroke="black" stroke-width="16" />
+
+</svg>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
+ <g opacity=".15">
+ <circle cx="45" cy="45" r="30" stroke="black" stroke-width="15" fill="none" />
+ <rect x="90" y="-5" width="40" height="15" fill="black" transform="rotate(45)" />
+ </g>
+</svg>
@@ -0,0 +1,111 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+
+<meta charset="utf-8" />
+<title>DPI.lv ♥ Easily find the DPI/PPI of any screen</title>
+<link rel="stylesheet" href="style.css" />
+<script src="prefixfree.min.js"></script>
+
+</head>
+<body>
+
+<header>
+ <h1>
+ <img src="img/logo.svg" />
+ <strong>dpi</strong>love
+ </h1>
+</header>
+
+<fieldset>
+ Resolution:
+ <input id="width" pattern="\d+" />
+ ×
+ <input id="height" pattern="\d+" />
+
+ <p id="resolutions">Common:
+ <a href="#" tabindex="-1">1920×1080</a>
+ <a href="#" tabindex="-1">1680×1050</a>
+ <a href="#" tabindex="-1">1440×900</a>
+ <a href="#" tabindex="-1">1366×768</a>
+ <a href="#" tabindex="-1">1280×800</a>
+ <a href="#" tabindex="-1">1386×768</a>
+ <a href="#" tabindex="-1">1024×768</a>
+ <a href="#" tabindex="-1">800×600</a>
+ </p>
+</fieldset>
+
+<fieldset>
+ <select id="dimension" title="Physical dimension (in inches)">
+ <option selected value="d">Diagonal</option>
+ <option value="w">Width</option>
+ <option value="h">Height</option>
+ </select>:
+ <input id="physical" value="13.3" pattern="\d*\.?\d+" />″
+
+ <p id="diagonals">Common diagonals:
+ <a href="#" tabindex="-1">7″</a>
+ <a href="#" tabindex="-1">11.6″</a>
+ <a href="#" tabindex="-1">13.3″</a>
+ <a href="#" tabindex="-1">14″</a>
+ <a href="#" tabindex="-1">15.6″</a>
+ <a href="#" tabindex="-1">17.3″</a>
+ <a href="#" tabindex="-1">21″</a>
+ <a href="#" tabindex="-1">27″</a>
+ </p>
+</fieldset>
+
+<output>
+ <div>
+ <strong id="result"></strong>
+ pixels per inch
+ </div>
+</output>
+
+<section id="devices">
+ <h1>Known screens</h1>
+
+ <input type="search" placeholder="Search…" id="search" />
+
+ <div id="screens">
+ <table>
+ <thead>
+ <tr>
+ <th>Name</th>
+ <th>Diagonal</th>
+ <th>Resolution</th>
+ <th>DPI</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td colspan="4">Loading…</td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+</section>
+
+<footer>Handmade by <a href="http://lea.verou.me">Lea Verou</a> with love</footer>
+
+<script src="utopia.js"></script>
+<script src="dpi.js"></script>
+
+<!-- AdPacks.com Ad Code -->
+<script src="http://s3.buysellads.com/ac/bsa.js" async></script>
+<!-- End AdPacks.com Ad Code -->
+<!-- AdPacks.com Zone Code -->
+<div id="bsap_1261373" class="bsarocks bsap_67e1f7efa5300630944c625f7975b9b3"></div>
+<a href="http://adpacks.com" id="bsap_aplink">via Ad Packs</a>
+<!-- End AdPacks.com Zone Code -->
+
+<a href="http://github.com/LeaVerou/dpilove"><img style="position: absolute; top: 0; left: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_left_red_aa0000.png" alt="Fork me on GitHub"></a>
+
+<a href="https://twitter.com/share" class="twitter-share-button" data-via="LeaVerou" data-count="vertical">Tweet</a>
+<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
+
+<script>var _gaq = [['_setAccount', 'UA-25106441-4'],['_trackPageview']];</script>
+<script src="http://www.google-analytics.com/ga.js" async></script>
+
+</body>
+</html>
@@ -0,0 +1,5 @@
+/**
+ * StyleFix 1.0.3 & PrefixFree 1.0.7
+ * @author Lea Verou
+ * MIT license
+ */(function(){function t(e,t){return[].slice.call((t||document).querySelectorAll(e))}if(!window.addEventListener)return;var e=window.StyleFix={link:function(t){try{if(t.rel!=="stylesheet"||t.hasAttribute("data-noprefix"))return}catch(n){return}var r=t.href||t.getAttribute("data-href"),i=r.replace(/[^\/]+$/,""),s=(/^[a-z]{3,10}:/.exec(i)||[""])[0],o=(/^[a-z]{3,10}:\/\/[^\/]+/.exec(i)||[""])[0],u=/^([^?]*)\??/.exec(r)[1],a=t.parentNode,f=new XMLHttpRequest,l;f.onreadystatechange=function(){f.readyState===4&&l()};l=function(){var n=f.responseText;if(n&&t.parentNode&&(!f.status||f.status<400||f.status>600)){n=e.fix(n,!0,t);if(i){n=n.replace(/url\(\s*?((?:"|')?)(.+?)\1\s*?\)/gi,function(e,t,n){return/^([a-z]{3,10}:|#)/i.test(n)?e:/^\/\//.test(n)?'url("'+s+n+'")':/^\//.test(n)?'url("'+o+n+'")':/^\?/.test(n)?'url("'+u+n+'")':'url("'+i+n+'")'});var r=i.replace(/([\\\^\$*+[\]?{}.=!:(|)])/g,"\\$1");n=n.replace(RegExp("\\b(behavior:\\s*?url\\('?\"?)"+r,"gi"),"$1")}var l=document.createElement("style");l.textContent=n;l.media=t.media;l.disabled=t.disabled;l.setAttribute("data-href",t.getAttribute("href"));a.insertBefore(l,t);a.removeChild(t);l.media=t.media}};try{f.open("GET",r);f.send(null)}catch(n){if(typeof XDomainRequest!="undefined"){f=new XDomainRequest;f.onerror=f.onprogress=function(){};f.onload=l;f.open("GET",r);f.send(null)}}t.setAttribute("data-inprogress","")},styleElement:function(t){if(t.hasAttribute("data-noprefix"))return;var n=t.disabled;t.textContent=e.fix(t.textContent,!0,t);t.disabled=n},styleAttribute:function(t){var n=t.getAttribute("style");n=e.fix(n,!1,t);t.setAttribute("style",n)},process:function(){t('link[rel="stylesheet"]:not([data-inprogress])').forEach(StyleFix.link);t("style").forEach(StyleFix.styleElement);t("[style]").forEach(StyleFix.styleAttribute)},register:function(t,n){(e.fixers=e.fixers||[]).splice(n===undefined?e.fixers.length:n,0,t)},fix:function(t,n,r){for(var i=0;i<e.fixers.length;i++)t=e.fixers[i](t,n,r)||t;return t},camelCase:function(e){return e.replace(/-([a-z])/g,function(e,t){return t.toUpperCase()}).replace("-","")},deCamelCase:function(e){return e.replace(/[A-Z]/g,function(e){return"-"+e.toLowerCase()})}};(function(){setTimeout(function(){t('link[rel="stylesheet"]').forEach(StyleFix.link)},10);document.addEventListener("DOMContentLoaded",StyleFix.process,!1)})()})();(function(e){function t(e,t,r,i,s){e=n[e];if(e.length){var o=RegExp(t+"("+e.join("|")+")"+r,"gi");s=s.replace(o,i)}return s}if(!window.StyleFix||!window.getComputedStyle)return;var n=window.PrefixFree={prefixCSS:function(e,r,i){var s=n.prefix;n.functions.indexOf("linear-gradient")>-1&&(e=e.replace(/(\s|:|,)(repeating-)?linear-gradient\(\s*(-?\d*\.?\d*)deg/ig,function(e,t,n,r){return t+(n||"")+"linear-gradient("+(90-r)+"deg"}));e=t("functions","(\\s|:|,)","\\s*\\(","$1"+s+"$2(",e);e=t("keywords","(\\s|:)","(\\s|;|\\}|$)","$1"+s+"$2$3",e);e=t("properties","(^|\\{|\\s|;)","\\s*:","$1"+s+"$2:",e);if(n.properties.length){var o=RegExp("\\b("+n.properties.join("|")+")(?!:)","gi");e=t("valueProperties","\\b",":(.+?);",function(e){return e.replace(o,s+"$1")},e)}if(r){e=t("selectors","","\\b",n.prefixSelector,e);e=t("atrules","@","\\b","@"+s+"$1",e)}e=e.replace(RegExp("-"+s,"g"),"-");e=e.replace(/-\*-(?=[a-z]+)/gi,n.prefix);return e},property:function(e){return(n.properties.indexOf(e)?n.prefix:"")+e},value:function(e,r){e=t("functions","(^|\\s|,)","\\s*\\(","$1"+n.prefix+"$2(",e);e=t("keywords","(^|\\s)","(\\s|$)","$1"+n.prefix+"$2$3",e);return e},prefixSelector:function(e){return e.replace(/^:{1,2}/,function(e){return e+n.prefix})},prefixProperty:function(e,t){var r=n.prefix+e;return t?StyleFix.camelCase(r):r}};(function(){var e={},t=[],r={},i=getComputedStyle(document.documentElement,null),s=document.createElement("div").style,o=function(n){if(n.charAt(0)==="-"){t.push(n);var r=n.split("-"),i=r[1];e[i]=++e[i]||1;while(r.length>3){r.pop();var s=r.join("-");u(s)&&t.indexOf(s)===-1&&t.push(s)}}},u=function(e){return StyleFix.camelCase(e)in s};if(i.length>0)for(var a=0;a<i.length;a++)o(i[a]);else for(var f in i)o(StyleFix.deCamelCase(f));var l={uses:0};for(var c in e){var h=e[c];l.uses<h&&(l={prefix:c,uses:h})}n.prefix="-"+l.prefix+"-";n.Prefix=StyleFix.camelCase(n.prefix);n.properties=[];for(var a=0;a<t.length;a++){var f=t[a];if(f.indexOf(n.prefix)===0){var p=f.slice(n.prefix.length);u(p)||n.properties.push(p)}}n.Prefix=="Ms"&&!("transform"in s)&&!("MsTransform"in s)&&"msTransform"in s&&n.properties.push("transform","transform-origin");n.properties.sort()})();(function(){function i(e,t){r[t]="";r[t]=e;return!!r[t]}var e={"linear-gradient":{property:"backgroundImage",params:"red, teal"},calc:{property:"width",params:"1px + 5%"},element:{property:"backgroundImage",params:"#foo"},"cross-fade":{property:"backgroundImage",params:"url(a.png), url(b.png), 50%"}};e["repeating-linear-gradient"]=e["repeating-radial-gradient"]=e["radial-gradient"]=e["linear-gradient"];var t={initial:"color","zoom-in":"cursor","zoom-out":"cursor",box:"display",flexbox:"display","inline-flexbox":"display",flex:"display","inline-flex":"display",grid:"display","inline-grid":"display","min-content":"width"};n.functions=[];n.keywords=[];var r=document.createElement("div").style;for(var s in e){var o=e[s],u=o.property,a=s+"("+o.params+")";!i(a,u)&&i(n.prefix+a,u)&&n.functions.push(s)}for(var f in t){var u=t[f];!i(f,u)&&i(n.prefix+f,u)&&n.keywords.push(f)}})();(function(){function s(e){i.textContent=e+"{}";return!!i.sheet.cssRules.length}var t={":read-only":null,":read-write":null,":any-link":null,"::selection":null},r={keyframes:"name",viewport:null,document:'regexp(".")'};n.selectors=[];n.atrules=[];var i=e.appendChild(document.createElement("style"));for(var o in t){var u=o+(t[o]?"("+t[o]+")":"");!s(u)&&s(n.prefixSelector(u))&&n.selectors.push(o)}for(var a in r){var u=a+" "+(r[a]||"");!s("@"+u)&&s("@"+n.prefix+u)&&n.atrules.push(a)}e.removeChild(i)})();n.valueProperties=["transition","transition-property"];e.className+=" "+n.prefix;StyleFix.register(n.prefixCSS)})(document.documentElement);
Oops, something went wrong.

0 comments on commit fd08208

Please sign in to comment.