paritybit.ca

Raw content of https://www.paritybit.ca.
git clone https://git.sr.ht/~jbauer/paritybit.ca
Log | Files | Refs | README | LICENSE

commit a898e11b0ebb5ae5e33d1d552391c8d4e1a0aef8
parent d5bdea4eccd766b69a6b0b2a0b89bf2115497cf5
Author: Jake Bauer <jbauer@paritybit.ca>
Date:   Mon, 21 Feb 2022 21:56:24 -0500

Add monitor DPI calculator

Diffstat:
Mcontent/projects.md | 1+
Acontent/projects/monitor-dpi-calculator.md | 37+++++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/content/projects.md b/content/projects.md @@ -47,6 +47,7 @@ on [my Bandcamp wishlist](https://bandcamp.com/jbauer001/wishlist). Thanks! ## Web-Based Utilities <ul> + <li><a href="projects/monitor-dpi-calculator">Monitor DPI Calculator</a></li> <li><a href="projects/file-transfer-time-calculator">File Transfer Time Calculator</a></li> <li><a href="projects/time-duration-calculator">Time Duration Calculator</a></li> <li><a href="projects/morrowind-character-roller">Morrowind Character Roller</a></li> diff --git a/content/projects/monitor-dpi-calculator.md b/content/projects/monitor-dpi-calculator.md @@ -0,0 +1,37 @@ +Title: Monitor DPI Calculator +Summary: Calculate your monitor's DPI. + +# [%title] + +<noscript>It seems that the current browser you are using does not support +JavaScript or it has been disabled. JavaScript is required for this applet to +function.</noscript> + +Input the size of the file and your transfer speed to calculate how long it will +take to transfer the file. + +<p><strong>Result:</strong> <span id="result-field">0.00</span> DPI</p> + +<form> + <input id="width" type="number" min="0" placeholder="1920" arial-label="Resolution Width"/>pixels<br> + <input id="height" type="number" min="0" placeholder="1080" aria-label="Resolution Height"/>pixels<br> + <input id="size" type="number" min="0" placeholder="0" aria-label="Monitor Size"/>inches<br> + <button type="button" onClick=calculate()>Calculate</button> +</form> + +<script> +function calculate() { + let width = document.getElementById("width").value; + let height = document.getElementById("height").value; + let size = document.getElementById("size").value; + + if (width <= 0 || height <= 0 || size <= 0) { + alert("Please enter a valid number greater than 0!"); + return; + } + + dpi = Math.sqrt(width * width + height * height) / size; + + document.getElementById("result-field").innerHTML = dpi.toFixed(2); +} +</script>