Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jeremie Garcia
Trajectoires
Commits
06d4a2c1
Commit
06d4a2c1
authored
Oct 22, 2015
by
Jérémie Garcia
Browse files
Session fix
parent
4ca3fc3e
Changes
2
Hide whitespace changes
Inline
Side-by-side
WOB/qr_code.png
View replaced file @
4ca3fc3e
View file @
06d4a2c1
627 Bytes
|
W:
|
H:
620 Bytes
|
W:
|
H:
2-up
Swipe
Onion skin
WOB/server/interfaces/js/Session.js
View file @
06d4a2c1
...
...
@@ -19,13 +19,14 @@ Traj.Session = {
this
.
lblCurrentSession
.
innerHTML
=
'
Session
'
+
Number
(
this
.
currentSession
+
1
)
+
'
/
'
+
Number
(
this
.
dict
.
length
);
},
makeTrajectoriesArrayFromDict
Array
:
function
(
array
){
makeTrajectoriesArrayFromDict
:
function
(
array
){
var
trajectories
=
[],
newCurve
=
{};
for
(
var
i
=
0
;
i
<
array
.
length
;
i
++
)
{
newCurve
=
new
TimedCurve
(
array
[
i
].
sourceNumber
);
for
(
var
j
=
0
;
j
<
this
.
dict
[
idx
][
i
].
X
.
length
;
j
++
)
{
for
(
var
j
=
0
;
j
<
array
[
i
].
X
.
length
;
j
++
)
{
newCurve
.
addTimedPoint
(
array
[
i
].
X
[
j
],
array
[
i
].
Y
[
j
],
array
[
i
].
Z
[
j
],
array
[
i
].
t
[
j
]);
}
newCurve
.
sourceNumber
=
array
[
i
].
sourceNumber
;
...
...
@@ -36,7 +37,7 @@ Traj.Session = {
loadTrajSession
:
function
(
idx
){
var
newTrajectories
=
this
.
dict
[
idx
],
trajectories
=
makeTrajectoriesArrayFromDict
Array
(
newTrajectories
);
trajectories
=
this
.
makeTrajectoriesArrayFromDict
(
newTrajectories
);
Traj
.
TrajManager
.
setTrajectories
(
trajectories
);
},
...
...
@@ -45,12 +46,12 @@ Traj.Session = {
},
loadLastTrajSession
:
function
(){
if
(
this
.
traj_
dict
.
length
>
0
){
Traj
.
Session
.
loadTrajSession
(
this
.
traj_
dict
.
length
-
1
);
if
(
this
.
dict
.
length
>
0
){
Traj
.
Session
.
loadTrajSession
(
this
.
dict
.
length
-
1
);
}
},
saveTrajSession
:
function
(){
saveTrajSession
:
function
(){
var
idx
=
this
.
currentSession
;
this
.
dict
[
idx
]
=
Traj
.
TrajManager
.
trajectories
;
localStorage
.
trajectories
=
JSON
.
stringify
(
this
.
dict
);
...
...
@@ -90,7 +91,7 @@ Traj.Session = {
if
(
this
.
currentSession
>
this
.
dict
.
length
-
1
)
{
this
.
currentSession
=
0
;
}
this
.
updateCurrentSessionLbl
();
this
.
updateCurrentSessionLbl
();
}
},
...
...
@@ -123,7 +124,7 @@ Traj.Session = {
/*
*STATE FOR UNDO MECHANISM
*STATE FOR UNDO MECHANISM
Needs to be redon with a better way
*/
...
...
@@ -131,7 +132,7 @@ Traj.State = {
historySessions
:
[],
// Save the state of the app
newAction
:
function
()
{
newAction
:
function
()
{
var
newState
=
JSON
.
stringify
(
Traj
.
TrajManager
.
trajectories
);
this
.
historySessions
.
unshift
(
newState
);
var
length
=
this
.
historySessions
.
length
;
...
...
@@ -140,12 +141,12 @@ Traj.State = {
}
},
// load previous state saved.
// load previous state saved.
//Problem : if you change the session and then press undo, you get all the curves from the last session...
undo
:
function
()
{
undo
:
function
()
{
if
(
this
.
historySessions
.
length
>
0
)
{
var
lastState
=
JSON
.
parse
(
this
.
historySessions
[
0
]),
trajectories
=
makeTrajectoriesArrayFromDict
Array
(
lastState
);
trajectories
=
Traj
.
Session
.
makeTrajectoriesArrayFromDict
(
lastState
);
Traj
.
TrajManager
.
setTrajectories
(
trajectories
);
this
.
historySessions
.
splice
(
0
,
1
);
}
...
...
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