Files
Alfis/src/webview/scripts.js
T

128 lines
4.1 KiB
JavaScript
Raw Normal View History

function onLoad() {
external.invoke(JSON.stringify({cmd: 'loaded'}));
}
function openTab(element, tabName) {
// Declare all variables
var i, tabContent, tabLinks;
// Get all elements with class="content" and hide them
tabContent = document.getElementsByClassName("content");
for (i = 0; i < tabContent.length; i++) {
tabContent[i].className = "context is-hidden";
}
// Get all elements with class="tablinks" and remove the class "active"
tabLinks = document.getElementsByClassName("is-active");
for (i = 0; i < tabLinks.length; i++) {
tabLinks[i].className = "";
}
// Show the current tab, and add an "active" class to the button that opened the tab
document.getElementById(tabName).className = "content";
element.className = "is-active";
}
function loadKey() {
2021-02-15 23:09:30 +01:00
external.invoke(JSON.stringify({cmd: 'loadKey'}));
}
function createKey() {
2021-02-15 23:09:30 +01:00
external.invoke(JSON.stringify({cmd: 'createKey'}));
}
function saveKey() {
external.invoke(JSON.stringify({cmd: 'saveKey'}));
}
function createDomain() {
new_domain = document.getElementById("new_domain").value;
new_dom_records = document.getElementById("new_domain_records").value;
new_dom_tags = document.getElementById("new_domain_tags").value;
external.invoke(JSON.stringify({cmd: 'createDomain', name: new_domain, records: new_dom_records, tags: new_dom_tags}));
}
function changeDomain() {
domain = document.getElementById("change_domain").value;
dom_records = document.getElementById("change_domain_records").value;
dom_tags = document.getElementById("change_domain_records").value;
external.invoke(JSON.stringify({cmd: 'changeDomain', name: domain, records: dom_records, tags: dom_tags}));
}
function renewDomain() {
domain = document.getElementById("renew_domain").value;
days = document.getElementById("renew_domain_extend_days").value;
external.invoke(JSON.stringify({cmd: 'renewDomain', name: domain, days: days}));
}
function transferDomain() {
domain = document.getElementById("transfer_domain").value;
new_owner = document.getElementById("transfer_domain_transfer_owner").value;
external.invoke(JSON.stringify({cmd: 'transferDomain', name: domain, owner: new_owner}));
}
function sendAction(param) {
external.invoke(JSON.stringify(param));
}
function onDomainChange(element) {
external.invoke(JSON.stringify({cmd: 'checkDomain', name: element.value}));
}
function domainAvailable(available) {
input = document.getElementById("new_domain");
button = document.getElementById("new_domain_button");
if (available) {
input.className = "input";
button.disabled = false
} else {
input.className = "input is-danger";
button.disabled = true
}
}
function showModalDialog(text, callback) {
message = document.getElementById("modal_text");
message.textContent = text;
button_positive = document.getElementById("modal_positive_button");
button_positive.onclick = function() {
callback();
dialog = document.getElementById("modal_dialog");
dialog.className = "modal";
};
button_negative = document.getElementById("modal_negative_button");
button_negative.onclick = function() {
dialog = document.getElementById("modal_dialog");
dialog.className = "modal";
}
dialog = document.getElementById("modal_dialog");
dialog.className = "modal is-active";
}
function showMiningIndicator(visible) {
indicator = document.getElementById("mining_indicator");
if (visible) {
indicator.style.visibility = 'visible';
} else {
indicator.style.visibility = 'hidden';
}
}
function miningIndicatorClick(element) {
showModalDialog("Do you really want to stop mining?", function() {
external.invoke(JSON.stringify({cmd: 'stopMining'}));
});
2021-02-15 23:09:30 +01:00
}
function keystoreChanged(path, pub_key) {
if (path == '') {
path = "In memory";
}
key_file_name = document.getElementById("key_file_name");
key_file_name.innerHTML = path;
key_file_key = document.getElementById("key_public_key");
key_file_key.innerHTML = pub_key;
}