Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Michael Ochmann
trakr.
Commits
c4ec9de3
Commit
c4ec9de3
authored
Jul 15, 2018
by
Michael Ochmann
Browse files
added settings system; fixed navbar
parent
24219e58
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/javascript/Settings.js
0 → 100644
View file @
c4ec9de3
class
Settings
{
constructor
()
{
this
.
settings
=
JSON
.
parse
(
localStorage
.
getItem
(
"
settings
"
))
||
{};
}
get
(
key
,
defaultValue
=
null
)
{
if
(
this
.
settings
.
hasOwnProperty
(
key
))
return
this
.
settings
[
key
];
return
defaultValue
;
}
set
(
key
,
value
)
{
this
.
settings
[
key
]
=
value
;
this
.
save
();
}
save
()
{
localStorage
.
setItem
(
"
settings
"
,
JSON
.
stringify
(
this
.
settings
));
}
static
Instance
()
{
if
(
Settings
.
INSTANCE
===
null
)
Settings
.
INSTANCE
=
new
Settings
();
return
Settings
.
INSTANCE
;
}
}
Settings
.
INSTANCE
=
null
;
export
default
Settings
.
Instance
();
\ No newline at end of file
src/javascript/controllers/HeightMapViewController.js
View file @
c4ec9de3
import
UIViewController
from
"
./UIViewController.js
"
;
import
UIViewController
from
"
./UIViewController.js
"
;
import
$
from
"
../smallQ.js
"
;
import
$
from
"
../smallQ.js
"
;
import
Std
from
"
../Std.js
"
;
import
Std
from
"
../Std.js
"
;
import
Settings
from
"
../Settings.js
"
;
import
GeoPoint
from
"
../GeoPoint.js
"
;
import
GeoPoint
from
"
../GeoPoint.js
"
;
...
@@ -12,15 +13,14 @@ class HeightMapViewController extends UIViewController {
...
@@ -12,15 +13,14 @@ class HeightMapViewController extends UIViewController {
this
.
drag
=
false
;
this
.
drag
=
false
;
this
.
lastX
=
0
;
this
.
lastX
=
0
;
this
.
translated
=
0
;
this
.
translated
=
0
;
this
.
isCapturing
=
false
;
this
.
isCapturing
=
false
;
}
}
addPoint
(
geoPoint
)
{
addPoint
(
geoPoint
)
{
if
(
geoPoint
.
constructor
.
name
!==
"
GeoPoint
"
)
if
(
geoPoint
.
constructor
.
name
!==
"
GeoPoint
"
)
throw
new
TypeError
(
"
an object of type 'GeoPoint' must be p
1
assed.
"
);
throw
new
TypeError
(
"
an object of type 'GeoPoint' must be passed.
"
);
if
(
this
.
model
.
points
.
length
>
0
&&
this
.
model
.
points
[
this
.
model
.
points
.
length
-
1
].
distance
(
geoPoint
)
<
5
)
if
(
this
.
model
.
points
.
length
>
0
&&
this
.
model
.
points
[
this
.
model
.
points
.
length
-
1
].
distance
(
geoPoint
)
<
Settings
.
get
(
"
distanceInterval
"
,
50
)
)
return
;
return
;
this
.
model
.
add
(
geoPoint
);
this
.
model
.
add
(
geoPoint
);
...
...
src/javascript/controllers/SettingsViewController.js
View file @
c4ec9de3
import
UIViewController
from
"
./UIViewController.js
"
;
import
UIViewController
from
"
./UIViewController.js
"
;
import
Settings
from
"
../Settings.js
"
;
import
$
from
"
../smallQ.js
"
;
class
SettingsViewController
extends
UIViewController
{
class
SettingsViewController
extends
UIViewController
{
constructor
(
view
,
model
)
{
constructor
(
view
,
model
)
{
super
(
view
,
model
);
super
(
view
,
model
);
this
.
heights
=
[
50
];
this
.
heights
=
[
5
,
50
];
for
(
let
h
=
100
;
h
<
1000
;
h
+=
100
)
for
(
let
h
=
100
;
h
<
1000
;
h
+=
100
)
this
.
heights
.
push
(
h
);
this
.
heights
.
push
(
h
);
for
(
let
h
=
1000
;
h
<=
10000
;
h
+=
1000
)
for
(
let
h
=
1000
;
h
<=
10000
;
h
+=
1000
)
this
.
heights
.
push
(
h
);
this
.
heights
.
push
(
h
);
}
}
viewDidLoad
()
{
$
(
"
#selectDistanceInterval
"
).
on
(
"
change
"
,
element
=>
{
Settings
.
set
(
"
distanceInterval
"
,
element
.
value
());
});
}
render
()
{
render
()
{
let
heights
=
this
.
heights
.
map
(
height
=>
`<option value="
${
height
}
">
${
height
}
m</option>`
).
join
(
""
);
let
selectedDistance
=
Settings
.
get
(
"
distanceInterval
"
,
100
);
let
heights
=
this
.
heights
.
map
(
height
=>
{
let
selected
=
height
==
selectedDistance
?
"
selected
"
:
""
;
return
`<option value="
${
height
}
"
${
selected
}
>
${
height
}
m</option>`
}).
join
(
""
);
return
`
return
`
<ul class="UITableView">
<ul class="UITableView">
<li>
<li>
New datapoint every
New datapoint every
<span class="right">
<span class="right">
<select>
<select
id=selectDistanceInterval
>
${
heights
}
${
heights
}
</select>
</select>
</span>
</span>
...
...
src/javascript/controllers/ViewController.js
View file @
c4ec9de3
...
@@ -6,6 +6,7 @@ import TracksListController from "./TracksListController.js";
...
@@ -6,6 +6,7 @@ import TracksListController from "./TracksListController.js";
import
HeightMap
from
"
../models/HeightMap.js
"
;
import
HeightMap
from
"
../models/HeightMap.js
"
;
import
Tracks
from
"
../models/Tracks.js
"
;
import
Tracks
from
"
../models/Tracks.js
"
;
import
Settings
from
"
../Settings.js
"
;
import
$
from
"
../smallQ.js
"
;
import
$
from
"
../smallQ.js
"
;
const
States
=
{
const
States
=
{
...
@@ -17,7 +18,8 @@ const States = {
...
@@ -17,7 +18,8 @@ const States = {
class
ViewController
extends
UIViewController
{
class
ViewController
extends
UIViewController
{
constructor
()
{
constructor
()
{
super
(
"
body
"
);
super
(
"
body
"
);
this
.
state
=
States
.
TRACKLIST
;
this
.
state
=
parseInt
(
Settings
.
get
(
"
appState
"
));
this
.
state
=
this
.
state
===
States
.
HEIGHTMAP
?
States
.
TRACKLIST
:
this
.
state
;
this
.
track
=
null
;
this
.
track
=
null
;
this
.
renderCall
();
this
.
renderCall
();
...
@@ -71,6 +73,7 @@ class ViewController extends UIViewController {
...
@@ -71,6 +73,7 @@ class ViewController extends UIViewController {
changeState
(
newState
)
{
changeState
(
newState
)
{
this
.
state
=
newState
;
this
.
state
=
newState
;
Settings
.
set
(
"
appState
"
,
newState
);
this
.
renderCall
();
this
.
renderCall
();
}
}
...
...
src/scss/app.scss
View file @
c4ec9de3
...
@@ -30,7 +30,7 @@ body, html {
...
@@ -30,7 +30,7 @@ body, html {
}
}
body
{
body
{
padding-top
:
20px
;
/*
padding-top: 20px;
*/
display
:
grid
;
display
:
grid
;
grid-template-rows
:
44px
auto
49px
;
grid-template-rows
:
44px
auto
49px
;
background
:
$header-background
;
background
:
$header-background
;
...
@@ -39,6 +39,14 @@ body {
...
@@ -39,6 +39,14 @@ body {
}
}
button
.big
{
button
.big
{
padding
:
20px
50px
;
padding
:
15px
50px
;
font-size
:
large
;
font-size
:
x-large
;
background
:
$header-background
;
border
:
none
;
color
:
$header-color
;
border-radius
:
100px
;
&
:active
{
opacity
:
0
.6
;
}
}
}
\ No newline at end of file
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