Fixed operation with zones in JS.

This commit is contained in:
Revertron
2021-04-01 12:09:38 +02:00
parent 89cb23306a
commit 11bc887fbb
+6 -2
View File
@@ -1,6 +1,6 @@
var recordsBuffer = []; var recordsBuffer = [];
var availableZones = []; var availableZones = [];
var currentZone = ""; var currentZone;
function addRecord(record) { function addRecord(record) {
recordsBuffer.push(record); recordsBuffer.push(record);
@@ -180,9 +180,11 @@ function sendAction(param) {
} }
function onDomainChange(element) { function onDomainChange(element) {
if (typeof currentZone !== 'undefined') {
var domain = element.value + "." + currentZone.name; var domain = element.value + "." + currentZone.name;
external.invoke(JSON.stringify({cmd: 'checkDomain', name: domain})); external.invoke(JSON.stringify({cmd: 'checkDomain', name: domain}));
} }
}
function domainAvailable(available) { function domainAvailable(available) {
var input = document.getElementById("new_domain"); var input = document.getElementById("new_domain");
@@ -337,7 +339,7 @@ function refreshZonesList() {
availableZones.forEach(function(value, index, array) { availableZones.forEach(function(value, index, array) {
var zone = value.name + " (" + value.difficulty + "🔥)"; var zone = value.name + " (" + value.difficulty + "🔥)";
var add_class = ""; var add_class = "";
if (currentZone.name == value.name) { if (typeof currentZone !== 'undefined' && currentZone.name == value.name) {
add_class = "is-active"; add_class = "is-active";
} }
buf += "<a id=\"zone-{1}\" class=\"dropdown-item {2}\" onclick=\"changeZone('{3}');\">.{4}</a>" buf += "<a id=\"zone-{1}\" class=\"dropdown-item {2}\" onclick=\"changeZone('{3}');\">.{4}</a>"
@@ -348,9 +350,11 @@ function refreshZonesList() {
}); });
var links = document.getElementById("zones-links"); var links = document.getElementById("zones-links");
links.innerHTML = buf; links.innerHTML = buf;
if (typeof currentZone !== 'undefined') {
var cur_name = document.getElementById("zones-current-name"); var cur_name = document.getElementById("zones-current-name");
cur_name.innerHTML = "." + currentZone.name + " (" + currentZone.difficulty + "🔥)"; cur_name.innerHTML = "." + currentZone.name + " (" + currentZone.difficulty + "🔥)";
} }
}
function zonesChanged(text) { function zonesChanged(text) {
availableZones = JSON.parse(text); availableZones = JSON.parse(text);