|
@@ -19,6 +19,7 @@ async function renderCurrency() {
|
|
|
let firstSelect = document.querySelector("#firstSelect");
|
|
|
for (let i = 0; i < curArray.length; i++) {
|
|
|
let option = document.createElement("option");
|
|
|
+ option.setAttribute("selected", curArray[0]);
|
|
|
option.setAttribute("value", curArray[i]);
|
|
|
option.innerHTML = currencies[curArray[i]]["name"];
|
|
|
firstSelect.appendChild(option);
|
|
@@ -38,10 +39,22 @@ async function convert() {
|
|
|
let currency2 = document.querySelector("#secondCurrency");
|
|
|
let value1 = document.querySelector("#firstInput");
|
|
|
let value2 = document.querySelector("#secondInput");
|
|
|
+ if (!currency1.value) {
|
|
|
+ currency1.value = "btc";
|
|
|
+ }
|
|
|
+ if (!currency2.value) {
|
|
|
+ currency2.value = "usd";
|
|
|
+ }
|
|
|
+ if (value1.value === "" || +value1.value < 0) {
|
|
|
+ alert(
|
|
|
+ "Не введено число / Введено отрицательное число\nПоставлено число по умолчанию - 1"
|
|
|
+ );
|
|
|
+ value1.value = 1;
|
|
|
+ }
|
|
|
if (currency1.value === currency2.value) {
|
|
|
value2.value = value1.value;
|
|
|
}
|
|
|
- if (currency2.value === "btc"s) {
|
|
|
+ if (currency2.value === "btc") {
|
|
|
value2.value = objCur[currency1.value]["value"];
|
|
|
}
|
|
|
if (currency1.value !== currency2.value) {
|