Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
Testat RockPaperScissoirs
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Operate
Terraform modules
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OST
WE1
Testat RockPaperScissoirs
Compare revisions
2dac8c891237ab7cac31196c40fc03693e9fc2d8 to 1557e234964f3962cec0f53ac772a4bbc2847a91
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
ost/we1/testat-rockpaperscissoirs
Select target project
No results found
1557e234964f3962cec0f53ac772a4bbc2847a91
Select Git revision
Swap
Target
ost/we1/testat-rockpaperscissoirs
Select target project
ost/we1/testat-rockpaperscissoirs
1 result
2dac8c891237ab7cac31196c40fc03693e9fc2d8
Select Git revision
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (3)
main.js peer review fixups
· 7b117861
Andri Joos
authored
2 years ago
7b117861
html peer review fixups
· 41969e06
Andri Joos
authored
2 years ago
41969e06
css peer review fixups
· 1557e234
Andri Joos
authored
2 years ago
1557e234
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
TestatVorlage/schere-stein-papier.html
+1
-1
1 addition, 1 deletion
TestatVorlage/schere-stein-papier.html
TestatVorlage/scripts/main.js
+39
-15
39 additions, 15 deletions
TestatVorlage/scripts/main.js
TestatVorlage/styles/global.css
+16
-0
16 additions, 0 deletions
TestatVorlage/styles/global.css
with
56 additions
and
16 deletions
TestatVorlage/schere-stein-papier.html
View file @
1557e234
...
...
@@ -11,7 +11,7 @@
<div
id=
"login"
>
<form
id=
"login-form"
>
<label
for=
"username"
>
Username:
</label>
<label
for=
"username
-input
"
>
Username:
</label>
<input
id=
"username-input"
placeholder=
"Please enter an username"
>
<button
type=
"submit"
>
Let's Go!
</button>
</form>
...
...
This diff is collapsed.
Click to expand it.
TestatVorlage/scripts/main.js
View file @
1557e234
...
...
@@ -26,7 +26,10 @@ const historyTableBody = document.querySelector('#history');
const
usernameDisplay
=
document
.
querySelector
(
'
#username-display
'
);
let
username
=
''
;
const
notWonColor
=
'
black
'
;
const
notWonClass
=
'
lost-draw-color
'
;
const
wonClass
=
'
win-color
'
;
const
visibleClass
=
'
visible
'
;
const
hiddenClass
=
'
hidden
'
;
function
addToHistory
(
userHand
,
opponentHand
,
winText
)
{
historyTableBody
.
innerHTML
+=
`<tr><td>
${
winText
}
</td>\t<td>
${
userHand
}
</td>\t<td>
${
opponentHand
}
\n</td></tr>`
;
...
...
@@ -34,16 +37,15 @@ function addToHistory(userHand, opponentHand, winText) {
function
handleOpponentPicked
(
userHand
,
opponentHand
,
gameEval
)
{
opponentHandLabel
.
innerText
=
opponentHand
;
const
winColor
=
'
green
'
;
let
winText
;
// eslint-disable-next-line @web-and-design/wed/use-action-map
if
(
gameEval
<
0
)
{
winText
=
'
Lost
'
;
opponentHandLabel
.
style
.
borderColor
=
w
i
nC
olor
;
opponentHandLabel
.
classList
.
replace
(
notWonClass
,
w
o
nC
lass
)
;
}
else
if
(
gameEval
>
0
)
{
winText
=
'
Won
'
;
playerHandLabel
.
style
.
borderColor
=
w
i
nC
olor
;
playerHandLabel
.
classList
.
replace
(
notWonClass
,
w
o
nC
lass
)
;
}
else
{
winText
=
'
Draw
'
;
}
...
...
@@ -69,8 +71,14 @@ function onOptionClick() {
playerHandLabel
.
innerText
=
userHand
;
opponentHandLabel
.
innerText
=
'
\n
'
;
playerHandLabel
.
style
.
borderColor
=
notWonColor
;
opponentHandLabel
.
style
.
borderColor
=
notWonColor
;
// eslint-disable-next-line @web-and-design/wed/use-action-map
if
(
playerHandLabel
.
classList
.
contains
(
wonClass
))
{
playerHandLabel
.
classList
.
replace
(
wonClass
,
notWonClass
);
}
if
(
opponentHandLabel
.
classList
.
contains
(
wonClass
))
{
opponentHandLabel
.
classList
.
replace
(
wonClass
,
notWonClass
);
}
evaluateHand
(
username
,
userHand
,
({
systemHand
,
...
...
@@ -78,24 +86,40 @@ function onOptionClick() {
})
=>
handleOpponentPicked
(
userHand
,
systemHand
,
gameEval
));
}
// used to switch between login screen and game screen
function
setScreenVisible
(
enablePlayScreen
)
{
const
hidden
=
'
none
'
;
const
visible
=
'
block
'
;
if
(
enablePlayScreen
)
{
loginScreen
.
style
.
display
=
hidden
;
gameScreen
.
style
.
display
=
visible
;
// eslint-disable-next-line @web-and-design/wed/use-action-map
if
(
loginScreen
.
classList
.
contains
(
visibleClass
))
{
loginScreen
.
classList
.
remove
(
visibleClass
);
}
if
(
gameScreen
.
classList
.
contains
(
hiddenClass
))
{
gameScreen
.
classList
.
remove
(
hiddenClass
);
}
loginScreen
.
classList
.
add
(
hiddenClass
);
gameScreen
.
classList
.
add
(
visibleClass
);
}
else
{
gameScreen
.
style
.
display
=
hidden
;
loginScreen
.
style
.
display
=
visible
;
// eslint-disable-next-line @web-and-design/wed/use-action-map
if
(
loginScreen
.
classList
.
contains
(
hiddenClass
))
{
loginScreen
.
classList
.
remove
(
hiddenClass
);
}
if
(
gameScreen
.
classList
.
contains
(
visibleClass
))
{
gameScreen
.
classList
.
remove
(
visibleClass
);
}
loginScreen
.
classList
.
add
(
visibleClass
);
gameScreen
.
classList
.
add
(
hiddenClass
);
}
}
function
resetGameScreen
()
{
historyTableBody
.
innerText
=
''
;
playerHandLabel
.
style
.
borderColor
=
notWonC
olor
;
opponentHandLabel
.
style
.
borderColor
=
notWonC
olor
;
playerHandLabel
.
classList
.
add
(
notWonC
lass
)
;
opponentHandLabel
.
classList
.
add
(
notWonC
lass
)
;
playerHandLabel
.
innerText
=
''
;
opponentHandLabel
.
innerText
=
''
;
...
...
This diff is collapsed.
Click to expand it.
TestatVorlage/styles/global.css
View file @
1557e234
...
...
@@ -44,3 +44,19 @@ td {
#game-table
{
margin
:
auto
;
}
.win-color
{
color
:
green
;
}
.lost-draw-color
{
color
:
black
;
}
.hidden
{
display
:
none
;
}
.visible
{
display
:
block
;
}
This diff is collapsed.
Click to expand it.