Skip to content

Commit

Permalink
BugFix
Browse files Browse the repository at this point in the history
  • Loading branch information
AXARevBot committed May 13, 2012
1 parent 117db15 commit 576524c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
10 changes: 5 additions & 5 deletions dpi.js
Expand Up @@ -81,38 +81,38 @@
detectPhone();
return (pixels / phoneDPI) / 0.393700787 | 0;
}
document.getMmFromPixel = getMmFromPixel;
window.getMmFromPixel = getMmFromPixel;

function getPixelFromMm(mm)
{
if (!phoneDPI)
detectPhone();
return mm * 0.393700787 * phoneDPI | 0;
}
document.getPixelFromMm = getPixelFromMm;
window.getPixelFromMm = getPixelFromMm;

function getInchFromPixel(pixels)
{
if (!phoneDPI)
detectPhone();
return (pixels / phoneDPI) | 0;
}
document.getInchFromPixel = getInchFromPixel;
window.getInchFromPixel = getInchFromPixel;

function getPixelFromInch(inch)
{
if (!phoneDPI)
detectPhone();
return inch * phoneDPI | 0;
}
document.getPixelFromInch = getPixelFromInch;
window.getPixelFromInch = getPixelFromInch;

function getDPI()
{
if (!phoneDPI)
detectPhone();
return phoneDPI;
}
document.getDPI = getDPI;
window.getDPI = getDPI;
}
)(window, navigator, document);
7 changes: 1 addition & 6 deletions test.html
Expand Up @@ -17,12 +17,7 @@
</div>
<div id="dpi"></div>
<script>
document.getElementById('data').innerHTML =
navigator.userAgent + '<br/>' + document.body.offsetWidth
+ '<br/>'
+ document.body.offsetHeight
+'<br/>'
+ document.getElementById("dpi").offsetHeight;
alert(getDPI())
</script>
</body>
</html>

0 comments on commit 576524c

Please sign in to comment.