EOS Feature Request: Add PageManager.getPageIds method
EOS Feature Request: Add PageManager.getPageIds method
It would be nice to have a getPageIds method that would return an array of all page ids.
Re: EOS Feature Request: Add PageManager.getPageIds method
I really wanted a way to at the very least check if a page exists or not for use in re-usable code, so the game can dynamically adapt to the pages defined in the given tease.
So here it is:
And here's a minified version:
Add the above to the start of your init script. You will now be able to use: if(pages.contains('my-page-name')) ...
Doesn't completely solve this feature request, but covers many of the use cases for it.
So here it is:
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
})
And here's a minified version:
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});
Doesn't completely solve this feature request, but covers many of the use cases for it.
Who is online
Users browsing this forum: No registered users and 4 guests