Files
FixIt/assets/js/pages/link.js
T
Cell 09e08d0772 refactor!: migrate theme assets from css to scss and centralize deprecation detection (#735)
**Breaking changes**:

1. Legacy custom style/script files are no longer loaded automatically.
2. Users must migrate custom files to:
   - `custom.scss`
   - `override.scss`
   - `_variables.scss`
   - `assets/js/custom.js`

**Migration guide**:

1. Move `assets/css/_custom.scss` to `assets/scss/custom.scss`.
2. Move `assets/css/_override.scss` to `assets/scss/override.scss`.
3. Keep variables in `assets/scss/_variables.scss`.
4. Move `assets/js/_custom.js` to `assets/js/custom.js`.
5. Rebuild site and verify no deprecation warnings remain.
2026-04-19 13:34:01 +08:00

45 lines
1.2 KiB
JavaScript

/**
* for link redirection page
*/
import { createCopyText } from '../utils/common';
const copyText = createCopyText();
function initLinkGuard() {
const params = new URLSearchParams(window.location.search);
const target = params.get('target');
const targetElement = document.querySelector('.target');
const copyBtn = document.querySelector('.copy-btn');
const confirmBtn = document.querySelector('.confirm-btn');
if (target) {
targetElement.textContent = target;
copyBtn.disabled = false;
confirmBtn.disabled = false;
copyBtn.addEventListener('click', () =>{
copyText(target).then(() => {
copyBtn.toggleAttribute('data-copied', true);
setTimeout(() => {
copyBtn.toggleAttribute('data-copied', false);
}, 2000);
}, () => {
console.error('Clipboard write failed!', 'Your browser does not support clipboard API!');
});
});
confirmBtn.addEventListener('click', () => {
window.location.href = target;
});
} else {
targetElement.textContent = 'Invalid target URL';
}
}
if (document.readyState !== 'loading') {
initLinkGuard();
} else {
document.addEventListener('DOMContentLoaded', initLinkGuard, false);
}