mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
feat: mandatory auto-generated passwords for share links + admin password copy/regeneration + password gate rate limiting
This commit is contained in:
30
app/public/assets/js/app/acces-password.js
Normal file
30
app/public/assets/js/app/acces-password.js
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* acces-password.js — copy text to clipboard helper.
|
||||
*
|
||||
* Usage:
|
||||
* copyTextToClipboard('some text')
|
||||
*
|
||||
* Provides visual feedback on the originating button.
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
window.copyTextToClipboard = function (text) {
|
||||
if (!text) return;
|
||||
navigator.clipboard.writeText(text).then(function () {
|
||||
var btn = window.event && window.event.target ? window.event.target.closest('button') : null;
|
||||
if (btn) {
|
||||
var origTitle = btn.getAttribute('title') || '';
|
||||
var origHTML = btn.innerHTML;
|
||||
btn.setAttribute('title', '\u2713 Copi\u00e9');
|
||||
btn.innerHTML = '\u2713';
|
||||
setTimeout(function () {
|
||||
btn.setAttribute('title', origTitle);
|
||||
btn.innerHTML = origHTML;
|
||||
}, 1200);
|
||||
}
|
||||
}).catch(function () {
|
||||
// Clipboard write failed — silently ignore
|
||||
});
|
||||
};
|
||||
})();
|
||||
Reference in New Issue
Block a user