Remove .gitignore and add dist and node_modules (LFS for .exe)
Made-with: Cursor
This commit is contained in:
1 parent
1fc4db96c8
commit
048ab8b980
5819 files changed
+1357436
-2
No files matched your search
+21
@@ -0,0 +1,21 @@
|
||||
Copyright (c) Electron contributors
|
||||
Copyright (c) 2013-2020 GitHub Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
+164587
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:ec9a6c995c49fe99eb722a7fba85d2f5ba3c74250505f7083a31c658ee0bfceb
|
||||
size 75943420
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:67dc2a7036860a68e5312c212c31b8772ac463ed0289fcc44897867f55075e89
|
||||
size 176813568
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
+38
@@ -0,0 +1,38 @@
|
||||
# PTW Auto-Disconnect (Standalone GUI)
|
||||
|
||||
Runs your PTW monitor in a small desktop window **without opening Chrome**. It stays connected to `http://localhost:1947/_int_/sessions.html`, scans for the same keywords, and clicks Disconnect on matching rows. Logs and Monitor ON/OFF state are kept in the GUI.
|
||||
|
||||
## Requirements
|
||||
|
||||
- Node.js (LTS recommended)
|
||||
- The sessions page must be available at `http://localhost:1947/_int_/sessions.html` (start your server first)
|
||||
|
||||
## Run
|
||||
|
||||
```bash
|
||||
npm install
|
||||
npm start
|
||||
```
|
||||
|
||||
## Build an executable (optional)
|
||||
|
||||
```bash
|
||||
npm run dist
|
||||
```
|
||||
|
||||
- **`dist\PTW Auto-Disconnect Setup 2.1.0.exe`** — Installer (Start Menu, etc.).
|
||||
- **`dist\win-unpacked\`** — No-install: run **PTW Auto-Disconnect.exe** from this folder (all DLLs stay next to the exe; avoids ffmpeg.dll errors).
|
||||
|
||||
To build and also create a single zip for the no-install version:
|
||||
|
||||
```bash
|
||||
npm run dist:portable
|
||||
```
|
||||
|
||||
Then use **`dist\PTW Auto-Disconnect-no-install.zip`**: unzip anywhere and run **PTW Auto-Disconnect.exe** from the extracted folder.
|
||||
|
||||
## Behavior
|
||||
|
||||
- **Monitor ON/OFF** — Same as your script; when ON, the page is monitored and reloaded every 60 seconds.
|
||||
- **Clear** — Clears the log display (state is still persisted until you clear).
|
||||
- The page is loaded in a hidden webview inside the app; only the compact log + buttons window is visible.
|
||||
@@ -0,0 +1,3 @@
|
||||
Set sh = CreateObject("WScript.Shell")
|
||||
sh.CurrentDirectory = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName)
|
||||
sh.Run "cmd /c npm start", 0, False
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
/**
|
||||
* Ensure ffmpeg.dll is next to the exe (appOutDir) so the portable exe finds it.
|
||||
* extraFiles may place it in resources/app; copy to root if needed.
|
||||
*/
|
||||
module.exports = async function (context) {
|
||||
if (context.electronPlatformName !== 'win32') return;
|
||||
|
||||
const appOutDir = context.appOutDir;
|
||||
const rootFfmpeg = path.join(appOutDir, 'ffmpeg.dll');
|
||||
const appFfmpeg = path.join(appOutDir, 'resources', 'app', 'ffmpeg.dll');
|
||||
|
||||
if (fs.existsSync(rootFfmpeg)) return; // already in place
|
||||
|
||||
if (fs.existsSync(appFfmpeg)) {
|
||||
fs.copyFileSync(appFfmpeg, rootFfmpeg);
|
||||
}
|
||||
};
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; frame-src 'self' http: https:; connect-src 'self' http://localhost:*">
|
||||
<title>PTW Auto-Disconnect</title>
|
||||
<style>
|
||||
* { box-sizing: border-box; }
|
||||
html, body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
height: 100%;
|
||||
font-family: sans-serif;
|
||||
background: #1a1a1a;
|
||||
color: #e0e0e0;
|
||||
}
|
||||
body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 10px;
|
||||
min-height: 0;
|
||||
}
|
||||
.webview-wrap {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
overflow: hidden;
|
||||
}
|
||||
.webview-wrap webview {
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
}
|
||||
.panels {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
gap: 10px;
|
||||
min-height: 0;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
}
|
||||
.section-title { font-size: 11px; font-weight: bold; color: #aaa; margin-bottom: 4px; flex-shrink: 0; }
|
||||
#sessionsBox {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
background: rgba(0,0,0,0.6);
|
||||
color: #c0c0c0;
|
||||
font-family: monospace;
|
||||
font-size: 10px;
|
||||
padding: 6px;
|
||||
border-radius: 5px;
|
||||
border: 1px solid #444;
|
||||
scrollbar-width: thin;
|
||||
}
|
||||
#sessionsBox .sess-user-block { margin-bottom: 6px; }
|
||||
#sessionsBox .sess-user-name { color: #7eb8da; font-weight: bold; padding: 2px 0 1px 0; border-bottom: 1px solid rgba(255,255,255,0.15); }
|
||||
#sessionsBox .sess-row { padding: 1px 0 1px 10px; font-size: 9px; color: #b5b5b5; }
|
||||
#sessionsBox .sess-product { color: #b5b5b5; }
|
||||
#sessionsBox .empty { color: #777; font-style: italic; }
|
||||
#logBox {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
background: rgba(0,0,0,0.85);
|
||||
color: #00ff00;
|
||||
font-family: monospace;
|
||||
font-size: 10px;
|
||||
padding: 6px;
|
||||
border-radius: 5px;
|
||||
border: 1px solid #444;
|
||||
scrollbar-width: thin;
|
||||
}
|
||||
#logBox .empty { color: #777; font-style: italic; }
|
||||
#logBox .entry { border-bottom: 1px solid rgba(255,255,255,0.1); padding: 2px 0; }
|
||||
.controls { display: flex; gap: 8px; flex-shrink: 0; }
|
||||
.controls button {
|
||||
padding: 8px 15px;
|
||||
color: white;
|
||||
border: 1px solid white;
|
||||
cursor: pointer;
|
||||
border-radius: 20px;
|
||||
font-family: sans-serif;
|
||||
font-size: 11px;
|
||||
font-weight: bold;
|
||||
background: #333;
|
||||
}
|
||||
.controls button.toggle-on { background: #28a745; }
|
||||
.controls button.toggle-off { background: #dc3545; }
|
||||
.controls button.clear-btn { background: #6c757d; }
|
||||
.status { font-size: 10px; color: #888; margin-top: 6px; flex-shrink: 0; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="webview-wrap">
|
||||
<webview id="wv" src="http://localhost:1947/_int_/config.html" partition="persist:ptw"></webview>
|
||||
</div>
|
||||
<div class="panels">
|
||||
<div class="panel">
|
||||
<div class="section-title">Logged in</div>
|
||||
<div id="sessionsBox"><div class="empty">Loading...</div></div>
|
||||
</div>
|
||||
<div class="panel">
|
||||
<div class="section-title">Activity log</div>
|
||||
<div id="logBox"><div class="empty">Connecting...</div></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<button id="toggleBtn" class="toggle-on">MONITOR: ON</button>
|
||||
<button id="clearBtn" class="clear-btn">Clear</button>
|
||||
</div>
|
||||
<div class="status" id="status">Connected to sessions page</div>
|
||||
<script src="renderer.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
// Injected into the webview (sessions page). Runs in that page's context.
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
const TARGET_KEYWORDS = [
|
||||
'PTW_DATAEXCHANGE', 'PTW_ARC_FLASH', 'PTW_DEVEVAL', 'PTW_AFAULT',
|
||||
'PTW_DAPPER', 'PTW_COOREVAL', 'PTW_CAPTOR', 'PTW_IEC_FAULT', 'PTW_IEC61363'
|
||||
];
|
||||
|
||||
window.__ptw_logQueue = window.__ptw_logQueue || [];
|
||||
window.__ptw_running = window.__ptw_running !== false;
|
||||
|
||||
function addLog(msg) {
|
||||
const t = new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
||||
window.__ptw_logQueue.push(`[${t}] ${msg}`);
|
||||
}
|
||||
|
||||
function scanAndDisconnect() {
|
||||
if (!window.__ptw_running) return;
|
||||
const rows = document.querySelectorAll('#mydata table.list tr');
|
||||
rows.forEach(function (row) {
|
||||
const rowText = row.innerText;
|
||||
const hasMatch = TARGET_KEYWORDS.some(function (k) { return rowText.indexOf(k) !== -1; });
|
||||
if (hasMatch) {
|
||||
const disconnectLink = row.querySelector('a.sbutton');
|
||||
if (disconnectLink && disconnectLink.textContent.indexOf('Disconnect') !== -1) {
|
||||
const itemName = (rowText.split('\t')[0] || '').trim() || 'Item';
|
||||
addLog('OUT: ' + itemName);
|
||||
disconnectLink.click();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
window.__ptw_flushLogs = function () {
|
||||
const q = window.__ptw_logQueue.slice();
|
||||
window.__ptw_logQueue = [];
|
||||
return q;
|
||||
};
|
||||
|
||||
window.__ptw_setRunning = function (v) { window.__ptw_running = !!v; };
|
||||
window.__ptw_getRunning = function () { return window.__ptw_running; };
|
||||
|
||||
/** Returns list of { user, product, feature, machine, loginTime } from #mydata table.list */
|
||||
window.__ptw_getSessions = function () {
|
||||
var out = [];
|
||||
var rows = document.querySelectorAll('#mydata table.list tr');
|
||||
for (var i = 0; i < rows.length; i++) {
|
||||
if (rows[i].classList && rows[i].classList.contains('tableheader')) continue;
|
||||
var cells = rows[i].querySelectorAll('td');
|
||||
if (cells.length < 9) continue;
|
||||
var product = (cells[3] && cells[3].innerText) ? cells[3].innerText.replace(/\s+/g, ' ').trim() : '';
|
||||
var feature = (cells[4] && cells[4].innerText) ? cells[4].innerText.replace(/\s+/g, ' ').trim() : '';
|
||||
var user = (cells[6] && cells[6].innerText) ? cells[6].innerText.trim() : '';
|
||||
var machine = (cells[7] && cells[7].innerText) ? cells[7].innerText.trim() : '';
|
||||
var loginTime = (cells[8] && cells[8].innerText) ? cells[8].innerText.trim() : '';
|
||||
out.push({ user: user, product: product, feature: feature, machine: machine, loginTime: loginTime });
|
||||
}
|
||||
return out;
|
||||
};
|
||||
|
||||
var targetNode = document.getElementById('mydata') || document.body;
|
||||
var observer = new MutationObserver(function () { scanAndDisconnect(); });
|
||||
observer.observe(targetNode, { childList: true, subtree: true });
|
||||
addLog('Refreshed');
|
||||
scanAndDisconnect();
|
||||
})();
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
const { app, BrowserWindow, powerSaveBlocker } = require('electron');
|
||||
const path = require('path');
|
||||
|
||||
function createWindow() {
|
||||
// Keep system and display from sleeping while the app is running
|
||||
powerSaveBlocker.start('prevent-app-suspension');
|
||||
powerSaveBlocker.start('prevent-display-sleep');
|
||||
const win = new BrowserWindow({
|
||||
width: 320,
|
||||
height: 420,
|
||||
minWidth: 280,
|
||||
minHeight: 320,
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, 'preload.js'),
|
||||
contextIsolation: true,
|
||||
nodeIntegration: false,
|
||||
webviewTag: true,
|
||||
},
|
||||
title: 'PTW Auto-Disconnect',
|
||||
show: false,
|
||||
});
|
||||
|
||||
win.once('ready-to-show', () => win.show());
|
||||
win.loadFile('index.html');
|
||||
}
|
||||
|
||||
app.whenReady().then(createWindow);
|
||||
app.on('window-all-closed', () => app.quit());
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "ptw-auto-disconnect",
|
||||
"version": "2.1.0",
|
||||
"description": "PTW Auto-Disconnect – compact GUI, no browser window",
|
||||
"main": "main.js"
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
// Preload: main window uses no Node APIs; GUI is self-contained in renderer.
|
||||
+190
@@ -0,0 +1,190 @@
|
||||
(function () {
|
||||
const CONFIG_URL = 'http://localhost:1947/_int_/config.html';
|
||||
const SESSION_URL = 'http://localhost:1947/_int_/sessions.html';
|
||||
const STORAGE_RUNNING = 'ptw_monitor_running';
|
||||
const STORAGE_LOGS = 'ptw_persistent_logs';
|
||||
const MAX_LOGS = 30;
|
||||
const POLL_MS = 500;
|
||||
const RELOAD_MS = 60000;
|
||||
|
||||
const wv = document.getElementById('wv');
|
||||
const sessionsBox = document.getElementById('sessionsBox');
|
||||
const logBox = document.getElementById('logBox');
|
||||
const toggleBtn = document.getElementById('toggleBtn');
|
||||
const clearBtn = document.getElementById('clearBtn');
|
||||
const statusEl = document.getElementById('status');
|
||||
|
||||
let isRunning = localStorage.getItem(STORAGE_RUNNING) !== 'false';
|
||||
let savedLogs = JSON.parse(localStorage.getItem(STORAGE_LOGS) || '[]');
|
||||
let injectCode = null;
|
||||
let reloadTimer = null;
|
||||
|
||||
function renderSessions(list) {
|
||||
if (!list || list.length === 0) {
|
||||
sessionsBox.innerHTML = "<div class='empty'>No sessions</div>";
|
||||
return;
|
||||
}
|
||||
var byUser = {};
|
||||
list.forEach(function (s) {
|
||||
var u = s.user && s.user.trim() ? s.user.trim() : '(no user)';
|
||||
if (!byUser[u]) byUser[u] = [];
|
||||
byUser[u].push(s);
|
||||
});
|
||||
var users = Object.keys(byUser).sort();
|
||||
var html = [];
|
||||
users.forEach(function (user) {
|
||||
var safeUser = escapeHtml(user);
|
||||
html.push("<div class='sess-user-block'><div class='sess-user-name'>" + safeUser + "</div>");
|
||||
byUser[user].forEach(function (s) {
|
||||
var product = escapeHtml(s.product || '');
|
||||
var feature = escapeHtml(s.feature || '');
|
||||
var detail = (product + (product && feature ? " · " : "") + feature).trim();
|
||||
html.push("<div class='sess-row'>" + (detail ? "<span class='sess-product'>" + detail + "</span>" : "—") + "</div>");
|
||||
});
|
||||
html.push("</div>");
|
||||
});
|
||||
sessionsBox.innerHTML = html.join('');
|
||||
}
|
||||
|
||||
function renderLogs() {
|
||||
if (savedLogs.length === 0) {
|
||||
logBox.innerHTML = "<div class='empty'>No activity...</div>";
|
||||
} else {
|
||||
logBox.innerHTML = savedLogs.map(function (log) {
|
||||
return "<div class='entry'>" + escapeHtml(log) + '</div>';
|
||||
}).join('');
|
||||
}
|
||||
logBox.scrollTop = logBox.scrollHeight;
|
||||
}
|
||||
|
||||
function escapeHtml(s) {
|
||||
const div = document.createElement('div');
|
||||
div.textContent = s;
|
||||
return div.innerHTML;
|
||||
}
|
||||
|
||||
function addLog(msg) {
|
||||
savedLogs.push(msg);
|
||||
if (savedLogs.length > MAX_LOGS) savedLogs.shift();
|
||||
try { localStorage.setItem(STORAGE_LOGS, JSON.stringify(savedLogs)); } catch (e) {}
|
||||
renderLogs();
|
||||
}
|
||||
|
||||
function updateToggleButton() {
|
||||
toggleBtn.textContent = isRunning ? 'MONITOR: ON' : 'MONITOR: OFF';
|
||||
toggleBtn.className = isRunning ? 'toggle-on' : 'toggle-off';
|
||||
}
|
||||
|
||||
function runInWebview(fn) {
|
||||
if (!wv || !wv.executeJavaScript) return Promise.resolve();
|
||||
try {
|
||||
return wv.executeJavaScript(fn);
|
||||
} catch (e) {
|
||||
return Promise.reject(e);
|
||||
}
|
||||
}
|
||||
|
||||
function injectScript() {
|
||||
if (!injectCode) return Promise.resolve();
|
||||
return runInWebview(injectCode).catch(function (err) {
|
||||
console.warn('Inject failed', err);
|
||||
statusEl.textContent = 'Page may block scripts; check console.';
|
||||
});
|
||||
}
|
||||
|
||||
function startReloadTimer() {
|
||||
stopReloadTimer();
|
||||
if (!isRunning) return;
|
||||
reloadTimer = setInterval(function () {
|
||||
if (!isRunning) return;
|
||||
wv.reload();
|
||||
}, RELOAD_MS);
|
||||
}
|
||||
|
||||
function stopReloadTimer() {
|
||||
if (reloadTimer) {
|
||||
clearInterval(reloadTimer);
|
||||
reloadTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
function ensureConfigThenSessions() {
|
||||
var url = wv.getURL() || '';
|
||||
if (url.indexOf('config.html') === -1) return;
|
||||
statusEl.textContent = 'Checking config (rows per page)...';
|
||||
runInWebview(
|
||||
"(function(){ var el = document.getElementById('linesperpage'); if (!el) return { submitted: false, status: 'notfound' }; if (el.value === '100') return { submitted: false, status: 'already100' }; el.value = '100'; var btn = document.querySelector('a.confbutton[href*=\"doSubmitConfigUrl\"]'); if (btn) btn.click(); return { submitted: true, status: 'set' }; })()"
|
||||
).then(function (result) {
|
||||
if (result && result.status === 'already100') addLog('Config: rows per page already 100');
|
||||
else if (result && result.submitted) addLog('Config: rows per page set to 100');
|
||||
else if (result && result.status === 'notfound') addLog('Config: rows-per-page input not found');
|
||||
var delay = (result && result.submitted) ? 2500 : 600;
|
||||
setTimeout(function () {
|
||||
wv.src = SESSION_URL;
|
||||
}, delay);
|
||||
}).catch(function () {
|
||||
setTimeout(function () { wv.src = SESSION_URL; }, 500);
|
||||
});
|
||||
}
|
||||
|
||||
wv.addEventListener('did-finish-load', function () {
|
||||
var url = wv.getURL() || '';
|
||||
if (url.indexOf('config.html') !== -1) {
|
||||
ensureConfigThenSessions();
|
||||
return;
|
||||
}
|
||||
if (url.indexOf('sessions.html') === -1) return;
|
||||
statusEl.textContent = 'Connected: ' + SESSION_URL;
|
||||
injectScript().then(function () {
|
||||
return runInWebview("window.__ptw_setRunning(" + isRunning + ")");
|
||||
}).then(function () {
|
||||
if (isRunning) addLog('Refreshed');
|
||||
}).catch(function () {});
|
||||
});
|
||||
|
||||
wv.addEventListener('did-fail-load', function (e) {
|
||||
if (e.errorCode !== -3) statusEl.textContent = 'Load failed: ' + (e.errorDescription || 'check if server is running');
|
||||
});
|
||||
|
||||
setInterval(function () {
|
||||
runInWebview("(window.__ptw_flushLogs && window.__ptw_flushLogs()) || []").then(function (logs) {
|
||||
if (Array.isArray(logs) && logs.length) logs.forEach(addLog);
|
||||
}).catch(function () {});
|
||||
runInWebview("(window.__ptw_getSessions && window.__ptw_getSessions()) || []").then(function (sessions) {
|
||||
if (Array.isArray(sessions)) renderSessions(sessions);
|
||||
}).catch(function () {});
|
||||
}, POLL_MS);
|
||||
|
||||
toggleBtn.addEventListener('click', function () {
|
||||
isRunning = !isRunning;
|
||||
try { localStorage.setItem(STORAGE_RUNNING, isRunning); } catch (e) {}
|
||||
updateToggleButton();
|
||||
addLog(isRunning ? 'Resumed' : 'Paused');
|
||||
runInWebview("window.__ptw_setRunning(" + isRunning + ")").catch(function () {});
|
||||
if (isRunning) {
|
||||
wv.reload();
|
||||
startReloadTimer();
|
||||
} else {
|
||||
stopReloadTimer();
|
||||
}
|
||||
});
|
||||
|
||||
clearBtn.addEventListener('click', function () {
|
||||
savedLogs = [];
|
||||
try { localStorage.removeItem(STORAGE_LOGS); } catch (e) {}
|
||||
renderLogs();
|
||||
});
|
||||
|
||||
clearBtn.classList.add('clear-btn');
|
||||
updateToggleButton();
|
||||
renderLogs();
|
||||
|
||||
if (isRunning) startReloadTimer();
|
||||
|
||||
fetch('inject.js').then(function (r) { return r.text(); }).then(function (code) {
|
||||
injectCode = code;
|
||||
if (wv.getURL() && wv.getURL().indexOf('localhost') !== -1) injectScript();
|
||||
}).catch(function () {
|
||||
statusEl.textContent = 'Could not load inject.js';
|
||||
});
|
||||
})();
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:9b1fbf0c11c520ae714af8aa9af12cfd48503eedecd7398d8992ee94d1b4dc37
|
||||
size 107520
|
||||
Vendored
BIN
Binary file not shown.
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
+1
@@ -0,0 +1 @@
|
||||
{"file_format_version": "1.0.0", "ICD": {"library_path": ".\\vk_swiftshader.dll", "api_version": "1.0.5"}}
|
||||
Vendored
BIN
Binary file not shown.
Reference in new issue
Block a user