Modified scripts and added some tooltips. Made it so that NGINX version is required instead of URL. #2
@ -8,5 +8,6 @@
 | 
				
			|||||||
    </content>
 | 
					    </content>
 | 
				
			||||||
    <orderEntry type="inheritedJdk" />
 | 
					    <orderEntry type="inheritedJdk" />
 | 
				
			||||||
    <orderEntry type="sourceFolder" forTests="false" />
 | 
					    <orderEntry type="sourceFolder" forTests="false" />
 | 
				
			||||||
 | 
					    <orderEntry type="library" name="jquery" level="application" />
 | 
				
			||||||
  </component>
 | 
					  </component>
 | 
				
			||||||
</module>
 | 
					</module>
 | 
				
			||||||
							
								
								
									
										53
									
								
								app.js
									
									
									
									
									
								
							
							
						
						
									
										53
									
								
								app.js
									
									
									
									
									
								
							@ -17,7 +17,33 @@ const service = "[Unit]\n" +
 | 
				
			|||||||
    "[Install]\n" +
 | 
					    "[Install]\n" +
 | 
				
			||||||
    "WantedBy=multi-user.target";
 | 
					    "WantedBy=multi-user.target";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function generateQuickCmd() {
 | 
					
 | 
				
			||||||
 | 
					// async function fetch1() {
 | 
				
			||||||
 | 
					//     let url = "https://thingproxy.freeboard.io/fetch/ " + encodeURIComponent("https://nginx.org/download/");
 | 
				
			||||||
 | 
					//     await $.get(url, (data, status) => {
 | 
				
			||||||
 | 
					//         console.log(data);
 | 
				
			||||||
 | 
					//         return data.body;
 | 
				
			||||||
 | 
					//     });
 | 
				
			||||||
 | 
					//     return "ERROR?";
 | 
				
			||||||
 | 
					// }
 | 
				
			||||||
 | 
					// 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() {
 | 
				
			||||||
 | 
					    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 === "") {
 | 
				
			||||||
 | 
					        document.getElementById("script").innerHTML = "ERROR!? Did you leave the NGINX Verison field blank?" + "\n<span class=\"tooltiptext\" id=\"myTooltip\">Copy to clipboard</span>";
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    let reqData = "{" +
 | 
					    let reqData = "{" +
 | 
				
			||||||
        "\"content\":\"" + encodeURI(buildCmd()) + "\"" +
 | 
					        "\"content\":\"" + encodeURI(buildCmd()) + "\"" +
 | 
				
			||||||
        "}";
 | 
					        "}";
 | 
				
			||||||
@ -27,12 +53,23 @@ function generateQuickCmd() {
 | 
				
			|||||||
        body: reqData,
 | 
					        body: reqData,
 | 
				
			||||||
        mode: "cors"
 | 
					        mode: "cors"
 | 
				
			||||||
    }).then(res => res.json().then(json => {
 | 
					    }).then(res => res.json().then(json => {
 | 
				
			||||||
        document.getElementById("script").innerText = "curl -s " + json.url + " | bash";
 | 
					        document.getElementById("script").innerHTML = "curl -s " + json.url + " | bash" + "\n<span class=\"tooltiptext\" id=\"myTooltip\">Copy to clipboard</span>";
 | 
				
			||||||
    }));
 | 
					    }));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function outFunc() {
 | 
				
			||||||
 | 
					    var tooltip = document.getElementById("myTooltip");
 | 
				
			||||||
 | 
					    tooltip.innerHTML = "Copy to clipboard";
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function copy() {
 | 
				
			||||||
 | 
					    var copyText = document.getElementById("script").innerHTML.split("<span")[0];
 | 
				
			||||||
 | 
					    var tooltip = document.getElementById("myTooltip");
 | 
				
			||||||
 | 
					    navigator.clipboard.writeText(copyText).then(r => tooltip.innerHTML = "Copied!");
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function buildCmd() {
 | 
					function buildCmd() {
 | 
				
			||||||
    let nginxStr = document.getElementById("link").value; //https://nginx.org/download/nginx-x.xx.x.tar.gz
 | 
					    let nginxStr = document.getElementById("link").value; //user input
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let script = "#!/bin/bash\n" +
 | 
					    let script = "#!/bin/bash\n" +
 | 
				
			||||||
        "if [ \"$EUID\" -ne 0 ]\n" +
 | 
					        "if [ \"$EUID\" -ne 0 ]\n" +
 | 
				
			||||||
@ -41,16 +78,16 @@ function buildCmd() {
 | 
				
			|||||||
        "fi\n\n" +
 | 
					        "fi\n\n" +
 | 
				
			||||||
        "apt-get update\n" +
 | 
					        "apt-get update\n" +
 | 
				
			||||||
        "apt-get install -y build-essential libpcre3 libpcre3-dev zlib1g zlib1g-dev libssl-dev wget git\n" +
 | 
					        "apt-get install -y build-essential libpcre3 libpcre3-dev zlib1g zlib1g-dev libssl-dev wget git\n" +
 | 
				
			||||||
        "wget " + document.getElementById("link").value + "\n" +
 | 
					        "wget https://nginx.org/download/nginx-" + extractNginxVersion(nginxStr) + ".tar.gz\n" +
 | 
				
			||||||
        "tar -xzvf " + extractNginxVersion(nginxStr) + "\n";
 | 
					        "tar -xzvf " + "nginx-" + extractNginxVersion(nginxStr) + ".tar.gz\n";
 | 
				
			||||||
        if (document.getElementById("extMod").checked === true) {
 | 
					        if (document.getElementById("extMod").checked === true) {
 | 
				
			||||||
            script += "git clone https://github.com/google/ngx_brotli.git\n" +
 | 
					            script += "git clone https://github.com/google/ngx_brotli.git\n" +
 | 
				
			||||||
            "git clone https://github.com/openresty/headers-more-nginx-module.git\n" +
 | 
					            "git clone https://github.com/openresty/headers-more-nginx-module.git\n" +
 | 
				
			||||||
            "cd ngx_brotli/\n" +
 | 
					            "cd ngx_brotli/\n" +
 | 
				
			||||||
            "git submodule update --init\n" +
 | 
					            "git submodule update --init\n" +
 | 
				
			||||||
            "cd ../" + extractNginxVersion(nginxStr).replace(/\.tar\.gz$/, '') + "/\n";
 | 
					            "cd ../nginx-" + extractNginxVersion(nginxStr) + "/\n";
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            script += "cd " + extractNginxVersion(nginxStr).replace(/\.tar\.gz$/, '') + "\n";
 | 
					            script += "cd nginx-" + extractNginxVersion(nginxStr) + "\n";
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        script += "cp -r conf /etc/nginx\n" +
 | 
					        script += "cp -r conf /etc/nginx\n" +
 | 
				
			||||||
        "mkdir /var/cache/nginx\n" +
 | 
					        "mkdir /var/cache/nginx\n" +
 | 
				
			||||||
@ -80,7 +117,7 @@ function getConfigureStr() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
function extractNginxVersion(url) {
 | 
					function extractNginxVersion(url) {
 | 
				
			||||||
    // This regex matches 'nginx' followed by a hyphen and a version number, followed by '.tar.gz'
 | 
					    // This regex matches 'nginx' followed by a hyphen and a version number, followed by '.tar.gz'
 | 
				
			||||||
    const regex = /nginx-\d+\.\d+\.\d+\.tar\.gz/;
 | 
					    const regex = /\d+\.\d+\.\d+/;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Use the regex to search the string
 | 
					    // Use the regex to search the string
 | 
				
			||||||
    const match = url.match(regex);
 | 
					    const match = url.match(regex);
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										12
									
								
								index.html
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								index.html
									
									
									
									
									
								
							@ -2,15 +2,17 @@
 | 
				
			|||||||
<html lang="en-US ">
 | 
					<html lang="en-US ">
 | 
				
			||||||
<head>
 | 
					<head>
 | 
				
			||||||
    <meta charset="UTF-8">
 | 
					    <meta charset="UTF-8">
 | 
				
			||||||
    <title>Nginx Installer</title>
 | 
					    <title>NGINX Installer</title>
 | 
				
			||||||
    <link rel="stylesheet" href="style.css">
 | 
					    <link rel="stylesheet" href="style.css">
 | 
				
			||||||
    <link href='https://fonts.googleapis.com/css?family=JetBrains Mono' rel='stylesheet'>
 | 
					    <link href='https://fonts.googleapis.com/css?family=JetBrains Mono' rel='stylesheet'>
 | 
				
			||||||
 | 
					    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.2/jquery.min.js" integrity="sha512-tWHlutFnuG0C6nQRlpvrEhE4QpkG1nn2MOUMWmUeRePl4e3Aki0VB6W1v3oLjFtd0hVOtRQ9PHpSfN6u6/QXkQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
 | 
				
			||||||
</head>
 | 
					</head>
 | 
				
			||||||
<body>
 | 
					<body>
 | 
				
			||||||
  <div class="main">
 | 
					  <div class="main">
 | 
				
			||||||
<!--    <h1 style="margin-left: auto; margin-right: auto">Nginx Script Gen</h1>-->
 | 
					    <h1 style="margin: 0 auto;">NGINX Script Gen</h1>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <label for="link" style="height: 50px">
 | 
					    <label for="link" style="height: 50px">
 | 
				
			||||||
        <p style="width: 300px; "><a href="https://nginx.org/download/" target=”_blank”>NGINX Archive Link:</a></p>
 | 
					        <a style="width: 180px; text-align: center " href="https://nginx.org/download/" target=”_blank”>NGINX Version:</a>
 | 
				
			||||||
        <input type="text" id="link" style="margin-top: 10px">
 | 
					        <input type="text" id="link" style="margin-top: 10px">
 | 
				
			||||||
    </label>
 | 
					    </label>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -33,7 +35,9 @@
 | 
				
			|||||||
    </label>
 | 
					    </label>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <button id="submit" class="centered-button">Generate Script</button>
 | 
					    <button id="submit" class="centered-button">Generate Script</button>
 | 
				
			||||||
    <code lang="bash" id="script"></code>
 | 
					    <code class="tooltip" onclick="copy()" onmouseout="outFunc()" lang="bash" id="script">
 | 
				
			||||||
 | 
					        <span class="tooltiptext" id="myTooltip">Copy to clipboard</span>
 | 
				
			||||||
 | 
					    </code>
 | 
				
			||||||
  </div>
 | 
					  </div>
 | 
				
			||||||
<script src="app.js"></script>
 | 
					<script src="app.js"></script>
 | 
				
			||||||
</body>
 | 
					</body>
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										56
									
								
								style.css
									
									
									
									
									
								
							
							
						
						
									
										56
									
								
								style.css
									
									
									
									
									
								
							@ -20,7 +20,7 @@ body {
 | 
				
			|||||||
    text-align: center;
 | 
					    text-align: center;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
p {
 | 
					p, a {
 | 
				
			||||||
    padding: 0px;
 | 
					    padding: 0px;
 | 
				
			||||||
    margin: 0px 2px 0px 0px;
 | 
					    margin: 0px 2px 0px 0px;
 | 
				
			||||||
    font-size: 14px;
 | 
					    font-size: 14px;
 | 
				
			||||||
@ -37,6 +37,7 @@ label {
 | 
				
			|||||||
    margin-left: auto;
 | 
					    margin-left: auto;
 | 
				
			||||||
    margin-right: auto;
 | 
					    margin-right: auto;
 | 
				
			||||||
    padding: 5px;
 | 
					    padding: 5px;
 | 
				
			||||||
 | 
					    text-align: center;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Adjust the spacing specifically for the first label */
 | 
					/* Adjust the spacing specifically for the first label */
 | 
				
			||||||
@ -56,6 +57,18 @@ a {
 | 
				
			|||||||
    text-decoration: none;
 | 
					    text-decoration: none;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					code {
 | 
				
			||||||
 | 
					    margin-left: auto;
 | 
				
			||||||
 | 
					    margin-right: auto;
 | 
				
			||||||
 | 
					    background-color: #b8d9ff;
 | 
				
			||||||
 | 
					    padding: 2px;
 | 
				
			||||||
 | 
					    border-radius: 5px;
 | 
				
			||||||
 | 
					    transition: background .2s ease-in;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					code:hover {
 | 
				
			||||||
 | 
					    background-color: #88a8c5;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
a:hover {
 | 
					a:hover {
 | 
				
			||||||
    text-decoration: underline;
 | 
					    text-decoration: underline;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -90,3 +103,44 @@ button:active {
 | 
				
			|||||||
    margin: 20px auto; /* Adds 20px space above and centers horizontally */
 | 
					    margin: 20px auto; /* Adds 20px space above and centers horizontally */
 | 
				
			||||||
    width: fit-content; /* Auto width to fit the button's content */
 | 
					    width: fit-content; /* Auto width to fit the button's content */
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.tooltip {
 | 
				
			||||||
 | 
					    position: relative;
 | 
				
			||||||
 | 
					    display: inline-block;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.tooltip .tooltiptext {
 | 
				
			||||||
 | 
					    visibility: hidden;
 | 
				
			||||||
 | 
					    width: 140px;
 | 
				
			||||||
 | 
					    background-color: #555;
 | 
				
			||||||
 | 
					    color: #fff;
 | 
				
			||||||
 | 
					    text-align: center;
 | 
				
			||||||
 | 
					    border-radius: 6px;
 | 
				
			||||||
 | 
					    padding: 5px;
 | 
				
			||||||
 | 
					    position: absolute;
 | 
				
			||||||
 | 
					    z-index: 1;
 | 
				
			||||||
 | 
					    bottom: 150%;
 | 
				
			||||||
 | 
					    left: 50%;
 | 
				
			||||||
 | 
					    margin-left: -75px;
 | 
				
			||||||
 | 
					    opacity: 0;
 | 
				
			||||||
 | 
					    transition: opacity 0.3s;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.tooltip .tooltiptext::after {
 | 
				
			||||||
 | 
					    content: "";
 | 
				
			||||||
 | 
					    position: absolute;
 | 
				
			||||||
 | 
					    top: 100%;
 | 
				
			||||||
 | 
					    left: 50%;
 | 
				
			||||||
 | 
					    margin-left: -5px;
 | 
				
			||||||
 | 
					    border-width: 5px;
 | 
				
			||||||
 | 
					    border-style: solid;
 | 
				
			||||||
 | 
					    border-color: #555 transparent transparent transparent;
 | 
				
			||||||
 | 
					    transition: opacity 0.3s;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.tooltip:hover .tooltiptext {
 | 
				
			||||||
 | 
					    visibility: visible;
 | 
				
			||||||
 | 
					    opacity: 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    transition: opacity 0.3s;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user