initial commit
This commit is contained in:
commit
9246e48f03
39 files changed
+34142
No files matched your search
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
/*!
|
||||
* Bootstrap v5.3.5 (https://getbootstrap.com/)
|
||||
* Copyright 2011-2025 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||||
*/
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("@popperjs/core")):"function"==typeof define&&define.amd?define(["@popperjs/core"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).bootstrap=e(t.Popper)}(this,(function(t){"use strict";function e(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t)for(const i in t)if("default"!==i){const s=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:()=>t[i]})}return e.default=t,Object.freeze(e)}const i=e(t),s=new Map,n={set(t,e,i){s.has(t)||s.set(t,new Map);const n=s.get(t);n.has(e)||0===n.size?n.set(e,i):console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(n.keys())[0]}.`)},get:(t,e)=>s.has(t)&&s.get(t).get(e)||null,remove(t,e){if(!s.has(t))return;const i=s.get(t);i.delete(e),0===i.size&&s.delete(t)}},o="transitionend",r=t=>(t&&window.CSS&&window.CSS.escape&&(t=t.replace(/#([^\s"#']+)/g,((t,e)=>`#${CSS.escape(e)}`))),t),a=t=>{t.dispatchEvent(new Event(o))},l=t=>!(!t||"object"!=typeof t)&&(void 0!==t.jquery&&(t=t[0]),void 0!==t.nodeType),c=t=>l(t)?t.jquery?t[0]:t:"string"==typeof t&&t.length>0?document.querySelector(r(t)):null,h=t=>{if(!l(t)||0===t.getClientRects().length)return!1;const e="visible"===getComputedStyle(t).getPropertyValue("visibility"),i=t.closest("details:not([open])");if(!i)return e;if(i!==t){const e=t.closest("summary");if(e&&e.parentNode!==i)return!1;if(null===e)return!1}return e},d=t=>!t||t.nodeType!==Node.ELEMENT_NODE||!!t.classList.contains("disabled")||(void 0!==t.disabled?t.disabled:t.hasAttribute("disabled")&&"false"!==t.getAttribute("disabled")),u=t=>{if(!document.documentElement.attachShadow)return null;if("function"==typeof t.getRootNode){const e=t.getRootNode();return e instanceof ShadowRoot?e:null}return t instanceof ShadowRoot?t:t.parentNode?u(t.parentNode):null},_=()=>{},g=t=>{t.offsetHeight},f=()=>window.jQuery&&!document.body.hasAttribute("data-bs-no-jquery")?window.jQuery:null,m=[],p=()=>"rtl"===document.documentElement.dir,b=t=>{var e;e=()=>{const e=f();if(e){const i=t.NAME,s=e.fn[i];e.fn[i]=t.jQueryInterface,e.fn[i].Constructor=t,e.fn[i].noConflict=()=>(e.fn[i]=s,t.jQueryInterface)}},"loading"===document.readyState?(m.length||document.addEventListener("DOMContentLoaded",(()=>{for(const t of m)t()})),m.push(e)):e()},v=(t,e=[],i=t)=>"function"==typeof t?t.call(...e):i,y=(t,e,i=!0)=>{if(!i)return void v(t);const s=(t=>{if(!t)return 0;let{transitionDuration:e,transitionDelay:i}=window.getComputedStyle(t);const s=Number.parseFloat(e),n=Number.parseFloat(i);return s||n?(e=e.split(",")[0],i=i.split(",")[0],1e3*(Number.parseFloat(e)+Number.parseFloat(i))):0})(e)+5;let n=!1;const r=({target:i})=>{i===e&&(n=!0,e.removeEventListener(o,r),v(t))};e.addEventListener(o,r),setTimeout((()=>{n||a(e)}),s)},w=(t,e,i,s)=>{const n=t.length;let o=t.indexOf(e);return-1===o?!i&&s?t[n-1]:t[0]:(o+=i?1:-1,s&&(o=(o+n)%n),t[Math.max(0,Math.min(o,n-1))])},A=/[^.]*(?=\..*)\.|.*/,E=/\..*/,C=/::\d+$/,T={};let k=1;const $={mouseenter:"mouseover",mouseleave:"mouseout"},S=new Set(["click","dblclick","mouseup","mousedown","contextmenu","mousewheel","DOMMouseScroll","mouseover","mouseout","mousemove","selectstart","selectend","keydown","keypress","keyup","orientationchange","touchstart","touchmove","touchend","touchcancel","pointerdown","pointermove","pointerup","pointerleave","pointercancel","gesturestart","gesturechange","gestureend","focus","blur","change","reset","select","submit","focusin","focusout","load","unload","beforeunload","resize","move","DOMContentLoaded","readystatechange","error","abort","scroll"]);function L(t,e){return e&&`${e}::${k++}`||t.uidEvent||k++}function O(t){const e=L(t);return t.uidEvent=e,T[e]=T[e]||{},T[e]}function I(t,e,i=null){return Object.values(t).find((t=>t.callable===e&&t.delegationSelector===i))}function D(t,e,i){const s="string"==typeof e,n=s?i:e||i;let o=M(t);return S.has(o)||(o=t),[s,n,o]}function N(t,e,i,s,n){if("string"!=typeof e||!t)return;let[o,r,a]=D(e,i,s);if(e in $){const t=t=>function(e){if(!e.relatedTarget||e.relatedTarget!==e.delegateTarget&&!e.delegateTarget.contains(e.relatedTarget))return t.call(this,e)};r=t(r)}const l=O(t),c=l[a]||(l[a]={}),h=I(c,r,o?i:null);if(h)return void(h.oneOff=h.oneOff&&n);const d=L(r,e.replace(A,"")),u=o?function(t,e,i){return function s(n){const o=t.querySelectorAll(e);for(let{target:r}=n;r&&r!==this;r=r.parentNode)for(const a of o)if(a===r)return F(n,{delegateTarget:r}),s.oneOff&&j.off(t,n.type,e,i),i.apply(r,[n])}}(t,i,r):function(t,e){return function i(s){return F(s,{delegateTarget:t}),i.oneOff&&j.off(t,s.type,e),e.apply(t,[s])}}(t,r);u.delegationSelector=o?i:null,u.callable=r,u.oneOff=n,u.uidEvent=d,c[d]=u,t.addEventListener(a,u,o)}function P(t,e,i,s,n){const o=I(e[i],s,n);o&&(t.removeEventListener(i,o,Boolean(n)),delete e[i][o.uidEvent])}function x(t,e,i,s){const n=e[i]||{};for(const[o,r]of Object.entries(n))o.includes(Line truncated
|
||||
//# sourceMappingURL=bootstrap.min.js.map
|
||||
@@ -0,0 +1,8 @@
|
||||
const dhcp_enabled = document.querySelector("#dhcp_enabled");
|
||||
const dhcp_rect_body = document.querySelector("#dhcp_rect_body");
|
||||
|
||||
dhcp_enabled.addEventListener("click", () => {
|
||||
!dhcp_enabled.checked
|
||||
? dhcp_rect_body.classList.add("hidden")
|
||||
: dhcp_rect_body.classList.remove("hidden");
|
||||
});
|
||||
@@ -0,0 +1,207 @@
|
||||
const upstream_dns_servers_table_body = document.querySelector(
|
||||
"#upstream-dns-servers-table-body",
|
||||
);
|
||||
const local_domains_table_body = document.querySelector(
|
||||
"#local-domains-table-body",
|
||||
);
|
||||
const cache_size_input = document.querySelector("#cache-size-input");
|
||||
const save_settings_button = document.querySelector("#save-settings-button");
|
||||
const add_dns_server_button = document.querySelector("#add_dns_server_button");
|
||||
const add_local_domain_button = document.querySelector(
|
||||
"#add_local_domain_button",
|
||||
);
|
||||
const edit_file_input = document.querySelector("#edit_file_input");
|
||||
const save_config_file_button = document.querySelector(
|
||||
"#save_config_file_button",
|
||||
);
|
||||
|
||||
var settings = {};
|
||||
var configFile = "";
|
||||
|
||||
const updateDnsServersTable = () => {
|
||||
upstream_dns_servers_table_body.innerHTML = "";
|
||||
for (var i = 0; i < settings.resolv.length; i++) {
|
||||
upstream_dns_servers_table_body.innerHTML += `<tr>
|
||||
<th class="d-flex align-items-center justify-content-between">
|
||||
${settings.resolv[i]}
|
||||
<button id="${i}" class="delete-table-button btn btn-danger">Del</button>
|
||||
</th>
|
||||
</tr>`;
|
||||
}
|
||||
};
|
||||
|
||||
const updateLocalDomainsTable = () => {
|
||||
local_domains_table_body.innerHTML = "";
|
||||
for (const [key, value] of Object.entries(settings.hosts)) {
|
||||
if (Array.isArray(value)) {
|
||||
for (var i = 0; i < value.length; i++) {
|
||||
local_domains_table_body.innerHTML += `<tr>
|
||||
<th>${key}</th>
|
||||
<th>${value[i]}</th>
|
||||
<th><button class="deldomain btn btn-danger" id="${key}|${value[i]}">Del</button>
|
||||
</th>
|
||||
</tr>`;
|
||||
}
|
||||
} else {
|
||||
local_domains_table_body.innerHTML += `<tr>
|
||||
<th>${key}</th>
|
||||
<th>${value}</th>
|
||||
<th><button class="deldomain btn btn-danger" id="${key}|${value}">Del</button>
|
||||
</th>
|
||||
</tr>`;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const updateInterface = () => {
|
||||
updateDnsServersTable();
|
||||
updateLocalDomainsTable();
|
||||
cache_size_input.value = settings.cache_size;
|
||||
};
|
||||
|
||||
const getSettings = () => {
|
||||
fetch(window.location.origin + "/api/settings")
|
||||
.then((data) => data.json())
|
||||
.then((jsondata) => {
|
||||
settings = jsondata;
|
||||
updateInterface();
|
||||
})
|
||||
.catch((e) => alert(e));
|
||||
};
|
||||
|
||||
const setSettings = () => {
|
||||
fetch(window.location.origin + "/api/settings", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(settings),
|
||||
})
|
||||
.then((data) => data.json())
|
||||
.then((jsondata) => {
|
||||
settings = jsondata;
|
||||
updateInterface();
|
||||
alert("Success set settings");
|
||||
})
|
||||
.catch((e) => alert(e));
|
||||
};
|
||||
|
||||
save_settings_button.addEventListener("click", () => {
|
||||
setSettings();
|
||||
});
|
||||
|
||||
const write_cache_size = (value) => {
|
||||
settings.cache_size = value;
|
||||
};
|
||||
|
||||
cache_size_input.addEventListener("change", (e) => {
|
||||
write_cache_size(e.target.value);
|
||||
});
|
||||
|
||||
cache_size_input.addEventListener("input", (e) => {
|
||||
write_cache_size(e.target.value);
|
||||
});
|
||||
|
||||
getSettings();
|
||||
|
||||
add_dns_server_button.addEventListener("click", () => {
|
||||
const dns_server = prompt("Input your DNS server:");
|
||||
if (dns_server === null) return;
|
||||
if (confirm("Confirm DNS settings? (add DNS server)")) {
|
||||
if (Array.isArray(settings.resolv)) {
|
||||
if (!settings.resolv.includes(dns_server)) {
|
||||
settings.resolv.push(dns_server);
|
||||
updateDnsServersTable();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
upstream_dns_servers_table_body.addEventListener("click", (e) => {
|
||||
if (e.target.classList.contains("delete-table-button")) {
|
||||
if (
|
||||
confirm(`Confirm DNS settings? (delete DNS server: ${e.target.id})`)
|
||||
) {
|
||||
if (Array.isArray(settings.resolv)) {
|
||||
settings.resolv.splice(e.target.id, 1);
|
||||
updateDnsServersTable();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
add_local_domain_button.addEventListener("click", () => {
|
||||
const domainip = prompt("Input localdomain IP:");
|
||||
if (domainip === null) return;
|
||||
const domain = prompt("Input domain:");
|
||||
if (domainip === null || domain === null) return;
|
||||
if (
|
||||
confirm(
|
||||
`Confirm DNS settings? (Add Local Domain: ${domainip} ${domain})`,
|
||||
)
|
||||
) {
|
||||
for (const [key, value] of Object.entries(settings.hosts)) {
|
||||
if (key === domainip) {
|
||||
if (Array.isArray(value)) {
|
||||
if (!value.includes(domain)) {
|
||||
value.push(domain);
|
||||
updateLocalDomainsTable();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
const domainsarray = [value, domain];
|
||||
settings.hosts[key] = domainsarray;
|
||||
updateLocalDomainsTable();
|
||||
return;
|
||||
}
|
||||
}
|
||||
settings.hosts[domainip] = domain;
|
||||
updateLocalDomainsTable();
|
||||
}
|
||||
});
|
||||
|
||||
local_domains_table_body.addEventListener("click", (e) => {
|
||||
if (e.target.classList.contains("deldomain")) {
|
||||
if (confirm(`Confirm DNS settings? (delete domain: ${e.target.id})`)) {
|
||||
const domainip = e.target.id.split("|")[0];
|
||||
const domain = e.target.id.split("|")[1];
|
||||
for (const [key, value] of Object.entries(settings.hosts)) {
|
||||
if (key === domainip) {
|
||||
if (Array.isArray(value)) {
|
||||
if (value.includes(domain)) {
|
||||
value.splice(value.indexOf(domain), 1);
|
||||
updateLocalDomainsTable();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
delete settings.hosts[key];
|
||||
updateLocalDomainsTable();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const getConfigFile = () => {
|
||||
fetch(window.location.origin + "/api/settings/file")
|
||||
.then((data) => data.text())
|
||||
.then((textdata) => (edit_file_input.value = textdata))
|
||||
.catch((e) => alert(e));
|
||||
};
|
||||
|
||||
getConfigFile();
|
||||
|
||||
save_config_file_button.addEventListener("click", () => {
|
||||
if (confirm("Save Config file?")) {
|
||||
fetch(window.location.origin + "/api/settings/file", {
|
||||
method: "POST",
|
||||
body: edit_file_input.value,
|
||||
})
|
||||
.then((data) => data.text())
|
||||
.then((textdata) => {
|
||||
edit_file_input.value = textdata;
|
||||
alert("Success write settings file");
|
||||
})
|
||||
.catch((e) => alert(e));
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
const dark_theme = document.querySelector('#dark_theme')
|
||||
|
||||
dark_theme.addEventListener('click', () => {
|
||||
if (dark_theme.checked) {
|
||||
document.documentElement.setAttribute('data-bs-theme', 'dark')
|
||||
localStorage.setItem('data-bs-theme', 'dark')
|
||||
} else {
|
||||
document.documentElement.setAttribute('data-bs-theme', 'light')
|
||||
localStorage.setItem('data-bs-theme', 'light')
|
||||
}
|
||||
})
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
var theme = localStorage.getItem('data-bs-theme')
|
||||
if (theme) {
|
||||
document.documentElement.setAttribute('data-bs-theme', theme)
|
||||
if (theme === 'dark') {
|
||||
dark_theme.checked = true
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in new issue
Block a user