Refactor to only have one function registerMenuCommand
When selected custom menu is removed, go to settings menu Allow iframe in custom menu to use Scripting API Return menu object when it is registered, can call remove function on it
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Custom Iframe Menu</title>
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://workadventu.re/">GO TO WA BY IFRAME</a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,20 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>API in iframe menu</title>
|
||||
<script>
|
||||
var script = document.createElement('script');
|
||||
// Don't do this at home kids! The "document.referrer" part is actually inserting a XSS security.
|
||||
// We are OK in this precise case because the HTML page is hosted on the "maps" domain that contains only static files.
|
||||
script.setAttribute('src', document.referrer + 'iframe_api.js');
|
||||
document.head.appendChild(script);
|
||||
window.addEventListener('load', () => {
|
||||
WA.chat.sendChatMessage('The iframe opened by a script works !', 'Mr Robot');
|
||||
})
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<p>This iframe send you a message in the chat.</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -8,7 +8,7 @@
|
||||
script.setAttribute('src', document.referrer + 'iframe_api.js');
|
||||
document.head.appendChild(script);
|
||||
window.addEventListener('load', () => {
|
||||
WA.ui.registerMenuIframe('test', 'customIframeMenu.html');
|
||||
WA.ui.registerMenuCommand('test', 'customIframeMenu.html', {autoClose: true});
|
||||
})
|
||||
</script>
|
||||
</head>
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
let menuIframeApi = undefined;
|
||||
|
||||
WA.ui.registerMenuCommand('TO WA', () => {
|
||||
WA.nav.openTab("https://workadventu.re/");
|
||||
})
|
||||
|
||||
WA.ui.registerMenuCommand('TO WA BY IFRAME', {iframe: 'customIframeMenu.html'});
|
||||
|
||||
WA.room.onEnterZone('iframeMenu', () => {
|
||||
menuIframeApi = WA.ui.registerMenuCommand('IFRAME USE API', {iframe: 'customIframeMenuApi.html', allowApi: true});
|
||||
})
|
||||
|
||||
WA.room.onLeaveZone('iframeMenu', () => {
|
||||
menuIframeApi.remove();
|
||||
})
|
||||
Reference in New Issue
Block a user