Download app.js from Hamson/sf-83a: direct link, hf CLI and curl.
- Browser
- Download file 1.01 kB
-
https://huggingface.co/spaces/Hamson/sf-83a/resolve/main/app.js
- Command line
-
hf download hf://spaces/Hamson/sf-83a/app.js
-
curl -L -o app.js https://huggingface.co/spaces/Hamson/sf-83a/resolve/main/app.js
1.01 kB
| function calculatePrice() { | |
| cost = (days * nights * persons); | |
| price = cost * 0.95; // 5% markdown | |
| } | |
| function roundToTwo(num) { | |
| return +(Math.round(num + "e+2") + "e-2"); | |
| } | |
| function parseNumber(str) { | |
| if (typeof str == "number") return str; | |
| str = str.replace(/[^\d.-]/g, ""); | |
| return parseFloat(str); | |
| } | |
| function isFloat(value) { | |
| let x = value; | |
| x = x.replace(/\./, ""); | |
| return parseInt("1" + x); | |
| } | |
| function validate(value) { | |
| const float = parseFloat(value); | |
| return isFloat(float) && float >= 0 ? float : parseNumber(value); | |
| } | |
| function format(value) { | |
| let x = parseNumber(value); | |
| x = roundToTwo(x); | |
| x = isFloat(x) ? x.toFixed(2) : x; | |
| return x; | |
| } | |
| window.onload = function() { | |
| calculatePrice(); | |
| }; | |
| document | |
| .querySelector('button[type="submit"]') | |
| .addEventListener("click", calculatePrice); | |
| document | |
| .querySelector('input[type="text"]') | |
| .addEventListener("input", (event) => { | |
| calculatePrice(event.target.value); | |
| }); |