Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
Wahlen
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
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ömer Kinik
Wahlen
Commits
f42fcda2
Commit
f42fcda2
authored
1 year ago
by
Ömer Kinik
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
cd80ba4f
Branches
main
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
vote.html
+176
-0
176 additions, 0 deletions
vote.html
with
176 additions
and
0 deletions
vote.html
0 → 100644
+
176
−
0
View file @
f42fcda2
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<title>
Vote
</title>
<script
src=
"https://unpkg.com/vue@next"
></script>
<script
src=
"https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"
></script>
<!-- import for vuetify-->
<link
href=
"https://cdn.jsdelivr.net/npm/vuetify@latest/dist/vuetify.min.css"
rel=
"stylesheet"
>
<script
src=
"https://cdn.jsdelivr.net/npm/vuetify@latest"
></script>
<style>
.voteConfirmation
{
color
:
green
;
font-weight
:
bold
;
margin
:
10px
;
}
.big-button
{
font-size
:
large
;
padding
:
20px
20px
;
margin-top
:
400px
;
}
.my-heading
{
font-size
:
1.5rem
;
font-weight
:
500
;
}
</style>
</head>
<body>
<div
id=
"app"
>
<v-app>
<v-container>
<v-row
justify=
"center"
>
<v-col
cols=
"12"
sm=
"8"
md=
"6"
>
<v-btn
v-if=
"showStartVotingButton"
block
color=
"primary"
@
click=
"startTheVote"
class=
"big-button"
>
Start Voting
</v-btn>
</v-col>
</v-row>
<v-row>
<v-col
cols=
"12"
sm=
"6"
md=
"4"
v-for=
"persona in persons"
:key=
"persona.firstName + persona.lastName"
class=
"mb-3"
>
<v-card>
<v-card-title>
<div
justify=
"center"
class=
"my-heading"
>
{{ persona.firstName }} {{
persona.lastName }}
</div>
</v-card-title>
<v-card-actions>
<v-btn
block
color=
"success"
@
click=
"castVote(persona)"
>
Vote
</v-btn>
</v-card-actions>
</v-card>
</v-col>
</v-row>
</v-container>
<div
v-if=
"votedPerson"
class=
"voteConfirmation"
>
Your vote for {{votedPerson}} has been counted, votes left:
{{voteLimit - voteCount}}
</div>
<v-container>
<v-bottom-navigation
grow
>
<v-btn
@
click=
"goToPage('index.html')"
>
Create a person
</v-btn>
<v-btn
@
click=
"goToPage('vote.html')"
>
Vote
</v-btn>
<v-btn
@
click=
"goToPage('vote_results.html')"
>
Vote results
</v-btn>
</v-bottom-navigation>
</v-container>
</v-app>
</div>
<script>
const
vuetify
=
Vuetify
.
createVuetify
();
let
app
=
Vue
.
createApp
({
data
()
{
return
{
persons
:
[],
voteCount
:
0
,
voteLimit
:
1
,
person
:
{
firstName
:
''
,
lastName
:
''
},
winner
:
''
,
votedPerson
:
null
,
showStartVotingButton
:
true
}
},
methods
:
{
async
startTheVote
()
{
const
response
=
await
axios
.
get
(
'
http://127.0.0.1:8000/persons
'
)
this
.
persons
=
response
.
data
setVoteLimit
=
parseInt
(
prompt
(
"
Set the vote limit please
"
))
this
.
voteLimit
=
setVoteLimit
this
.
showStartVotingButton
=
false
;
},
async
findPersonWithMostVotes
()
{
const
response
=
await
axios
.
get
(
'
http://127.0.0.1:8000/vote
'
)
const
data
=
response
.
data
let
maxVotes
=
-
1
let
personWithMaxVotes
=
''
for
(
person
of
data
)
{
if
(
person
.
Stimmzahl
>
maxVotes
)
{
maxVotes
=
person
.
Stimmzahl
personWithMaxVotes
=
person
.
person
}
}
this
.
winner
=
personWithMaxVotes
},
async
castVote
(
person
)
{
const
personToVote
=
{
firstName
:
person
.
firstName
,
lastName
:
person
.
lastName
}
axios
.
post
(
'
http://127.0.0.1:8000/vote
'
,
personToVote
)
this
.
voteCount
++
this
.
votedPerson
=
personToVote
.
firstName
+
"
"
+
personToVote
.
lastName
if
(
this
.
voteCount
>=
this
.
voteLimit
)
{
await
this
.
findPersonWithMostVotes
()
this
.
votedPerson
=
''
alert
(
"
Voting is complete, you will be redirected to the results page
"
)
window
.
location
.
href
=
'
vote_results.html
'
return
}
},
goToPage
(
page
)
{
window
.
location
.
href
=
page
;
}
}
})
app
.
use
(
vuetify
);
app
.
mount
(
'
#app
'
)
</script>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment