mirror of
https://github.com/anatolykopyl/variants.git
synced 2026-03-26 21:04:38 +00:00
Добавил валидацию кода подключения
Добавил код ошибки 404 при подключении к несуществующей комнате
This commit is contained in:
@@ -9,10 +9,15 @@
|
||||
}
|
||||
|
||||
let id;
|
||||
let invalidId = false;
|
||||
|
||||
function connect() {
|
||||
const url=`${process.env.URL}/room/?id=${id}`;
|
||||
window.location.href = url;
|
||||
if (/^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(id)) {
|
||||
const url=`${process.env.URL}/room/?id=${id}`;
|
||||
window.location.href = url;
|
||||
} else {
|
||||
invalidId = true;
|
||||
}
|
||||
}
|
||||
|
||||
const plcType = ['Лабораторная работа', 'Лаба', 'Практическая работа', 'Практика', 'Лабораторная', 'Доклад'];
|
||||
@@ -60,6 +65,7 @@
|
||||
<div class="inputWrap">
|
||||
Код подключения:<br>
|
||||
<input type="text" size="45" placeholder="43d0505c-d695-4323-9140-5d7744ec95e7" bind:value={id}>
|
||||
{#if invalidId}<span class="error-hint">Неверный формат кода :(</span>{/if}
|
||||
</div>
|
||||
<span style="text-align: center;">
|
||||
<input class="btn" type="button" value="Подключиться" on:click={connect}>
|
||||
@@ -83,6 +89,10 @@
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.error-hint {
|
||||
color: indianred;
|
||||
}
|
||||
|
||||
.btn {
|
||||
width: 15ch;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user