forked from Steven/NginxInstaller
Compare commits
No commits in common. "1653e2dfae4752b7f7f88ef61570f497443c3cc2" and "8db5a839e6a9ed4798018d0b338efa19ceb4d143" have entirely different histories.
1653e2dfae
...
8db5a839e6
38
app.js
38
app.js
@ -1,8 +1,5 @@
|
|||||||
document.getElementById("submit").addEventListener("click", generateQuickCmd, false);
|
document.getElementById("submit").addEventListener("click", generateQuickCmd, false);
|
||||||
|
|
||||||
const debug = true; // DISABLE FOR PRODUCTION
|
|
||||||
const baseURL = debug ? "http://localhost:8081/ngx" : "https://dev.nevets.tech/ngx";
|
|
||||||
|
|
||||||
const service = "[Unit]\n" +
|
const service = "[Unit]\n" +
|
||||||
"Description=The NGINX HTTP and reverse proxy server\n" +
|
"Description=The NGINX HTTP and reverse proxy server\n" +
|
||||||
"After=syslog.target network-online.target remote-fs.target nss-lookup.target\n" +
|
"After=syslog.target network-online.target remote-fs.target nss-lookup.target\n" +
|
||||||
@ -31,41 +28,30 @@ const service = "[Unit]\n" +
|
|||||||
// }
|
// }
|
||||||
// const sleep = ms => new Promise(r => setTimeout(r, ms));
|
// const sleep = ms => new Promise(r => setTimeout(r, ms));
|
||||||
|
|
||||||
|
async function getHTML() {
|
||||||
|
return fetch("corsurl" + encodeURIComponent("https://nginx.org/download/"))
|
||||||
|
.then((response)=>response.body.toString())
|
||||||
|
.then((responseJson)=>{return responseJson});
|
||||||
|
}
|
||||||
|
|
||||||
async function generateQuickCmd() {
|
async function generateQuickCmd() {
|
||||||
let nginxStr = document.getElementById("link").value;
|
let nginxStr = document.getElementById("link").value;
|
||||||
|
// if (!st.toString().includes(extractNginxVersion(nginxStr))) {
|
||||||
|
// document.getElementById("script").innerHTML = "ERROR!? Do you have a valid verison of NGINX?" + "\n<span class=\"tooltiptext\" id=\"myTooltip\">Copy to clipboard</span>";
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
if (nginxStr === "") {
|
if (nginxStr === "") {
|
||||||
document.getElementById("script").innerHTML = "ERROR!? Did you leave the NGINX Verison field blank?" + "\n<span class=\"tooltiptext\" id=\"myTooltip\">Copy to clipboard</span>";
|
document.getElementById("script").innerHTML = "ERROR!? Did you leave the NGINX Verison field blank?" + "\n<span class=\"tooltiptext\" id=\"myTooltip\">Copy to clipboard</span>";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (extractNginxVersion(nginxStr)===null || extractNginxVersion(nginxStr).includes("null")) {
|
|
||||||
document.getElementById("script").innerHTML = "ERROR!? Regex could not find the version in the input field!" + "\n<span class=\"tooltiptext\" id=\"myTooltip\">Copy to clipboard</span>";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
let reqData = "{" +
|
let reqData = "{" +
|
||||||
"\"version\":\"" + encodeURIComponent(extractNginxVersion(nginxStr)) + "\"" + "}";
|
|
||||||
let continueCycle = true;
|
|
||||||
await fetch(baseURL + "/dhv", {
|
|
||||||
method: "POST",
|
|
||||||
body: reqData,
|
|
||||||
}).then(res => res.json().then(json => {
|
|
||||||
if (json.url.includes("false")) {
|
|
||||||
document.getElementById("script").innerHTML = "ERROR!? Do you have a valid verison of NGINX?" + "\n<span class=\"tooltiptext\" id=\"myTooltip\">Copy to clipboard</span>";
|
|
||||||
continueCycle = false;
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
if (!continueCycle) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
reqData = "{" +
|
|
||||||
"\"content\":\"" + encodeURI(buildCmd()) + "\"" +
|
"\"content\":\"" + encodeURI(buildCmd()) + "\"" +
|
||||||
"}";
|
"}";
|
||||||
fetch(baseURL + "/create", {
|
|
||||||
|
fetch("https://api.nevets.tech/ngx/create", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: reqData,
|
body: reqData,
|
||||||
|
mode: "cors"
|
||||||
}).then(res => res.json().then(json => {
|
}).then(res => res.json().then(json => {
|
||||||
document.getElementById("script").innerHTML = "curl -s " + json.url + " | bash" + "\n<span class=\"tooltiptext\" id=\"myTooltip\">Copy to clipboard</span>";
|
document.getElementById("script").innerHTML = "curl -s " + json.url + " | bash" + "\n<span class=\"tooltiptext\" id=\"myTooltip\">Copy to clipboard</span>";
|
||||||
}));
|
}));
|
||||||
|
Loading…
Reference in New Issue
Block a user