Compare commits
No commits in common. "fcf2d160e233a1873d9a1da8b1e407010f638175" and "33eb5709e95452f3837607457418ed95f439a3a1" have entirely different histories.
fcf2d160e2
...
33eb5709e9
38
index.html
38
index.html
|
@ -7,8 +7,7 @@
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h3>Conversion</h3>
|
<select id='curr'>
|
||||||
From: <select id='curr'>
|
|
||||||
<option value='EUR'>EUR</option>
|
<option value='EUR'>EUR</option>
|
||||||
<option value='USD'>USD</option>
|
<option value='USD'>USD</option>
|
||||||
<option value='SEK'>SEK</option>
|
<option value='SEK'>SEK</option>
|
||||||
|
@ -23,7 +22,7 @@ From: <select id='curr'>
|
||||||
|
|
||||||
<input type='number' id='val' step='0.01'>
|
<input type='number' id='val' step='0.01'>
|
||||||
|
|
||||||
To: <select id='curr2'>
|
<select id='curr2'>
|
||||||
<option value='USD'>USD</option>
|
<option value='USD'>USD</option>
|
||||||
<option value='EUR'>EUR</option>
|
<option value='EUR'>EUR</option>
|
||||||
<option value='SEK'>SEK</option>
|
<option value='SEK'>SEK</option>
|
||||||
|
@ -41,40 +40,7 @@ To: <select id='curr2'>
|
||||||
<p>
|
<p>
|
||||||
Conversion: <span id='res'></span>
|
Conversion: <span id='res'></span>
|
||||||
</p>
|
</p>
|
||||||
<h3>Reversed conversion</h3>
|
|
||||||
From: <select id='rev'>
|
|
||||||
<option value='USD'>USD</option>
|
|
||||||
<option value='EUR'>EUR</option>
|
|
||||||
<option value='SEK'>SEK</option>
|
|
||||||
<option value='JPY'>JPY</option>
|
|
||||||
<option value='GBP'>GBP</option>
|
|
||||||
<option value='INR'>INR</option>
|
|
||||||
<option value='ISK'>ISK</option>
|
|
||||||
<option value='DKK'>DKK</option>
|
|
||||||
<option value='RON'>RON</option>
|
|
||||||
<option value='NOK'>NOK</option>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<input type='number' id='val2' step='0.01'>
|
|
||||||
|
|
||||||
To: <select id='rev2'>
|
|
||||||
<option value='EUR'>EUR</option>
|
|
||||||
<option value='USD'>USD</option>
|
|
||||||
<option value='SEK'>SEK</option>
|
|
||||||
<option value='JPY'>JPY</option>
|
|
||||||
<option value='GBP'>GBP</option>
|
|
||||||
<option value='INR'>INR</option>
|
|
||||||
<option value='ISK'>ISK</option>
|
|
||||||
<option value='DKK'>DKK</option>
|
|
||||||
<option value='RON'>RON</option>
|
|
||||||
<option value='NOK'>NOK</option>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<button onClick='convert2()'>Convert</button>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
Conversion: <span id='res2'></span>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<script src='script.js'></script>
|
<script src='script.js'></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
35
script.js
35
script.js
|
@ -15,38 +15,3 @@ async function convert(){
|
||||||
var val = document.getElementById('val').value;
|
var val = document.getElementById('val').value;
|
||||||
document.getElementById('res').textContent = Number((val*coef).toFixed(2)).toLocaleString('en') + ' ' +document.getElementById('curr2').value;
|
document.getElementById('res').textContent = Number((val*coef).toFixed(2)).toLocaleString('en') + ' ' +document.getElementById('curr2').value;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function convert2(){
|
|
||||||
const base = document.getElementById('rev').value;
|
|
||||||
const rates = await api(base);
|
|
||||||
const cur = document.getElementById('rev2').value;
|
|
||||||
var coef = rates[cur];
|
|
||||||
if (base==cur){
|
|
||||||
coef = 1;
|
|
||||||
}
|
|
||||||
var val = document.getElementById('val2').value;
|
|
||||||
document.getElementById('res2').textContent = Number((val*coef).toFixed(2)).toLocaleString('en') + ' ' +document.getElementById('rev2').value;
|
|
||||||
}
|
|
||||||
|
|
||||||
const from1 = document.getElementById('curr');
|
|
||||||
const to1 = document.getElementById('curr2');
|
|
||||||
|
|
||||||
const from2 = document.getElementById('rev');
|
|
||||||
const to2 = document.getElementById('rev2');
|
|
||||||
|
|
||||||
from1.onchange = function(a){
|
|
||||||
to2.value = a.target.value;
|
|
||||||
};
|
|
||||||
|
|
||||||
to1.onchange = function(a){
|
|
||||||
from2.value = a.target.value;
|
|
||||||
};
|
|
||||||
|
|
||||||
from2.onchange = function(a){
|
|
||||||
to1.value = a.target.value;
|
|
||||||
};
|
|
||||||
|
|
||||||
to2.onchange = function(a){
|
|
||||||
from1.value = a.target.value;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user