another-dimension
Version:
A lightweight library for converting units of length
53 lines (47 loc) • 1.1 kB
HTML
<head>
<meta charset="utf-8">
<title>Browser test for another-dimension</title>
<style>
body {
font-family: monospace;
white-space: pre;
}
.error {
font-weight: bold;
color: #990000;
}
</style>
</head>
<body>
<script>
function printError(message) {
document.write('<div class="error">Error: ' + message + '</div>');
}
</script>
<script src="another-dimension.js"></script>
<script>
try {
document.write("Testing another-dimension named import...\n");
let dim1 = Dimension("1in");
if (dim1.toNumber("mm") != 25.4) throw new Error("Incorrect conversion\n");
document.write("All OK.");
}
catch (error) {
printError(error);
}
</script>
<script src="another-dimension.js" data-another-dimension-global="XDimension"></script>
<script>
try {
document.write("Testing another-dimension named import...\n");
let dim1 = XDimension("1in");
if (dim1.toNumber("mm") != 25.4) throw new Error("Incorrect conversion\n");
document.write("All OK.");
}
catch (error) {
printError(error);
}
</script>
</body>
</html>