2022-03-23 19:30:44 +03:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
2022-09-18 15:16:35 +03:00
|
|
|
<head>
|
|
|
|
<style>
|
|
|
|
#response {
|
|
|
|
white-space: pre-wrap;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</head>
|
2022-03-23 19:30:44 +03:00
|
|
|
|
2022-09-18 15:16:35 +03:00
|
|
|
<body>
|
|
|
|
<div id="window-label"></div>
|
|
|
|
<div id="container"></div>
|
|
|
|
<div id="response"></div>
|
2022-03-23 19:30:44 +03:00
|
|
|
|
2022-09-18 15:16:35 +03:00
|
|
|
<script>
|
2023-07-12 14:44:26 +03:00
|
|
|
const WebviewWindow = window.__TAURI__.window.WebviewWindow
|
|
|
|
const thisTauriWindow = window.__TAURI__.window.getCurrent()
|
|
|
|
const windowLabel = thisTauriWindow.label
|
|
|
|
const windowLabelContainer = document.getElementById('window-label')
|
2022-09-18 15:16:35 +03:00
|
|
|
windowLabelContainer.innerText = 'This is the ' + windowLabel + ' window.'
|
2022-03-23 19:30:44 +03:00
|
|
|
|
2023-07-12 14:44:26 +03:00
|
|
|
const container = document.getElementById('container')
|
2022-03-23 19:30:44 +03:00
|
|
|
|
2023-07-12 14:44:26 +03:00
|
|
|
const responseContainer = document.getElementById('response')
|
2022-09-18 15:16:35 +03:00
|
|
|
function runCommand(commandName, args, optional) {
|
2023-11-20 23:53:13 +03:00
|
|
|
window.__TAURI__.core
|
2022-09-18 15:16:35 +03:00
|
|
|
.invoke(commandName, args)
|
|
|
|
.then((response) => {
|
|
|
|
responseContainer.innerText += `Ok(${response})\n\n`
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
responseContainer.innerText += `Err(${error})\n\n`
|
|
|
|
})
|
|
|
|
}
|
|
|
|
window.__TAURI__.event.listen('tauri://window-created', function (event) {
|
|
|
|
responseContainer.innerText += 'Got window-created event\n\n'
|
|
|
|
})
|
2022-03-23 19:30:44 +03:00
|
|
|
|
2023-07-12 14:44:26 +03:00
|
|
|
const createWindowButton = document.createElement('button')
|
|
|
|
const windowId = Math.random().toString().replace('.', '')
|
|
|
|
const windowNumber = 1
|
2022-05-06 02:57:32 +03:00
|
|
|
createWindowButton.innerHTML = 'Create child window ' + windowNumber
|
2022-09-18 15:16:35 +03:00
|
|
|
createWindowButton.addEventListener('click', function () {
|
|
|
|
runCommand('create_child_window', {
|
|
|
|
id: `child-${windowId}-${windowNumber}`
|
|
|
|
})
|
|
|
|
windowNumber += 1
|
|
|
|
createWindowButton.innerHTML = 'Create child window ' + windowNumber
|
|
|
|
})
|
|
|
|
container.appendChild(createWindowButton)
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|