Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
vc-roomunlock-web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan Hartig
vc-roomunlock-web
Compare revisions
ead017b59c755a70adb338956f7208c7267f067f to 081a60efcab0ee8c8b78d933e68170857f01ead1
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
janhartig/vc-roomunlock-web
Select target project
No results found
081a60efcab0ee8c8b78d933e68170857f01ead1
Select Git revision
Branches
main
1 result
Swap
Target
janhartig/vc-roomunlock-web
Select target project
janhartig/vc-roomunlock-web
1 result
ead017b59c755a70adb338956f7208c7267f067f
Select Git revision
Branches
main
1 result
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (2)
Add error handling
· 192caccc
Jan Hartig
authored
1 year ago
192caccc
Merge branch 'dev' into 'main'
· 081a60ef
Jan Hartig
authored
1 year ago
Add error handling See merge request
!1
081a60ef
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
roomunlock.html
+116
-58
116 additions, 58 deletions
roomunlock.html
with
116 additions
and
58 deletions
roomunlock.html
View file @
081a60ef
<!DOCTYPE html>
<html
lang=
"de"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
Raumfreischaltung - PTB VC
</title>
...
...
@@ -37,20 +38,20 @@
button
:hover
{
transition
:
background-color
0.12s
ease-in-out
;
background-color
:
#45a049
;
background-color
:
green
;
}
button
:hover:disabled
{
pointer-events
:
none
;
}
#
hiddenField
{
.
hiddenField
{
margin-top
:
5rem
;
opacity
:
0
;
transition
:
opacity
0.25s
ease-in
;
}
#
hiddenField
.visible
{
.
hiddenField.visible
{
opacity
:
1
;
}
...
...
@@ -58,64 +59,121 @@
width
:
40rem
;
margin-bottom
:
1.5rem
;
}
.error
{
margin-top
:
unset
;
color
:
rgb
(
179
,
50
,
50
);
font-weight
:
bolder
;
}
</style>
</head>
<body>
<h1>
Raumfreischaltung
</h1>
<input
type=
"text"
id=
"room"
name=
"raumname"
placeholder=
"Raumname"
minlength=
"1"
>
<button
type=
"button"
onclick=
"process_form()"
id=
"unlock"
>
Freischalten
</button>
<div
id=
"hiddenField"
aria-hidden=
"true"
>
<p
id=
"urlText"
></p>
<p
id=
"urlTime"
></p>
<input
type=
"text"
id=
"roomUrl"
readonly
>
<h1>
Raumfreischaltung
</h1>
<div
id=
"hiddenFieldError"
class=
"hiddenField error"
aria-hidden=
"true"
>
<p
id=
"errorText"
>
empty
</p>
</div>
<input
type=
"text"
id=
"room"
placeholder=
"Raumname"
minlength=
2
required
>
<button
type=
"button"
onclick=
"process_form()"
id=
"unlock"
>
Freischalten
</button>
<br>
<button
id=
"copyButton"
onclick=
"copyToClipboard()"
>
Link in Zwischenablage kopieren
</button>
</div>
<script>
const
baseUrl
=
window
.
location
.
protocol
+
"
//
"
+
window
.
location
.
host
const
unlockButton
=
document
.
getElementById
(
'
unlock
'
)
const
roomField
=
document
.
getElementById
(
'
room
'
)
const
hiddenField
=
document
.
getElementById
(
'
hiddenField
'
);
const
urlText
=
document
.
getElementById
(
'
urlText
'
);
const
urlTime
=
document
.
getElementById
(
'
urlTime
'
);
const
roomUrl
=
document
.
getElementById
(
'
roomUrl
'
);
let
room
=
window
.
location
.
href
.
substring
(
window
.
location
.
href
.
lastIndexOf
(
'
/
'
)
+
1
)
if
(
room
.
length
>
2
&&
room
!==
"
raumfreischaltung
"
)
{
roomField
.
value
=
room
;
get_room
();
}
function
get_room
()
{
fetch
(
baseUrl
+
"
/unlockroom
"
,
{
method
:
"
POST
"
,
body
:
JSON
.
stringify
({
"
room
"
:
room
}),
headers
:
{
"
Content-Type
"
:
"
application/json
"
}
}).
then
(
data
=>
{
data
.
json
().
then
(
data
=>
{
urlText
.
innerHTML
=
"
Dieser Link öffnet den Raum <b>
"
+
data
.
room
+
"
</b> ohne Zertifikat.
"
;
urlTime
.
innerHTML
=
"
Gültig bis <b>
"
+
new
Date
(
Date
.
now
()
+
data
.
valid_for
*
24
*
60
*
60
*
1000
).
toLocaleDateString
()
+
"
</b>
"
;
roomUrl
.
value
=
baseUrl
+
"
/
"
+
data
.
room
+
"
?jwt=
"
+
data
.
jwt
;
<p
style=
"font-weight: bold;"
>
oder...
</p>
<button
type=
"button"
onclick=
"get_room()"
id=
"random"
>
Zufälligen Raum erstellen
</button>
<div
id=
"hiddenField"
class=
"hiddenField"
aria-hidden=
"true"
>
<p
id=
"urlText"
></p>
<p
id=
"urlTime"
></p>
<input
type=
"text"
id=
"roomUrl"
readonly
>
<br>
<button
id=
"copyButton"
onclick=
"copyToClipboard()"
>
Link in Zwischenablage kopieren
</button>
</div>
<script>
const
baseUrl
=
window
.
location
.
protocol
+
"
//
"
+
window
.
location
.
host
const
unlockButton
=
document
.
getElementById
(
'
unlock
'
)
const
randomButton
=
document
.
getElementById
(
'
random
'
)
const
roomField
=
document
.
getElementById
(
'
room
'
)
const
hiddenField
=
document
.
getElementById
(
'
hiddenField
'
);
const
hiddenFieldError
=
document
.
getElementById
(
'
hiddenFieldError
'
);
const
errorText
=
document
.
getElementById
(
'
errorText
'
);
const
urlText
=
document
.
getElementById
(
'
urlText
'
);
const
urlTime
=
document
.
getElementById
(
'
urlTime
'
);
const
roomUrl
=
document
.
getElementById
(
'
roomUrl
'
);
let
room
=
window
.
location
.
href
.
substring
(
window
.
location
.
href
.
lastIndexOf
(
'
/
'
)
+
1
)
if
(
room
!==
"
raumfreischaltung
"
&&
room
!==
""
)
{
roomField
.
value
=
room
;
if
(
room
.
length
>=
2
)
{
get_room
(
room
);
}
else
{
errorText
.
innerText
=
"
Raumname zu kurz.
"
;
hiddenFieldError
.
classList
.
add
(
"
visible
"
);
hiddenFieldError
.
ariaHidden
=
"
false
"
;
}
}
function
get_room
(
_room
)
{
hiddenFieldError
.
classList
.
remove
(
"
visible
"
);
hiddenFieldError
.
ariaHidden
=
"
true
"
;
let
_body
;
if
(
_room
)
{
_body
=
JSON
.
stringify
({
"
room
"
:
room
})
}
else
{
_body
=
"
{}
"
}
fetch
(
baseUrl
+
"
/unlockroom
"
,
{
method
:
"
POST
"
,
body
:
_body
,
headers
:
{
"
Content-Type
"
:
"
application/json
"
}
}).
then
(
response
=>
{
if
(
!
response
.
ok
)
{
errorText
.
innerText
=
"
Fehler bei der Datenabfrage. Versuchen Sie es bitte später erneut.
"
;
hiddenFieldError
.
classList
.
add
(
"
visible
"
);
hiddenFieldError
.
ariaHidden
=
"
false
"
;
}
else
{
response
.
json
().
then
(
data
=>
{
if
(
data
.
error
)
{
errorText
.
innerText
=
data
.
error
;
hiddenFieldError
.
classList
.
add
(
"
visible
"
);
hiddenFieldError
.
ariaHidden
=
"
false
"
;
}
else
{
urlText
.
innerHTML
=
"
Dieser Link öffnet den Raum <b>
"
+
data
.
room
+
"
</b> ohne Zertifikat.
"
;
urlTime
.
innerHTML
=
"
Gültig bis <b>
"
+
new
Date
(
Date
.
now
()
+
data
.
valid_for
*
24
*
60
*
60
*
1000
).
toLocaleDateString
()
+
"
</b>
"
;
roomUrl
.
value
=
baseUrl
+
"
/
"
+
data
.
room
+
"
?jwt=
"
+
data
.
jwt
;
unlockButton
.
disabled
=
true
;
randomButton
.
disabled
=
true
;
roomField
.
disabled
=
true
;
hiddenField
.
classList
.
add
(
'
visible
'
);
hiddenField
.
ariaHidden
=
"
false
"
;
}
})
}
})
})
unlockButton
.
disabled
=
true
;
roomField
.
disabled
=
true
;
hiddenField
.
classList
.
add
(
'
visible
'
);
hiddenField
.
ariaHidden
=
"
false
"
;
}
function
process_form
()
{
room
=
roomField
.
value
get_room
()
}
function
copyToClipboard
()
{
roomUrl
.
select
();
document
.
execCommand
(
'
copy
'
);
}
</script>
}
function
process_form
()
{
if
(
roomField
.
checkValidity
())
{
room
=
roomField
.
value
;
get_room
(
room
);
}
else
if
(
roomField
.
validity
.
valueMissing
)
{
errorText
.
innerText
=
"
Bitte Raumname wählen.
"
;
hiddenFieldError
.
classList
.
add
(
"
visible
"
);
hiddenFieldError
.
ariaHidden
=
"
false
"
;
}
else
if
(
roomField
.
validity
.
tooShort
)
{
errorText
.
innerText
=
"
Raumname zu kurz.
"
;
hiddenFieldError
.
classList
.
add
(
"
visible
"
);
hiddenFieldError
.
ariaHidden
=
"
false
"
;
}
}
function
copyToClipboard
()
{
roomUrl
.
select
();
document
.
execCommand
(
'
copy
'
);
}
</script>
</body>
</html>
</html>
\ No newline at end of file
This diff is collapsed.
Click to expand it.