1var getSaveBookmarkResourceURL; 2var HP = HP || {}; 3HP.PFP = HP.PFP || {}; 4HP.PFP.Bookmark = HP.PFP.Bookmark || {}; 5 6HP.PFP.Bookmark.bookmarkResource = function (url, isPageReloaded) { 7 const bookmarkIcon = document.getElementById("bookmarkIconId"); 8 bookmarkIcon.removeAttribute("data-title"); 9 Liferay.Util.fetch(url , { 10 headers: { 11 'currentUrl': Liferay.ThemeDisplay.getPortalURL() + Liferay.currentURL 12 } 13 }).then(function(response) { 14 return response.json(); 15 }).then(function(response) { 16 if(response && response.status) { 17 bookmarkIcon.classList.remove("bookmark-portlet-on"); 18 bookmarkIcon.classList.remove("disabled"); 19 bookmarkIcon.classList.add("bookmark-portlet-off"); 20 bookmarkIcon.setAttribute("data-title", response.tooltip); 21 } else { 22 const getBookmarksCountResourceURL = Liferay.Util.PortletURL.createResourceURL(Liferay.ThemeDisplay.getLayoutURL(), { 23 p_p_id: document.getElementById("bookmark_module_namespace").value, 24 p_p_resource_id: '/bookmarks/get_count' 25 }); 26 Liferay.Util.fetch(getBookmarksCountResourceURL) 27 .then(function(response) { 28 return response.json(); 29 }).then(function(response) { 30 if(response && response.status) { 31 if(response.count >= response.maxCount) { 32 bookmarkIcon.classList.add("bookmark-portlet-on"); 33 bookmarkIcon.classList.remove("bookmark-portlet-off"); 34 bookmarkIcon.classList.add("disabled"); 35 bookmarkIcon.setAttribute("data-title", response.tooltip); 36 } else { 37 bookmarkIcon.classList.remove("bookmark-portlet-off"); 38 bookmarkIcon.classList.remove("disabled"); 39 bookmarkIcon.classList.add("bookmark-portlet-on"); 40 bookmarkIcon.setAttribute("data-title", response.tooltip); 41 } 42 } 43 }).catch(() => { 44 console.log("catch block") 45 } 46 ); 47 } 48 49 if(!isPageReloaded) HP.PFP.Bookmark.hideElementWithDelay("bookmark-status-msg", 5000, response.message); 50 51 const hpSidebar = document.getElementsByClassName("hp-sidebar"); 52 if(!isPageReloaded && response.status && hpSidebar && !hpSidebar[0].classList.contains('active') && hpSidebar[0].innerHTML.trim() !== "") { 53 handleSideBar(); 54 isPageReloaded = true; 55 } 56 57 if(!isPageReloaded && hpSidebar.length > 0 && hpSidebar[0].classList.contains('active')) { 58 closeEditWorkspaceView(); 59 } 60 61 let workspaceWidgetList = document.getElementById("my_workspace"); 62 if(workspaceWidgetList && workspaceWidgetList.innerHTML.trim() === "") { 63 workspaceWidgetList.innerHTML = '<div id="empty-msg" class="accordion-header"><p class="container">'+'Your\x20menu\x20is\x20empty\x2e\x20If\x20you\x20want\x20to\x20customize\x20it\x2c\x20click\x20\x26quot\x3bCustomize\x2e\x26quot\x3b'+'</p></div>'; 64 } 65 }).catch(() => { 66 console.log("catch block") 67 }); 68} 69 70HP.PFP.Bookmark.hideElementWithDelay = function(elementId, delay, statusMessage) { 71 const element = document.getElementById(elementId); 72 element.removeAttribute("style"); 73 element.innerText = statusMessage; 74 75 setTimeout(() => { 76 element.style.transition = 'opacity 5s ease-in-out'; 77 element.style.opacity = 0; 78 }, delay); 79} 80 81Liferay.on( 82 "allPortletsReady", 83 84 function () { 85 if(document.getElementById("bookmark_module_namespace")) { 86 const getBookmarkStatusResourceURL = Liferay.Util.PortletURL.createResourceURL(Liferay.ThemeDisplay.getLayoutURL(), { 87 p_p_id: document.getElementById("bookmark_module_namespace").value, 88 p_p_resource_id: '/bookmark/get_status' 89 }); 90 91 HP.PFP.Bookmark.bookmarkResource(getBookmarkStatusResourceURL, true); 92 } 93 } 94); 95if(document.getElementById("bookmark_module_namespace")) { 96 getSaveBookmarkResourceURL = Liferay.Util.PortletURL.createResourceURL(Liferay.ThemeDisplay.getLayoutURL(), { 97 p_p_id: document.getElementById("bookmark_module_namespace").value, 98 p_p_resource_id: '/bookmark/save_bookmark' 99 }); 100}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.