Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Full Stack harjoitustyö
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
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
AA2875
Full Stack harjoitustyö
Commits
7f39702d
Commit
7f39702d
authored
2 years ago
by
AA2875
Browse files
Options
Downloads
Patches
Plain Diff
Kaikki tietosarakkeet lisätty
parent
90ddfcd3
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
V2/index.js
+14
-4
14 additions, 4 deletions
V2/index.js
V2/page/code.js
+17
-2
17 additions, 2 deletions
V2/page/code.js
V2/page/index.html
+9
-4
9 additions, 4 deletions
V2/page/index.html
with
40 additions
and
10 deletions
V2/index.js
+
14
−
4
View file @
7f39702d
...
...
@@ -24,8 +24,13 @@ db.once('open', function() {
const
jumpSchema
=
new
mongoose
.
Schema
({
number
:
{
type
:
String
,
required
:
true
},
date
:
{
type
:
String
,
required
:
true
},
place
:
{
type
:
String
,
required
:
true
},
plane
:
{
type
:
String
,
required
:
true
},
canopy
:
{
type
:
String
,
required
:
true
},
height
:
{
type
:
String
,
required
:
true
},
falltime
:
{
type
:
String
,
required
:
true
}
falltime
:
{
type
:
String
,
required
:
true
},
comments
:
{
type
:
String
,
required
:
false
},
link
:
{
type
:
String
,
required
:
false
}
})
// model
...
...
@@ -33,13 +38,18 @@ const Jump = mongoose.model('Jump', jumpSchema, 'jumps')
app
.
post
(
'
/jumps
'
,
async
(
request
,
response
)
=>
{
console
.
log
(
request
.
body
)
const
{
number
,
date
,
height
,
falltime
}
=
request
.
body
console
.
log
(
number
,
date
,
height
,
falltime
)
const
{
number
,
date
,
place
,
plane
,
canopy
,
height
,
falltime
,
comments
,
link
}
=
request
.
body
console
.
log
(
number
,
date
,
place
,
plane
,
canopy
,
height
,
falltime
,
comments
,
link
)
const
jump
=
new
Jump
({
number
:
number
,
date
:
date
,
place
:
place
,
plane
:
plane
,
canopy
:
canopy
,
height
:
height
,
falltime
:
falltime
falltime
:
falltime
,
comments
:
comments
,
link
:
link
})
const
savedJump
=
await
jump
.
save
()
response
.
json
(
savedJump
)
...
...
This diff is collapsed.
Click to expand it.
V2/page/code.js
+
17
−
2
View file @
7f39702d
...
...
@@ -56,7 +56,7 @@ function createJumpListItem(jump) {
return
li
}
function
jumpItemFullInfo
(
jump
)
{
function
jumpItemFullInfo
(
jump
)
{
// TÄÄÄÄNNEE KONTSAA
const
specs
=
[
jump
.
height
,
jump
.
falltime
...
...
@@ -152,13 +152,23 @@ function changeJumpOrder() {
async
function
addJump
()
{
let
newJumpNumber
=
document
.
getElementById
(
'
newJumpNumber
'
)
let
newJumpDate
=
document
.
getElementById
(
'
newJumpDate
'
)
let
newJumpPlace
=
document
.
getElementById
(
'
newJumpPlace
'
)
let
newJumpPlane
=
document
.
getElementById
(
'
newJumpPlane
'
)
let
newJumpCanopy
=
document
.
getElementById
(
'
newJumpCanopy
'
)
let
newJumpHeight
=
document
.
getElementById
(
'
newJumpHeight
'
)
let
newJumpFalltime
=
document
.
getElementById
(
'
newJumpFalltime
'
)
let
newJumpComments
=
document
.
getElementById
(
'
newJumpComments
'
)
let
newJumpLink
=
document
.
getElementById
(
'
newJumpLink
'
)
const
data
=
{
'
number
'
:
newJumpNumber
.
value
,
'
date
'
:
newJumpDate
.
value
,
'
place
'
:
newJumpPlace
.
value
,
'
plane
'
:
newJumpPlane
.
value
,
'
canopy
'
:
newJumpCanopy
.
value
,
'
height
'
:
newJumpHeight
.
value
,
'
falltime
'
:
newJumpFalltime
.
value
'
falltime
'
:
newJumpFalltime
.
value
,
'
comments
'
:
newJumpComments
.
value
,
'
link
'
:
newJumpLink
.
value
}
const
response
=
await
fetch
(
'
http://localhost:3000/jumps
'
,
{
method
:
'
POST
'
,
...
...
@@ -176,8 +186,13 @@ async function addJump() {
infoText
.
innerHTML
=
''
newJumpNumber
.
value
=
''
newJumpDate
.
value
=
''
newJumpPlace
.
value
=
''
newJumpPlane
.
value
=
''
newJumpCanopy
.
value
=
''
newJumpHeight
.
value
=
''
newJumpFalltime
.
value
=
''
newJumpComments
.
value
=
''
newJumpLink
.
value
=
''
}
function
editJump
(
id
){
...
...
This diff is collapsed.
Click to expand it.
V2/page/index.html
+
9
−
4
View file @
7f39702d
...
...
@@ -9,10 +9,15 @@
<body
onload=
"init()"
>
<div
id=
"container"
>
<h1>
Hypyt
</h1>
<input
type=
"text"
placeholder=
"Hyppy nro."
id=
"newJumpNumber"
onkeypress=
"return /[0-9]/i.test(event.key)"
/>
<input
type=
"text"
placeholder=
"Päivä"
id=
"newJumpDate"
/>
<input
type=
"text"
placeholder=
"Korkeus"
id=
"newJumpHeight"
onkeypress=
"return /[0-9]/i.test(event.key)"
/>
<input
type=
"text"
placeholder=
"Vapaa"
id=
"newJumpFalltime"
onkeypress=
"return /[0-9]/i.test(event.key)"
/>
<input
type=
"text"
placeholder=
"Hyppy nro.*"
id=
"newJumpNumber"
onkeypress=
"return /[0-9]/i.test(event.key)"
/>
<input
type=
"text"
placeholder=
"Päivä*"
id=
"newJumpDate"
/>
<input
type=
"text"
placeholder=
"Paikka*"
id=
"newJumpPlace"
/>
<input
type=
"text"
placeholder=
"Lentokone*"
id=
"newJumpPlane"
/>
<input
type=
"text"
placeholder=
"Päävarjo*"
id=
"newJumpCanopy"
/>
<input
type=
"text"
placeholder=
"Korkeus*"
id=
"newJumpHeight"
onkeypress=
"return /[0-9]/i.test(event.key)"
/>
<input
type=
"text"
placeholder=
"Vapaa*"
id=
"newJumpFalltime"
onkeypress=
"return /[0-9]/i.test(event.key)"
/>
<input
type=
"text"
placeholder=
"Kommentit"
id=
"newJumpComments"
/>
<input
type=
"text"
placeholder=
"Medialinkki"
id=
"newJumpLink"
/>
<button
onclick=
"addJump()"
id=
"addJumpBtn"
>
Lisää
</button>
<p
id=
"sortJumpsButton"
onclick=
"changeJumpOrder()"
>
Järjestys ▼
</p>
<ul
id=
"jumpsList"
></ul>
...
...
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