This repository was archived by the owner on Nov 21, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.min.js
More file actions
1 lines (1 loc) · 1.48 KB
/
script.min.js
File metadata and controls
1 lines (1 loc) · 1.48 KB
1
function openDialog(){document.getElementById("dialogContainer").style.display="block"}function closeDialog(){document.getElementById("dialogContainer").style.display="none"}function addShortcut(){var e=document.getElementById("label").value,t=document.getElementById("url").value;if(e&&t){var n={label:e,url:t},o=localStorage.getItem("shortcuts");(o=o?JSON.parse(o):[]).length>4?(o.shift(),alert("Error: You cannot add more than 5 shortcuts")):(o.push(n),localStorage.setItem("shortcuts",JSON.stringify(o)),renderShortcuts()),closeDialog(),document.getElementById("label").value="",document.getElementById("url").value=""}}function deleteShortcut(e){var t=localStorage.getItem("shortcuts");t&&((t=JSON.parse(t)).splice(e,1),localStorage.setItem("shortcuts",JSON.stringify(t)),renderShortcuts())}function renderShortcuts(){var e=localStorage.getItem("shortcuts");if(e){e=JSON.parse(e);var t=document.getElementById("shortcuts-container");t.innerHTML="",e.forEach(function(e,n){var o=document.createElement("li");o.className="shortcut";var l=document.createElement("img");l.src="https://t1.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url="+e.url+"&size=32";var r=document.createElement("a");r.innerText=e.label,r.href=e.url;var a=document.createElement("button");a.innerHTML="",a.className="delete-button",a.onclick=function(){deleteShortcut(n)},o.appendChild(l),o.appendChild(r),o.appendChild(a),t.appendChild(o)})}}window.addEventListener("load",function(){renderShortcuts()});