-
Notifications
You must be signed in to change notification settings - Fork 11
/
index.html
192 lines (170 loc) · 9.05 KB
/
index.html
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<style>
article, aside, footer, header, nav, section{
display: block;
}
#button_container {
text-align: center;
}
</style>
<title>SASINATOR v2.0</title>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
<script type="text/javascript">
const SASIN_CONSTANT = 70000000;
const PREFIXES = {"jokto" : "y", "zepto" : "z", "atto" : "a", "femto" : "f",
"piko" : "p", "nano" : "n", "mikro" : "µ", "mili" : "m",
"centy" : "c", "decy" : "d",
"-" : "",
"deka" : "da", "hekto" : "h",
"kilo" : "k", "mega" : "M", "giga" : "G", "tera" : "T",
"peta" : "P", "eksa" : "E", "zetta" : "Z", "jotta" : "Y"};
const NAMES = Object.keys(PREFIXES);
const SYMBOLS = Object.values(PREFIXES);
var _exponents = [];
for(let i = -24; i < -2; i += 3)
_exponents.push(i);
for(let i = -2; i < 1; i++)
_exponents.push(i);
for(let i=_exponents.length-2; i >= 0; i--)
_exponents.push(-_exponents[i])
const EXPONENTS = _exponents;
var toSasin = true;
var setResult = () => {
let i_val = document.getElementById("i").value;
let o = document.getElementById("o");
let out_multiplier = Math.pow(10, EXPONENTS[parseInt(document.getElementById("o_prefix_select").value)]);
let in_multiplier = Math.pow(10, EXPONENTS[parseInt(document.getElementById("i_prefix_select").value)]);
i_val = (i_val == "" ? 0 : parseFloat(i_val));
if(toSasin)
o.value = (Number.isNaN(i_val) ? "błędna liczba" : ((i_val * in_multiplier)/(SASIN_CONSTANT * out_multiplier)));
else
o.value = (Number.isNaN(i_val) ? "błędna liczba" : ((i_val * in_multiplier)*(SASIN_CONSTANT / out_multiplier)));
document.getElementById("out_prefix").textContent = SYMBOLS[parseInt(document.getElementById("o_prefix_select").value)];
document.getElementById("in_prefix").textContent = SYMBOLS[parseInt(document.getElementById("i_prefix_select").value)];
}
var writePrefixes = () => {
for(let i=NAMES.length-1; i > -1; i--) {
let name = NAMES[i];
let selected = (name == "-" ? "selected=\"selected\"" : "");
document.writeln("<option value=\"" + i + "\" " + selected + ">" + name + "</option>");
}
}
var switchSides = () => {
toSasin = !toSasin;
if(toSasin) {
document.getElementById("in_unit").textContent = "inna jednostka";
document.getElementById("in_symbol").textContent = "j";
document.getElementById("out_unit").textContent = "sasin";
document.getElementById("out_symbol").textContent = "Sas";
}
else {
document.getElementById("in_unit").textContent = "sasin";
document.getElementById("in_symbol").textContent = "Sas";
document.getElementById("out_unit").textContent = "inna jednostka";
document.getElementById("out_symbol").textContent = "j";
}
document.getElementById("i").value = document.getElementById("o").value;
let selected_i_prefix = document.getElementById("i_prefix_select").value;
document.getElementById("i_prefix_select").value = document.getElementById("o_prefix_select").value;
document.getElementById("o_prefix_select").value = selected_i_prefix;
setResult();
}
</script>
</head>
<body>
<header>
<div class="w-100 p-3 d-flex justify-content-center">
<h1><img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Ftse1.mm.bing.net%2Fth%3Fid%3DOIP.e3IofiAj1fLTxnMb4zl4yQAAAA%26pid%3DApi&f=1" alt="strajk kobiet" style="width:120px;height:134px;margin-right:15px;">SASINATOR <span class="badge badge-secondary">v2.0</span></h1>
</div>
<h2 style="justify-content: center;display: flex;">***** ***</h2>
</header>
<div class="w-100 p-3 d-flex justify-content-center" style="background-color: #eee;">
<article>
<header>
<h3>Przelicznik na uniwersalną jednostkę - sasin</h3>
</header>
<div class="w-100 p-3 d-flex justify-content-center">
<section id="article-content">
<p>
<form oninput="setResult()" autocomplete="off">
<input name="i" id="i" type="text" placeholder="Wprowadź wartość" />
<select id="i_prefix_select">
<script type="text/javascript">
writePrefixes();
</script>
</select>
<span id="in_unit">inna jednostka</span> (<span id="in_prefix"></span><span id="in_symbol">j</span>) =
<input name="o" id="o" type="text" value="0" disabled="disabled" />
<select id="o_prefix_select">
<script type="text/javascript">
writePrefixes();
</script>
</select>
<span id="out_unit">sasin</span> (<span id="out_prefix"></span><span id="out_symbol">Sas</span>)
</form>
</p>
<div id="button_container">
<button id="swipe" style="margin-left:5px;" type="button" class="btn btn-outline-secondary" onclick="switchSides()"><svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-shuffle" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" d="M0 3.5A.5.5 0 0 1 .5 3H1c2.202 0 3.827 1.24 4.874 2.418.49.552.865 1.102 1.126 1.532.26-.43.636-.98 1.126-1.532C9.173 4.24 10.798 3 13 3v1c-1.798 0-3.173 1.01-4.126 2.082A9.624 9.624 0 0 0 7.556 8a9.624 9.624 0 0 0 1.317 1.918C9.828 10.99 11.204 12 13 12v1c-2.202 0-3.827-1.24-4.874-2.418A10.595 10.595 0 0 1 7 9.05c-.26.43-.636.98-1.126 1.532C4.827 11.76 3.202 13 1 13H.5a.5.5 0 0 1 0-1H1c1.798 0 3.173-1.01 4.126-2.082A9.624 9.624 0 0 0 6.444 8a9.624 9.624 0 0 0-1.317-1.918C4.172 5.01 2.796 4 1 4H.5a.5.5 0 0 1-.5-.5z"/>
<path d="M13 5.466V1.534a.25.25 0 0 1 .41-.192l2.36 1.966c.12.1.12.284 0 .384l-2.36 1.966a.25.25 0 0 1-.41-.192zm0 9v-3.932a.25.25 0 0 1 .41-.192l2.36 1.966c.12.1.12.284 0 .384l-2.36 1.966a.25.25 0 0 1-.41-.192z"/>
</svg> </button>
</div>
</section>
</div>
<footer>
</footer>
</article>
</div>
<div class="w-100 p-3 d-flex justify-content-center">
<div class="w-25 p-1 d-flex shadow-lg p-3 mb-5 bg-white rounded">
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="https://media.nationalgeographic.org/assets/photos/000/290/29094.jpg">
<div class="carousel-caption d-none d-md-block">
<h5>CZY WIESZ, ŻE:</h5>
<p>Odległość słońca od ziemi to 2,137142857142857 sasin?</p>
</div>
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://s3.wizaz.pl/newsy/robert-lewandowski-3616955420-4_3_800.png">
<div class="carousel-caption d-none d-md-block">
<h5>CZY WIESZ, ŻE:</h5>
<p>Rober Lewandowski zarabia około 1,3 sasin rocznie?</p>
</div>
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://thumbs.dreamstime.com/b/sok%C3%B3%C5%82-w%C4%99drowny-jastrz%C4%85bek-94895755.jpg" alt="Third slide">
<div class="carousel-caption d-none d-md-block">
<h5>CZY WIESZ, ŻE:</h5>
<p>Sokół pikuje z prędkością około 4.571428571428571 mikrosasin/h?</p>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</div>
<footer>
</footer>
</body>
</html>