EOS Feature Request: Add PageManager.getPageIds method
Posted: Thu Apr 16, 2020 4:22 pm
It would be nice to have a getPageIds method that would return an array of all page ids.
... for the explorer at heart!
https://milovana.com/forum/
Code: Select all
// Add a missing 'pages.contains(pageId)' method to EOS PageManager
// Allows checking if a given page exists or not
pages.contains || (pages.contains = function (pageId) {
// Store the original state of the page, if any.
// (pages.isEnabled will always return true for pages that don't exist)
var origState = pages.isEnabled(pageId)
// Disable the page (will not store disabled state for pages that don't exist)
pages.disable(pageId)
// If the page is now disabled, it exists. Missing pages will always return true.
var hasPage = !pages.isEnabled(pageId)
// If the page exists, restore its state to what it was when we got here
if (hasPage && origState) pages.enable(pageId)
// Return our result
return hasPage
})
Code: Select all
// Add a missing 'pages.contains(pageId)' method to EOS PageManager
// See: https://milovana.com/forum/viewtopic.php?p=288586#p288586
pages.contains||(pages.contains=function(a){var e=pages.isEnabled(a);pages.disable(a);var s=!pages.isEnabled(a);return s&&e&&pages.enable(a),s});