Commit 06d4a2c1 authored by Jérémie Garcia's avatar Jérémie Garcia

Session fix

parent 4ca3fc3e
WOB/qr_code.png

627 Bytes | W: | H:

WOB/qr_code.png

620 Bytes | W: | H:

WOB/qr_code.png
WOB/qr_code.png
WOB/qr_code.png
WOB/qr_code.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -19,13 +19,14 @@ Traj.Session = {
this.lblCurrentSession.innerHTML = 'Session ' + Number(this.currentSession+1) + '/' + Number(this.dict.length);
},
makeTrajectoriesArrayFromDictArray : 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 = makeTrajectoriesArrayFromDictArray(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 = makeTrajectoriesArrayFromDictArray(lastState);
trajectories = Traj.Session.makeTrajectoriesArrayFromDict(lastState);
Traj.TrajManager.setTrajectories(trajectories);
this.historySessions.splice(0,1);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment