Implemented DNS on blockchain. Beautified a lot of code, fixed some things.
This commit is contained in:
Vendored
+8
@@ -10838,4 +10838,12 @@ label.panel-block:hover {
|
||||
|
||||
html {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.notification {
|
||||
position: absolute;
|
||||
z-index: 100;
|
||||
width: 50%;
|
||||
top: 10pt;
|
||||
right: 10pt;
|
||||
}
|
||||
+66
-8
@@ -28,8 +28,66 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="new_record_dialog" class="modal">
|
||||
<div class="modal-background"></div>
|
||||
<div class="modal-content">
|
||||
<div class="box">
|
||||
<div class="columns">
|
||||
<div class="column is-one-third">
|
||||
<div class="field">
|
||||
<label class="label">Name</label>
|
||||
<div class="control">
|
||||
<input class="input" type="text" placeholder="www" id="record_name">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label class="label">Type</label>
|
||||
<div class="select">
|
||||
<select id="record_type">
|
||||
<option>A</option>
|
||||
<option>AAAA</option>
|
||||
<option>CNAME</option>
|
||||
<option>MX</option>
|
||||
<option>TXT</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label class="label">TTL</label>
|
||||
<div class="control">
|
||||
<input class="input" type="text" placeholder="3600" id="record_ttl" value="3600">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column is-one-third">
|
||||
<div class="field">
|
||||
<label class="label">Data</label>
|
||||
<div class="control">
|
||||
<input class="input" type="text" placeholder="1.2.3.4" id="record_data">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
<div class="buttons is-grouped is-centered">
|
||||
<button class="button is-primary" id="new_record_positive_button">Ok</button>
|
||||
<button class="button is-link is-light" id="new_record_negative_button">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="notification is-warning is-hidden" id="notification_warning">
|
||||
<button class="delete" id="close"></button>
|
||||
<p id="warning_text"></p>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<div class="columns">
|
||||
<div class="columns is-mobile">
|
||||
<div class="column is-one-fifth">
|
||||
<div class="menu">
|
||||
<ul class="menu-list">
|
||||
@@ -94,13 +152,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="label">Domain records</label>
|
||||
<div class="control">
|
||||
<textarea class="textarea" placeholder="@ IN AAAA 200:1111:2222:3333:4444:5555:6666:7777" id="new_domain_records"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="label">Domain tags (will be used for search)</label>
|
||||
<div class="control">
|
||||
@@ -108,7 +159,14 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content" id="domain_records">
|
||||
<!-- Here will be our domain records, added by dialog -->
|
||||
</div>
|
||||
|
||||
<div class="field is-grouped">
|
||||
<div class="control">
|
||||
<button class="button is-success" id="add_record_button" onclick="showNewRecordDialog();">Add record</button>
|
||||
</div>
|
||||
<div class="control">
|
||||
<button class="button is-link" id="new_domain_button" onclick="createDomain();" disabled>Create domain</button>
|
||||
</div>
|
||||
|
||||
+79
-1
@@ -1,3 +1,66 @@
|
||||
var recordsBuffer = [];
|
||||
|
||||
function addRecord(record) {
|
||||
recordsBuffer.push(record);
|
||||
refresh_records_list();
|
||||
}
|
||||
|
||||
function delRecord(index) {
|
||||
recordsBuffer.splice(index, 1);
|
||||
refresh_records_list();
|
||||
}
|
||||
|
||||
function refresh_records_list() {
|
||||
var buf = "";
|
||||
if (recordsBuffer.length > 0) {
|
||||
buf = "<label class=\"label\">Records:</label>\n";
|
||||
}
|
||||
function getInput(text) {
|
||||
return '<input class="input" type="text" value="' + text + '" readonly>';
|
||||
}
|
||||
|
||||
function makeRecord(value, index, array) {
|
||||
buf += "<div class=\"columns is-1\">\n";
|
||||
buf += "<div class=\"column\">" + getInput(value.domain) + "</div>\n";
|
||||
buf += "<div class=\"column is-2\">" + getInput(value.type) + "</div>\n";
|
||||
buf += "<div class=\"column is-2\">" + getInput(value.ttl) + "</div>\n";
|
||||
buf += "<div class=\"column\">" + getInput(value.addr) + "</div>\n";
|
||||
buf += "<div class=\"column is-1 align-right\">\n<button class=\"button is-danger is-outlined\" id=\"record_delete\" onclick=\"delRecord(" + index + ");\">";
|
||||
buf += "<span class=\"icon is-small\"><i class=\"fas fa-times\"></i></span></button></div>\n";
|
||||
buf += "</div>";
|
||||
}
|
||||
|
||||
recordsBuffer.forEach(makeRecord);
|
||||
document.getElementById("domain_records").innerHTML = buf;
|
||||
}
|
||||
|
||||
function showNewRecordDialog() {
|
||||
button_positive = document.getElementById("new_record_positive_button");
|
||||
button_positive.onclick = function() {
|
||||
addRecord(get_record_from_dialog()); // It will refresh list
|
||||
dialog = document.getElementById("new_record_dialog");
|
||||
dialog.className = "modal";
|
||||
};
|
||||
|
||||
button_negative = document.getElementById("new_record_negative_button");
|
||||
button_negative.onclick = function() {
|
||||
dialog = document.getElementById("new_record_dialog");
|
||||
dialog.className = "modal";
|
||||
refresh_records_list();
|
||||
}
|
||||
|
||||
dialog = document.getElementById("new_record_dialog");
|
||||
dialog.className = "modal is-active";
|
||||
}
|
||||
|
||||
function get_record_from_dialog() {
|
||||
record_name = document.getElementById("record_name").value;
|
||||
record_type = document.getElementById("record_type").value;
|
||||
record_ttl = parseInt(document.getElementById("record_ttl").value);
|
||||
record_data = document.getElementById("record_data").value;
|
||||
return { type: record_type, domain: record_name, ttl: record_ttl, addr: record_data }
|
||||
}
|
||||
|
||||
function onLoad() {
|
||||
external.invoke(JSON.stringify({cmd: 'loaded'}));
|
||||
}
|
||||
@@ -37,7 +100,8 @@ function saveKey() {
|
||||
|
||||
function createDomain() {
|
||||
new_domain = document.getElementById("new_domain").value;
|
||||
new_dom_records = document.getElementById("new_domain_records").value;
|
||||
//new_dom_records = document.getElementById("new_domain_records").value;
|
||||
new_dom_records = JSON.stringify(recordsBuffer);
|
||||
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}));
|
||||
}
|
||||
@@ -102,6 +166,20 @@ function showModalDialog(text, callback) {
|
||||
dialog.className = "modal is-active";
|
||||
}
|
||||
|
||||
function showWarning(text) {
|
||||
warning = document.getElementById("notification_warning");
|
||||
message = document.getElementById("warning_text");
|
||||
message.innerHTML = text;
|
||||
|
||||
warning.className = "notification is-warning";
|
||||
button = document.getElementById("close");
|
||||
button.onclick = function() {
|
||||
message.value = "";
|
||||
warning.className = "notification is-warning is-hidden";
|
||||
}
|
||||
setTimeout(button.onclick, 5000);
|
||||
}
|
||||
|
||||
function showMiningIndicator(visible) {
|
||||
indicator = document.getElementById("mining_indicator");
|
||||
if (visible) {
|
||||
|
||||
Reference in New Issue
Block a user