JSFiddle - React, Tailwind, and code Playground
by musicreader
HTML
<button id="SelectWindow">
Select Window
</button>
<button id="CaptureScreenshot">
Screenshot
</button>
<button id="DetectClick">
Detect Click
</button>
<button id="ShutDownServer">
ShutDownServer
</button>
<button id="getAppVersion">
getAppVersion
</button>
<a href="ScreenshotCompanion://start?code=72HGD62723HDGAJ823ySHSH92782">test</a>
JavaScript
async function saveWindowReference() {
const response = await fetch('http://localhost:5000/save-window-reference?auth=72HGD62723HDGAJ823ySHSH92782');
const data = await response.json();
console.log(data);
}
async function captureScreenshot() {
const response = await fetch('http://localhost:5000/capture-screenshot?auth=72HGD62723HDGAJ823ySHSH92782');
const blob = await response.blob();
const url = URL.createObjectURL(blob);
const img = document.createElement('img');
img.src = url;
document.body.appendChild(img);
}
async function detectClick() {
const response = await fetch('http://localhost:5000/detect-click?auth=72HGD62723HDGAJ823ySHSH92782');
const data = await response.json();
console.log(data);
}
function getAppVersion(callback) {
fetch('http://localhost:5000/get-app-version?auth=72HGD62723HDGAJ823ySHSH92782')
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
console.log('App version:', data.version);
callback(data.version);
})
.catch(error => {
console.error('Error fetching app version:', error);
callback('Unable to fetch version');
});
}
function shutdownServer() {
fetch('http://localhost:5000/shutdown', { method: 'POST' })
.then(response => response.json())
.then(data => {
console.log(data.message); // Log server response
document.getElementById('server-status').textContent = data.message;
})
.catch(error => {
console.error('Failed to shutdown the server:', error);
document.getElementById('server-status').textContent = 'Failed to shutdown the server.';
});
}
// Example...