Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update server.ts #69

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions resources/js/dashboard/servers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,21 @@ function playerAction(playerName: string, action: string, serverId: string) {
}

function copyToClipboard(text) {
function showSnackbar(message) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refer bans.ts for snackbar its fairly simple these function not needed

let snackbar = document.getElementById("snackbar");
snackbar.innerHTML = message;
snackbar.className = "show";
setTimeout(() => {
snackbar.className = snackbar.className.replace("show", "");
}, 3000);
}

if (navigator.clipboard) {
navigator.clipboard.writeText(text).then(() => {
toastr.success('IP and port copied to clipboard!');
showSnackbar('IP and port copied to clipboard!');
}).catch(err => {
console.error('Failed to copy text: ', err);
toastr.error('Failed to copy IP and port.');
showSnackbar('Failed to copy IP and port.');
});
} else {
// Fallback for older browsers
Expand All @@ -131,10 +140,10 @@ function copyToClipboard(text) {
textArea.select();
try {
document.execCommand('copy');
toastr.success('IP and port copied to clipboard!');
showSnackbar('IP and port copied to clipboard!');
} catch (err) {
console.error('Fallback: Oops, unable to copy', err);
toastr.error('Failed to copy IP and port.');
showSnackbar('Failed to copy IP and port.');
}
document.body.removeChild(textArea);
}
Expand Down
Loading