Merge branch 'develop' of github.com:thecodingmachine/workadventure into metadataScriptAPIV2

This commit is contained in:
David Négrier 2021-06-28 14:12:10 +02:00
commit 86cb118378
3 changed files with 32 additions and 9 deletions

View File

@ -199,4 +199,4 @@ jobs:
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
msg: Environment deployed at https://play-${{ env.GITHUB_HEAD_REF_SLUG }}.test.workadventu.re msg: "Environment deployed at https://play-${{ env.GITHUB_HEAD_REF_SLUG }}.test.workadventu.re \nTests available at https://maps-${{ env.GITHUB_HEAD_REF_SLUG }}.test.workadventu.re/tests"

View File

@ -1,22 +1,30 @@
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<script src="http://play.workadventure.localhost/iframe_api.js"></script> <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);
</script>
</head> </head>
<body> <body>
<button id="sendchat">Send chat message</button> <button id="sendchat">Send chat message</button>
<script> <script>
document.getElementById('sendchat').onclick = () => { document.getElementById('sendchat').onclick = () => {
WA.sendChatMessage('Hello world!', 'Mr ROBOT'); WA.chat.sendChatMessage('Hello world!', 'Mr ROBOT');
} }
</script> </script>
<div id="chatSent"></div> <div id="chatSent"></div>
<script> <script>
WA.onChatMessage((message => { window.addEventListener('load', () => {
const chatDiv = document.createElement('p'); WA.chat.onChatMessage((message => {
chatDiv.innerText = message; const chatDiv = document.createElement('p');
document.getElementById('chatSent').append(chatDiv); chatDiv.innerText = message;
})); document.getElementById('chatSent').append(chatDiv);
}));
})
</script> </script>
</body> </body>
</html> </html>

View File

@ -4,7 +4,7 @@
</head> </head>
<body> <body>
<label>Base test URL:</label> <label>Base test URL:</label>
<input id="baseurl" type="text" value="http://play.workadventure.localhost/_/global/maps.workadventure.localhost/tests/" /> <input id="baseurl" type="text" value="" />
<table> <table>
<tr> <tr>
<th>Result</th> <th>Result</th>
@ -174,6 +174,21 @@
<script> <script>
const baseInput = document.getElementById('baseurl'); const baseInput = document.getElementById('baseurl');
let host = window.location.host;
let playHost;
if (host.startsWith('maps-')) {
playHost = 'play-'+host.substr(5);
} else if (host.startsWith('maps.')) {
playHost = 'play.'+host.substr(5);
} else {
playHost = 'localhost';
}
let completeUrl = window.location.protocol + '//' + playHost + '/_/global/' + host + window.location.pathname;
baseInput.value = completeUrl;
baseInput.addEventListener('change', init); baseInput.addEventListener('change', init);
function init() { function init() {