-
Notifications
You must be signed in to change notification settings - Fork 0
/
size.php
40 lines (30 loc) · 960 Bytes
/
size.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<!doctype html>
<html>
<body>
<script src="https://code.jquery.com/jquery-3.1.0.js"
integrity="sha256-slogkvB1K3VOkzAI8QITxV3VzpOnkeNVsKvtkYLMjfk="
crossorigin="anonymous"></script>
<div id="target-location"></div>
<div id="hidden-resizer" style="display: none"></div>
<script type="text/javascript">
function numberWithSpaces(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
}
function showPrice(price) {
var size;
var desired_width = 50;
var resizer = $("#hidden-resizer");
price = numberWithSpaces(price);
resizer.html(price+" E");
while(resizer.width() > desired_width) {
size = parseInt(resizer.css("font-size"), 10);
;;console.log(size);
if(size<6) break;
resizer.css("font-size", size - 1);
}
$("#target-location").css("font-size", size).html(resizer.html());
}
showPrice(1200000);
</script>
</body>
</html>