First version with variables that actually work
This commit is contained in:
parent
5116b82e77
commit
e65e8b2097
11 changed files with 250 additions and 50 deletions
41
maps/tests/Variables/shared_variables.html
Normal file
41
maps/tests/Variables/shared_variables.html
Normal file
|
@ -0,0 +1,41 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<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', () => {
|
||||
console.log('On load');
|
||||
WA.onInit().then(() => {
|
||||
console.log('After WA init');
|
||||
const textField = document.getElementById('textField');
|
||||
textField.value = WA.room.loadVariable('textField');
|
||||
|
||||
textField.addEventListener('change', function (evt) {
|
||||
console.log('saving variable')
|
||||
WA.room.saveVariable('textField', this.value);
|
||||
});
|
||||
|
||||
WA.room.onVariableChange('textField').subscribe((value) => {
|
||||
console.log('variable changed received')
|
||||
textField.value = value;
|
||||
});
|
||||
|
||||
document.getElementById('btn').addEventListener('click', () => {
|
||||
console.log(WA.room.loadVariable('textField'));
|
||||
document.getElementById('placeholder').innerText = WA.room.loadVariable('textField');
|
||||
});
|
||||
});
|
||||
})
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<input type="text" id="textField" />
|
||||
|
||||
<button id="btn">Display textField variable value</button>
|
||||
<div id="placeholder"></div>
|
||||
</body>
|
||||
</html>
|
|
@ -199,7 +199,15 @@
|
|||
<input type="radio" name="test-variables"> Success <input type="radio" name="test-variables"> Failure <input type="radio" name="test-variables" checked> Pending
|
||||
</td>
|
||||
<td>
|
||||
<a href="#" class="testLink" data-testmap="Variables/variables.json" target="_blank">Testing scripting variables</a>
|
||||
<a href="#" class="testLink" data-testmap="Variables/variables.json" target="_blank">Testing scripting variables locally</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="radio" name="test-shared-variables"> Success <input type="radio" name="test-shared-variables"> Failure <input type="radio" name="test-shared-variables" checked> Pending
|
||||
</td>
|
||||
<td>
|
||||
<a href="#" class="testLink" data-testmap="Variables/shared_variables.json" target="_blank">Testing shared scripting variables</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue