MCPcopy Create free account
hub / github.com/cfwuya1/sublink-worker-admin / customPathFunctions

Function customPathFunctions

src/htmlBuilder.js:560–608  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

558`;
559
560const customPathFunctions = () => `
561 function saveCustomPath() {
562 const el = document.getElementById('customShortCode');
563 if (!el) return;
564 const customPath = el.value;
565 if (customPath) {
566 let savedPaths = JSON.parse(localStorage.getItem('savedCustomPaths') || '[]');
567 if (!savedPaths.includes(customPath)) {
568 savedPaths.push(customPath);
569 localStorage.setItem('savedCustomPaths', JSON.stringify(savedPaths));
570 updateSavedPathsDropdown();
571 }
572 }
573 }
574 function updateSavedPathsDropdown() {
575 const dropdown = document.getElementById('savedCustomPaths');
576 if(!dropdown) return;
577 const savedPaths = JSON.parse(localStorage.getItem('savedCustomPaths') || '[]');
578 dropdown.innerHTML = '<option value="">${t('savedPaths')}</option>';
579 savedPaths.forEach(path => {
580 const option = document.createElement('option');
581 option.value = path;
582 option.textContent = path;
583 dropdown.appendChild(option);
584 });
585 }
586 function loadSavedCustomPath() {
587 const dropdown = document.getElementById('savedCustomPaths');
588 const customShortCode = document.getElementById('customShortCode');
589 if (dropdown && customShortCode && dropdown.value) {
590 customShortCode.value = dropdown.value;
591 }
592 }
593 function deleteSelectedPath() {
594 const dropdown = document.getElementById('savedCustomPaths');
595 if(!dropdown || !dropdown.value) return;
596 let savedPaths = JSON.parse(localStorage.getItem('savedCustomPaths') || '[]');
597 savedPaths = savedPaths.filter(path => path !== dropdown.value);
598 localStorage.setItem('savedCustomPaths', JSON.stringify(savedPaths));
599 updateSavedPathsDropdown();
600 if(document.getElementById('customShortCode')) document.getElementById('customShortCode').value = '';
601 }
602 document.addEventListener('DOMContentLoaded', function() {
603 if(document.getElementById('savedCustomPaths')) {
604 updateSavedPathsDropdown();
605 document.getElementById('savedCustomPaths').addEventListener('change', loadSavedCustomPath);
606 }
607 });
608`;

Callers 1

generateScriptsFunction · 0.85

Calls 1

tFunction · 0.90

Tested by

no test coverage detected