Merge branch 'AlexxIT:master' into monaco-editor-141225

This commit is contained in:
Sergey Krashevich
2025-12-20 12:54:14 -08:00
committed by GitHub
21 changed files with 1935 additions and 256 deletions
+82
View File
@@ -413,6 +413,88 @@
</script>
<button id="xiaomi">Xiaomi</button>
<div>
<form id="xiaomi-login-form">
<input type="text" name="username" placeholder="username" required>
<input type="password" name="password" placeholder="password" required>
<button type="submit">login</button>
</form>
<form id="xiaomi-captcha-form">
<img id="xiaomi-captcha">
<input type="text" name="captcha" placeholder="captcha" required size="10">
<button type="submit">send</button>
</form>
<form id="xiaomi-verify-form">
<label id="xiaomi-verify"></label>
<input type="text" name="verify" placeholder="verify" required size="10">
<button type="submit">send</button>
</form>
<form id="xiaomi-devices-form">
<select id="xiaomi-id" name="id" required></select>
<select name="region" required>
<option value="cn">China</option>
<option value="de">Europe</option>
<option value="i2">India</option>
<option value="ru">Russia</option>
<option value="sg">Singapore</option>
<option value="us">United States</option>
</select>
<button type="submit">load devices</button>
</form>
<table id="xiaomi-table"></table>
</div>
<script>
async function xiaomiReload(ev) {
if (ev) ev.target.nextElementSibling.style.display = 'grid';
document.getElementById('xiaomi-login-form').style.display = 'flex';
document.getElementById('xiaomi-captcha-form').style.display = 'none';
document.getElementById('xiaomi-verify-form').style.display = 'none';
const r = await fetch('api/xiaomi', {'cache': 'no-cache'});
const data = await r.json();
const users = document.getElementById('xiaomi-id');
users.innerHTML = data.map(item => `<option value="${item}">${item}</option>`).join('');
}
document.getElementById('xiaomi').addEventListener('click', xiaomiReload);
async function xiaomiLogin(ev) {
ev.preventDefault();
const params = new URLSearchParams(new FormData(ev.target));
const r = await fetch('api/xiaomi', {method: 'POST', body: params});
if (r.status === 401) {
/** @type {{captcha: string, verify_email: string, verify_phone: string}} */
const data = await r.json();
document.getElementById('xiaomi-login-form').style.display = 'none';
if (data.captcha) {
document.getElementById('xiaomi-captcha-form').style.display = 'flex';
document.getElementById('xiaomi-captcha').src = 'data:image/jpeg;base64,' + data.captcha;
} else {
document.getElementById('xiaomi-verify-form').style.display = 'flex';
document.getElementById('xiaomi-verify').innerText = data.verify_email || data.verify_phone;
}
} else if (r.ok) {
alert('OK');
xiaomiReload();
} else {
alert('ERROR: ' + await r.text());
}
}
document.getElementById('xiaomi-login-form').addEventListener('submit', xiaomiLogin);
document.getElementById('xiaomi-captcha-form').addEventListener('submit', xiaomiLogin);
document.getElementById('xiaomi-verify-form').addEventListener('submit', xiaomiLogin);
document.getElementById('xiaomi-devices-form').addEventListener('submit', async ev => {
ev.preventDefault();
const params = new URLSearchParams(new FormData(ev.target));
await getSources('xiaomi-table', 'api/xiaomi?' + params.toString());
});
</script>
<button id="webtorrent">WebTorrent Shares</button>
<div>
<table id="webtorrent-table"></table>
+3 -3
View File
@@ -2,9 +2,9 @@
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="apple-touch-icon" href="https://alexxit.github.io/go2rtc/icons/apple-touch-icon-180x180.png" sizes="180x180">
<link rel="icon" href="https://alexxit.github.io/go2rtc/icons/favicon.ico">
<link rel="manifest" href="https://alexxit.github.io/go2rtc/manifest.json">
<link rel="apple-touch-icon" href="https://go2rtc.org/icons/apple-touch-icon-180x180.png" sizes="180x180">
<link rel="icon" href="https://go2rtc.org/icons/favicon.ico">
<link rel="manifest" href="https://go2rtc.org/manifest.json">
<title>stream - go2rtc</title>
<style>
body {