Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Haakon Gunleiksrud
IT2819_h19_p2_haakon
Commits
91d4cfcc
Commit
91d4cfcc
authored
Sep 27, 2019
by
Turid Cecilie Dahl
Browse files
Minor fixes and cleanup
parent
358f6792
Changes
2
Hide whitespace changes
Inline
Side-by-side
prosjekt2/src/components/MiddlePart.jsx
View file @
91d4cfcc
...
...
@@ -15,6 +15,7 @@ class MiddlePart extends React.Component{
this
.
handleOptionChangeImage
=
this
.
handleOptionChangeImage
.
bind
(
this
);
this
.
handleOptionChangeText
=
this
.
handleOptionChangeText
.
bind
(
this
);
this
.
handleGetFav
=
this
.
handleGetFav
.
bind
(
this
);
this
.
changeContent
=
this
.
changeContent
.
bind
(
this
);
//State keeps track of which category of text, sound and image is selected
//Check if the user has stored anything, and if so then use it
if
(
sessionStorage
.
currentText
&&
sessionStorage
.
currentIndex
){
...
...
@@ -36,7 +37,7 @@ class MiddlePart extends React.Component{
}
}
else
{
//Nothing stored, first time on the website in that session
//Nothing stored, first time on the website in that session
. Use default values
this
.
state
=
{
currentIndex
:
0
,
soundIndex
:
'
animals
'
,
...
...
@@ -44,7 +45,6 @@ class MiddlePart extends React.Component{
textIndex
:
'
clicheQuotes
'
}
}
this
.
changeContent
=
this
.
changeContent
.
bind
(
this
);
// Boolean variables to know when content should be changed,
// and when favorite collection should be displayed.
...
...
@@ -74,7 +74,7 @@ class MiddlePart extends React.Component{
}
}
//Set the radio buttons to favorite combination
//Set the radio buttons to favorite combination
with HTML Storage
handleGetFav
(){
if
(
localStorage
.
favSound
){
this
.
setState
({
...
...
@@ -187,7 +187,7 @@ class MiddlePart extends React.Component{
if
(
width
<
768
||
(
width
<
height
))
{
return
(
<
div
>
<
Sidebar
<
Sidebar
currentIndex
=
{
this
.
state
.
currentIndex
}
soundIndex
=
{
this
.
state
.
soundIndex
}
imageIndex
=
{
this
.
state
.
imageIndex
}
...
...
@@ -240,7 +240,9 @@ class MiddlePart extends React.Component{
goToThirdSlide
=
{
this
.
goToThirdSlide
}
goToFourthSlide
=
{
this
.
goToFourthSlide
}
/>
</
div
>
<
Sidebar
soundIndex
=
{
this
.
state
.
soundIndex
}
<
Sidebar
currentIndex
=
{
this
.
state
.
currentIndex
}
soundIndex
=
{
this
.
state
.
soundIndex
}
imageIndex
=
{
this
.
state
.
imageIndex
}
textIndex
=
{
this
.
state
.
textIndex
}
handleOptionChangeSound
=
{
this
.
handleOptionChangeSound
}
...
...
prosjekt2/src/components/Sidebar.jsx
View file @
91d4cfcc
import
React
,
{
Component
}
from
'
react
'
;
//http://react.tips/radio-buttons-in-reactjs/
class
Sidebar
extends
Component
{
constructor
(
props
){
...
...
@@ -12,10 +11,11 @@ class Sidebar extends Component {
seeCombinationClickHandler
(){
this
.
props
.
changeContent
();
if
(
typeof
(
Storage
)
!==
"
undefined
"
)
{
sessionStorage
.
currentIndex
=
this
.
props
.
currentIndex
sessionStorage
.
currentSound
=
this
.
props
.
soundIndex
sessionStorage
.
currentImage
=
this
.
props
.
imageIndex
sessionStorage
.
currentText
=
this
.
props
.
textIndex
}
else
{
// Sorry! No Web Storage support..
}
}
...
...
@@ -29,9 +29,9 @@ class Sidebar extends Component {
}
else
{
// Sorry! No Web Storage support..
}
console
.
log
(
localStorage
.
favImage
)
}
//http://react.tips/radio-buttons-in-reactjs/
render
()
{
return
(
<
div
>
...
...
@@ -133,7 +133,7 @@ class Sidebar extends Component {
<
button
onClick
=
{
(
e
)
=>
this
.
seeCombinationClickHandler
(
e
)
}
>
See combination
</
button
>
<
button
onClick
=
{
(
e
)
=>
this
.
saveFav
(
e
)
}
>
<
button
onClick
=
{
this
.
saveFav
}
>
Save as favorite
</
button
>
<
button
onClick
=
{
this
.
props
.
handleGetFav
}
>
...
...
Write
Preview
Supports
Markdown
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