update copy process, removed binary
This commit is contained in:
76
main.go
76
main.go
@@ -9,7 +9,8 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
passwordLength = 32
|
passwordLength = 32
|
||||||
chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!?§$%&=#+<>-:,.;_*@"
|
chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
||||||
|
//chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!?$%&=#+<>-:,.;_*@"
|
||||||
)
|
)
|
||||||
|
|
||||||
func generatePassword() string {
|
func generatePassword() string {
|
||||||
@@ -109,7 +110,7 @@ func helpHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
func webHandler(w http.ResponseWriter, r *http.Request) {
|
func webHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
password := generatePassword()
|
password := generatePassword()
|
||||||
html := fmt.Sprintf(
|
html := fmt.Sprintf(
|
||||||
`<DOCTYPE html>
|
`<DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
@@ -153,7 +154,21 @@ func webHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
width: 90%%;
|
width: 90%%;
|
||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
}
|
}
|
||||||
button {
|
.copy-button {
|
||||||
|
background: #4CAF50;
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
padding: 0.6rem 1.2rem;
|
||||||
|
font-size: 1rem;
|
||||||
|
border-radius: 4px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background 0.2s;
|
||||||
|
margin: 0.3rem;
|
||||||
|
}
|
||||||
|
.copy-button:hover {
|
||||||
|
background: #45a049;
|
||||||
|
}
|
||||||
|
.renew-button {
|
||||||
background: #007BFF;
|
background: #007BFF;
|
||||||
color: white;
|
color: white;
|
||||||
border: none;
|
border: none;
|
||||||
@@ -164,7 +179,7 @@ func webHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
transition: background 0.2s;
|
transition: background 0.2s;
|
||||||
margin: 0.3rem;
|
margin: 0.3rem;
|
||||||
}
|
}
|
||||||
button:hover {
|
.renew-button:hover {
|
||||||
background: #0056b3;
|
background: #0056b3;
|
||||||
}
|
}
|
||||||
.help-link {
|
.help-link {
|
||||||
@@ -183,11 +198,47 @@ func webHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
}
|
}
|
||||||
|
#toast {
|
||||||
|
visibility: hidden;
|
||||||
|
min-width: 150px;
|
||||||
|
background-color: #4CAF50;
|
||||||
|
color: white;
|
||||||
|
text-align: center;
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 0.5rem;
|
||||||
|
position: fixed;
|
||||||
|
top: 20px;
|
||||||
|
right: 20px;
|
||||||
|
z-index: 1;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<a href="/help" class="help-link">?</a>
|
||||||
|
<h1>Generiertes Passwort</h1>
|
||||||
|
<div id="password">%s</div>
|
||||||
|
<div class="buttons">
|
||||||
|
<button class="copy-button" onclick="copyToClipboard()">In Zwischenablage kopieren</button>
|
||||||
|
<button class="renew-button" onclick="generateNewPassword()">Neues Passwort generieren</button>
|
||||||
|
</div>
|
||||||
|
<div id="toast">✓ Kopiert!</div>
|
||||||
|
</div>
|
||||||
<script>
|
<script>
|
||||||
function copyToClipboard() {
|
function copyToClipboard() {
|
||||||
navigator.clipboard.writeText(document.getElementById("password").innerText);
|
const password = document.getElementById("password").innerText;
|
||||||
alert("Passwort kopiert!");
|
navigator.clipboard.writeText(password).then(() => {
|
||||||
|
const toast = document.getElementById("toast");
|
||||||
|
toast.style.visibility = "visible";
|
||||||
|
setTimeout(() => {
|
||||||
|
toast.style.visibility = "hidden";
|
||||||
|
}, 1500); // Toast verschwindet nach 1,5 Sekunden
|
||||||
|
}).catch(err => {
|
||||||
|
console.error("Fehler beim Kopieren: ", err);
|
||||||
|
alert("Kopieren fehlgeschlagen. Bitte manuell kopieren: " + password);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
function generateNewPassword() {
|
function generateNewPassword() {
|
||||||
fetch("/api/password")
|
fetch("/api/password")
|
||||||
@@ -198,21 +249,10 @@ func webHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
.catch(error => console.error("Fehler:", error));
|
.catch(error => console.error("Fehler:", error));
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="container">
|
|
||||||
<a href="/help" class="help-link">?</a>
|
|
||||||
<h1>Generiertes Passwort</h1>
|
|
||||||
<div id="password">%s</div>
|
|
||||||
<div class="buttons">
|
|
||||||
<button onclick="copyToClipboard()">In Zwischenablage kopieren</button>
|
|
||||||
<button onclick="generateNewPassword()">Neues Passwort generieren</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
</body>
|
||||||
</html>`,
|
</html>`,
|
||||||
password,
|
password,
|
||||||
)
|
)
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||||
fmt.Fprint(w, html)
|
fmt.Fprint(w, html)
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user