work in progress [might break]
/ test (push) Waiting to run Details

This commit is contained in:
Leon van Kammen 2024-04-18 18:40:06 +02:00
parent dbfc5fe8bb
commit b4969c4e39
1 changed files with 46 additions and 0 deletions

46
src/tests/eventbus.html Normal file
View File

@ -0,0 +1,46 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>eventbus for browsertabs</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<style type="text/css">
* { border-radius: 5px; font-family: Verdana; font-size:17px; }
button { border: none; background:#F0A; padding:10px; }
</style>
</head>
<body style="margin:10% 40%">
<h1>eventbus for duplicate browsertabs</h1>
1. Open this page in another,<br>
2. Copy something text to clipboard<br>
3. Click Paste in one tab
<br><Br>
<button id="paste">paste</button>
<br><br>
<pre id="out" style="border:2px solid #CCC; width:100%;height:200px"> </pre>
<script>
let out = document.querySelector('#out')
let paste = document.querySelector('#paste')
const show = (text) => out.innerHTML += `\n${window.localStorage.getItem('paste')}`
window.addEventListener("storage", show )
paste.addEventListener('click',(e) => {
navigator.clipboard.readText()
.then( (text) => {
window.localStorage.setItem('paste', text)
show()
})
})
show('connected to eventbus')
</script>
</body>
</html>