Hello. Could you tell me, please, is there a way to check if a window exists in manager by its symbolic name? hasWindow() does not except such a name. getWindow() returns empty window if it was not exists before. getWindow()...isInitialized() is always true. All I need is to check if the window "win1" exists, and if it's not, create it. Thank you. Igal (User:IKhitron)
On 2023-01-13 11:59, Igal Khitron wrote:
Hello. Could you tell me, please, is there a way to check if a window exists in manager by its symbolic name? hasWindow() does not except such a name. getWindow() returns empty window if it was not exists before. getWindow()...isInitialized() is always true. All I need is to check if the window "win1" exists, and if it's not, create it. Thank you. Igal (User:IKhitron)
There doesn't seem to be a good way to do it.
If you really wanted to, you could do it like this:
function isWindowRegistered( winManager, name ) { if ( winManager.windows[ name ] ) { return true; } if ( winManager.factory && winManager.factory.lookup( name ) ) { return true; } return false; }
However, these are not public APIs, and so I can't promise that they won't stop working in the future (or that you'll be notified when that happens).
I am curious about what you need this for, perhaps there's an easier way to achieve it. Can you share what you're building?
Hello, @matmarex, and thank you for your answer. Yes, it not looks like such a good way. The way I use for now, found it after sending that mail, is not good either, but seems to me a little better than this one, with hidden API. I wrote it as windowManager.getWindow(name) .then(function(data) {windowManager.openWindow(data);}) // (openWindow(data) above can be also openWindow(name), it's the same) .fail(function() {createMap(name); windowManager.openWindow(name);}); About your question, I've created a new version of Metro maps, with thumbnail in the article, that has a button, clicking on it opens a huge full version in a popup. I need this to be sure that I do not create some particular map twice, only if it wasn't created yet. I can give you some links to my code, if you're interested. Thanks again, Igal
בתאריך יום ב׳, 16 בינו׳ 2023, 21:59, מאת Bartosz Dziewoński < matma.rex@gmail.com>:
On 2023-01-13 11:59, Igal Khitron wrote:
Hello. Could you tell me, please, is there a way to check if a window exists in manager by its symbolic name? hasWindow() does not except such a name. getWindow() returns empty window if it was not exists before. getWindow()...isInitialized() is always true. All I need is to check if the window "win1" exists, and if it's not, create it. Thank you. Igal (User:IKhitron)
There doesn't seem to be a good way to do it.
If you really wanted to, you could do it like this:
function isWindowRegistered( winManager, name ) { if ( winManager.windows[ name ] ) { return true; } if ( winManager.factory && winManager.factory.lookup( name ) ) { return true; } return false; }
However, these are not public APIs, and so I can't promise that they won't stop working in the future (or that you'll be notified when that happens).
I am curious about what you need this for, perhaps there's an easier way to achieve it. Can you share what you're building?
-- Bartosz Dziewoński _______________________________________________ Wikitech-l mailing list -- wikitech-l@lists.wikimedia.org To unsubscribe send an email to wikitech-l-leave@lists.wikimedia.org https://lists.wikimedia.org/postorius/lists/wikitech-l.lists.wikimedia.org/
wikitech-l@lists.wikimedia.org