Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Tabu
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
9
Issues
9
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dennis Willers
Tabu
Commits
c98b09dc
Commit
c98b09dc
authored
Dec 29, 2020
by
Dennis Willers
🏀
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
e5288479
e316e2af
Pipeline
#295
passed with stages
in 5 minutes and 14 seconds
Changes
12
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
317 additions
and
6 deletions
+317
-6
angular.json
angular.json
+7
-2
app-routing.module.ts
src/app/app-routing.module.ts
+2
-1
app.module.ts
src/app/app.module.ts
+7
-1
error.component.ts
src/app/error/error.component.ts
+1
-1
game.component.html
src/app/game/game.component.html
+1
-0
game.component.scss
src/app/game/game.component.scss
+62
-0
guesser.component.html
src/app/guesser/guesser.component.html
+14
-0
guesser.component.scss
src/app/guesser/guesser.component.scss
+57
-0
guesser.component.spec.ts
src/app/guesser/guesser.component.spec.ts
+25
-0
guesser.component.ts
src/app/guesser/guesser.component.ts
+19
-0
overview.component.html
src/app/overview/overview.component.html
+4
-1
Timer.js
src/assets/JavaScript/Timer.js
+118
-0
No files found.
angular.json
View file @
c98b09dc
...
...
@@ -34,7 +34,9 @@
"./node_modules/@angular/material/prebuilt-themes/deeppurple-amber.css"
,
"src/styles.scss"
],
"scripts"
:
[]
"scripts"
:
[
"./src/assets/JavaScript/Timer.js"
]
},
"configurations"
:
{
"production"
:
{
...
...
@@ -129,5 +131,8 @@
}
}
},
"defaultProject"
:
"Tabu"
"defaultProject"
:
"Tabu"
,
"cli"
:
{
"analytics"
:
"7407060e-d956-49fb-9b06-019fa3c10d74"
}
}
src/app/app-routing.module.ts
View file @
c98b09dc
...
...
@@ -4,6 +4,7 @@ import {OverviewComponent} from './overview/overview.component';
import
{
SelectGameComponent
}
from
'
./select-game/select-game.component
'
;
import
{
ErrorComponent
}
from
'
./error/error.component
'
;
import
{
GameComponent
}
from
'
./game/game.component
'
;
import
{
GuesserComponent
}
from
'
./guesser/guesser.component
'
;
const
routes
:
Routes
=
[
{
...
...
@@ -24,7 +25,7 @@ const routes: Routes = [
},
{
path
:
'
:sessionName/:team/guesser
'
,
component
:
G
ame
Component
,
component
:
G
uesser
Component
,
},
{
path
:
''
,
...
...
src/app/app.module.ts
View file @
c98b09dc
...
...
@@ -19,6 +19,9 @@ import { ErrorComponent } from './error/error.component';
import
{
MatProgressSpinnerModule
}
from
'
@angular/material/progress-spinner
'
;
import
{
FormsModule
}
from
'
@angular/forms
'
;
import
{
GameComponent
}
from
'
./game/game.component
'
;
import
{
GuesserComponent
}
from
'
./guesser/guesser.component
'
;
import
{
MatSlideToggleModule
}
from
'
@angular/material/slide-toggle
'
;
import
{
MatIconModule
}
from
'
@angular/material/icon
'
;
@
NgModule
({
declarations
:
[
...
...
@@ -29,6 +32,7 @@ import { GameComponent } from './game/game.component';
OverviewComponent
,
ErrorComponent
,
GameComponent
,
GuesserComponent
,
],
imports
:
[
HttpClientModule
,
...
...
@@ -42,7 +46,9 @@ import { GameComponent } from './game/game.component';
MatInputModule
,
MatCardModule
,
MatProgressSpinnerModule
,
FormsModule
FormsModule
,
MatSlideToggleModule
,
MatIconModule
],
providers
:
[],
bootstrap
:
[
AppComponent
]
...
...
src/app/error/error.component.ts
View file @
c98b09dc
...
...
@@ -8,7 +8,7 @@ import {Router} from '@angular/router';
})
export
class
ErrorComponent
implements
OnInit
{
constructor
(
private
router
:
Router
)
{
}
constructor
(
private
router
:
Router
)
{}
ngOnInit
():
void
{
}
...
...
src/app/game/game.component.html
View file @
c98b09dc
<div
style=
"text-align: center; margin-left: 15em; margin-right: 15em; margin-top: 5em;"
>
<p>
Punktestand: {{points}}
</p>
<div
id=
"app"
></div>
<mat-card>
<h1>
{{cardInfo.solution}}
...
...
src/app/game/game.component.scss
View file @
c98b09dc
body
{
font-family
:
sans-serif
;
display
:
grid
;
height
:
100vh
;
place-items
:
center
;
}
.base-timer
{
position
:
relative
;
width
:
300px
;
height
:
300px
;
}
.base-timer__svg
{
transform
:
scaleX
(
-1
);
}
.base-timer__circle
{
fill
:
none
;
stroke
:
none
;
}
.base-timer__path-elapsed
{
stroke-width
:
7px
;
stroke
:
grey
;
}
.base-timer__path-remaining
{
stroke-width
:
7px
;
stroke-linecap
:
round
;
transform
:
rotate
(
90deg
);
transform-origin
:
center
;
transition
:
1s
linear
all
;
fill-rule
:
nonzero
;
stroke
:
currentColor
;
}
.base-timer__path-remaining.green
{
color
:
rgb
(
65
,
184
,
131
);
}
.base-timer__path-remaining.orange
{
color
:
orange
;
}
.base-timer__path-remaining.red
{
color
:
red
;
}
.base-timer__label
{
position
:
absolute
;
width
:
300px
;
height
:
300px
;
top
:
0
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
font-size
:
48px
;
}
src/app/guesser/guesser.component.html
0 → 100644
View file @
c98b09dc
<div
style=
"text-align: center; margin-left: 15em; margin-right: 15em; margin-top: 5em;"
>
<mat-card
class=
"transparent"
>
<h1>
Du musst raten!
</h1>
<p>
Punktestand: {{points}}
</p>
</mat-card>
<br>
<mat-progress-spinner
color=
"primary"
mode=
"determinate"
value=
"value"
>
</mat-progress-spinner>
</div>
<div
id=
"app"
></div>
src/app/guesser/guesser.component.scss
0 → 100644
View file @
c98b09dc
.transparent
{
opacity
:
0
.9
;
}
.base-timer
{
position
:
relative
;
width
:
300px
;
height
:
300px
;
}
.base-timer__svg
{
transform
:
scaleX
(
-1
);
}
.base-timer__circle
{
fill
:
none
;
stroke
:
none
;
}
.base-timer__path-elapsed
{
stroke-width
:
7px
;
stroke
:
grey
;
}
.base-timer__path-remaining
{
stroke-width
:
7px
;
stroke-linecap
:
round
;
transform
:
rotate
(
90deg
);
transform-origin
:
center
;
transition
:
1s
linear
all
;
fill-rule
:
nonzero
;
stroke
:
currentColor
;
}
.base-timer__path-remaining.green
{
color
:
rgb
(
65
,
184
,
131
);
}
.base-timer__path-remaining.orange
{
color
:
orange
;
}
.base-timer__path-remaining.red
{
color
:
red
;
}
.base-timer__label
{
position
:
absolute
;
width
:
300px
;
height
:
300px
;
top
:
0
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
font-size
:
48px
;
}
src/app/guesser/guesser.component.spec.ts
0 → 100644
View file @
c98b09dc
import
{
ComponentFixture
,
TestBed
}
from
'
@angular/core/testing
'
;
import
{
GuesserComponent
}
from
'
./guesser.component
'
;
describe
(
'
GuesserComponent
'
,
()
=>
{
let
component
:
GuesserComponent
;
let
fixture
:
ComponentFixture
<
GuesserComponent
>
;
beforeEach
(
async
()
=>
{
await
TestBed
.
configureTestingModule
({
declarations
:
[
GuesserComponent
]
})
.
compileComponents
();
});
beforeEach
(()
=>
{
fixture
=
TestBed
.
createComponent
(
GuesserComponent
);
component
=
fixture
.
componentInstance
;
fixture
.
detectChanges
();
});
it
(
'
should create
'
,
()
=>
{
expect
(
component
).
toBeTruthy
();
});
});
src/app/guesser/guesser.component.ts
0 → 100644
View file @
c98b09dc
import
{
Component
,
OnInit
}
from
'
@angular/core
'
;
declare
function
testJS
():
any
;
@
Component
({
selector
:
'
app-guesser
'
,
templateUrl
:
'
./guesser.component.html
'
,
styleUrls
:
[
'
./guesser.component.scss
'
]
})
export
class
GuesserComponent
implements
OnInit
{
points
=
0
;
constructor
()
{
}
ngOnInit
():
void
{
testJS
();
}
}
src/app/overview/overview.component.html
View file @
c98b09dc
<div
style=
"text-align: center; margin-left: 15em; margin-right: 15em; margin-top: 5em;"
>
<mat-card
class=
"transparent"
>
<h2>
Du spielst in Team rot!
</h2>
<h2>
Wähle dein Team
</h2>
<mat-icon
color =
"disabled"
aria-hidden=
"false"
aria-label=
"home icon blue"
>
home
</mat-icon>
Team grau
<mat-slide-toggle
color =
"warn"
>
Team rot
</mat-slide-toggle>
<mat-icon
color =
"warn"
aria-hidden=
"false"
aria-label=
"home icon red"
>
home
</mat-icon>
</mat-card>
<br>
<br>
...
...
src/assets/JavaScript/Timer.js
0 → 100644
View file @
c98b09dc
function
testJS
()
{
// Credit: Mateusz Rybczonec
const
FULL_DASH_ARRAY
=
283
;
const
WARNING_THRESHOLD
=
10
;
const
ALERT_THRESHOLD
=
5
;
const
COLOR_CODES
=
{
info
:
{
color
:
"
green
"
},
warning
:
{
color
:
"
orange
"
,
threshold
:
WARNING_THRESHOLD
},
alert
:
{
color
:
"
red
"
,
threshold
:
ALERT_THRESHOLD
}
};
const
TIME_LIMIT
=
20
;
let
timePassed
=
0
;
let
timeLeft
=
TIME_LIMIT
;
let
timerInterval
=
null
;
let
remainingPathColor
=
COLOR_CODES
.
info
.
color
;
document
.
getElementById
(
"
app
"
).
innerHTML
=
`
<div class="base-timer">
<svg class="base-timer__svg" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<g class="base-timer__circle">
<circle class="base-timer__path-elapsed" cx="50" cy="50" r="45"></circle>
<path
id="base-timer-path-remaining"
stroke-dasharray="283"
class="base-timer__path-remaining
${
remainingPathColor
}
"
d="
M 50, 50
m -45, 0
a 45,45 0 1,0 90,0
a 45,45 0 1,0 -90,0
"
></path>
</g>
</svg>
<span id="base-timer-label" class="base-timer__label">
${
formatTime
(
timeLeft
)}
</span>
</div>
`
;
startTimer
();
function
onTimesUp
()
{
clearInterval
(
timerInterval
);
}
function
startTimer
()
{
timerInterval
=
setInterval
(()
=>
{
timePassed
=
timePassed
+=
1
;
timeLeft
=
TIME_LIMIT
-
timePassed
;
document
.
getElementById
(
"
base-timer-label
"
).
innerHTML
=
formatTime
(
timeLeft
);
setCircleDasharray
();
setRemainingPathColor
(
timeLeft
);
if
(
timeLeft
===
0
)
{
onTimesUp
();
}
},
1000
);
}
function
formatTime
(
time
)
{
const
minutes
=
Math
.
floor
(
time
/
60
);
let
seconds
=
time
%
60
;
if
(
seconds
<
10
)
{
seconds
=
`0
${
seconds
}
`
;
}
return
`
${
minutes
}
:
${
seconds
}
`
;
}
function
setRemainingPathColor
(
timeLeft
)
{
const
{
alert
,
warning
,
info
}
=
COLOR_CODES
;
if
(
timeLeft
<=
alert
.
threshold
)
{
document
.
getElementById
(
"
base-timer-path-remaining
"
)
.
classList
.
remove
(
warning
.
color
);
document
.
getElementById
(
"
base-timer-path-remaining
"
)
.
classList
.
add
(
alert
.
color
);
}
else
if
(
timeLeft
<=
warning
.
threshold
)
{
document
.
getElementById
(
"
base-timer-path-remaining
"
)
.
classList
.
remove
(
info
.
color
);
document
.
getElementById
(
"
base-timer-path-remaining
"
)
.
classList
.
add
(
warning
.
color
);
}
}
function
calculateTimeFraction
()
{
const
rawTimeFraction
=
timeLeft
/
TIME_LIMIT
;
return
rawTimeFraction
-
(
1
/
TIME_LIMIT
)
*
(
1
-
rawTimeFraction
);
}
function
setCircleDasharray
()
{
const
circleDasharray
=
`
${(
calculateTimeFraction
()
*
FULL_DASH_ARRAY
).
toFixed
(
0
)}
283`
;
document
.
getElementById
(
"
base-timer-path-remaining
"
)
.
setAttribute
(
"
stroke-dasharray
"
,
circleDasharray
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment