whisper.cat/weboasis/js/custom-items-menu.min.js

8 lines
2.8 KiB
JavaScript
Raw Permalink Normal View History

2023-10-05 23:28:32 +11:00
function openCustomLinksNav(){document.getElementById("custom_links_nav").style.width="250px";document.CustomLinksNavOpened=!0}function closeCustomLinksNav(){document.getElementById("custom_links_nav").style.width="0";document.CustomLinksNavOpened=!1}function getCustomLinkItems(){return localStorage.getItem("menu-items")?JSON.parse(localStorage.getItem("menu-items")):{}}function storeCustomLinkItems(a){localStorage.setItem("menu-items",JSON.stringify(a))}
function getDefaultSystemLinks(){return window.linkMenu}
function buildCustomUserLinksMenu(){for(var a=getCustomLinkItems(),b=Object.keys(a),c=[],d=0;d<b.length;d++)if(!(2>a[b[d]].length)){c.push('<li class="cat-separator">\n\t\t'+(0==d?"":"<hr/>")+"\n\t\t<a > <span>"+b[d]+"</span></a>\n\t\t<hr/>\n\t\t</li>");for(var e=1;e<a[b[d]].length;e++)c.push('<li>\n\t\t\t<span class="remove-custom-link"\n\t\t\tdata-category="'+b[d]+'"\n\t\t\tdata-index="'+e+"\"\n\t\t\tonclick=\"customLinkRemoveConfirmation(event)\" >x</span>\n\t\t\t<a target='_blank' class='cat-item' href=\""+a[b[d]][e][1]+
'">'+a[b[d]][e][0]+"</a></li>")}document.getElementById("userCustomLinks").innerHTML=c.join("\n")}function getCustomLinkItemsCatImage(a){var b=getDefaultSystemLinks();return b[a]?b[a][0]:[]}function addCustomLinkToLinkItems(a,b,c,d){var e=getCustomLinkItems();e[c]||(e[c]=[],e[c].push([d]));e[c].push([b,a,""]);return e}function addCustomLinkToMenu(a,b,c,d){storeCustomLinkItems(addCustomLinkToLinkItems(a,b,c,d));buildCustomUserLinksMenu();perfectSrollBars.customLinks.update()}
function removeCustomLink(a,b){for(var c=getCustomLinkItems(),d=[],e=0;e<c[a].length;e++)e!=b&&d.push(c[a][e]);2>d.length?delete c[a]:c[a]=d;storeCustomLinkItems(c);buildCustomUserLinksMenu()}
function customLinkRemoveConfirmation(a){var b=a.srcElement.attributes["data-category"].nodeValue,c=a.srcElement.attributes["data-index"].nodeValue;a=getCustomLinkItems()[b][c][0];confirmModal.style.display="block";overlay.style.display="block";document.getElementById("modal-label").innerHTML=a;document.getElementById("deleteLink").addEventListener("click",function(){removeCustomLink(b,c);confirmModal.style.display="none";overlay.style.display="none"},{once:!0})}var perfectSrollBars={customLinks:null};
function setPerfectScrollbar(){perfectSrollBars.customLinks=new PerfectScrollbar("#userCustomLinks");perfectSrollBars.customLinks.update();document.getElementById("userCustomLinks").scrollTop=0;document.querySelector("#userCustomLinks>div.ps__rail-y").style.opacity=1}
(function(){var a=setInterval(function(){if(linkMenu){try{buildCustomUserLinksMenu(),window.addLinkToMenu=function(a,c,d){d=document.getElementById("custom-category-name").value;var b=document.getElementById("custom-category-color").value;addCustomLinkToMenu(a,c,d,b)},setPerfectScrollbar()}catch(b){console.log(b)}clearInterval(a)}},30)})();