localstorage started
This commit is contained in:
parent
54d8928d11
commit
6c6220e5db
81
js/store.js
81
js/store.js
@ -132,6 +132,7 @@ export function Reducer(inState, inAction)
|
|||||||
clone.Live.Mark = Data !== null ? {Stim:clone.Stim.Value, Resp:Data} : undefined;
|
clone.Live.Mark = Data !== null ? {Stim:clone.Stim.Value, Resp:Data} : undefined;
|
||||||
clone.Live.Freq[key] = clone.Live.Mark;
|
clone.Live.Freq[key] = clone.Live.Mark;
|
||||||
clone.Draw[key] = Redraw(clone.Live.Test, clone.Chan.Value, clone.Stim, true);
|
clone.Draw[key] = Redraw(clone.Live.Test, clone.Chan.Value, clone.Stim, true);
|
||||||
|
SaveTests(clone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( Name=="Stim" || Name=="Chan" || Name=="Freq")
|
else if( Name=="Stim" || Name=="Chan" || Name=="Freq")
|
||||||
@ -159,32 +160,9 @@ export function Reducer(inState, inAction)
|
|||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @type {Store.State} */
|
|
||||||
export const Initial = Reducer(
|
/** @type {Store.Test[]} */
|
||||||
{
|
const TestDefault = [
|
||||||
Chan: { Min:0, Max:1, Value:0, Step:1 },
|
|
||||||
Freq: { Min:2, Max:8, Value:3, Step:1 },
|
|
||||||
Stim: { Min:-10, Max:120, Value:30, Step:5 },
|
|
||||||
Live:
|
|
||||||
{
|
|
||||||
Test: undefined,
|
|
||||||
Freq: undefined,
|
|
||||||
Mark: undefined
|
|
||||||
},
|
|
||||||
Draw:
|
|
||||||
{
|
|
||||||
UserL:{Points:[], Paths:[]},
|
|
||||||
UserR:{Points:[], Paths:[]},
|
|
||||||
TestL:{Points:[], Paths:[]},
|
|
||||||
TestR:{Points:[], Paths:[]}
|
|
||||||
},
|
|
||||||
Show:
|
|
||||||
{
|
|
||||||
Cursor:true,
|
|
||||||
Answer:false
|
|
||||||
},
|
|
||||||
TestIndex: 0,
|
|
||||||
Test: [
|
|
||||||
{
|
{
|
||||||
Name: "Patient A Asymmetric Notch",
|
Name: "Patient A Asymmetric Notch",
|
||||||
Plot:
|
Plot:
|
||||||
@ -237,7 +215,56 @@ export const Initial = Reducer(
|
|||||||
{ Hz: 8000, TestL: { Stim: 0, Resp: true }, TestR: { Stim: 5, Resp: true } }
|
{ Hz: 8000, TestL: { Stim: 0, Resp: true }, TestR: { Stim: 5, Resp: true } }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
];
|
||||||
|
|
||||||
|
/** @type {Store.Test[] | string | null } */
|
||||||
|
let TestSaved = localStorage.getItem("app-tests");
|
||||||
|
if(TestSaved)
|
||||||
|
{
|
||||||
|
TestSaved = JSON.parse(TestSaved);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**@type {(inState:Store.State)=>void} */
|
||||||
|
const SaveTests =(inState)=> localStorage.setItem("app-tests", JSON.stringify(inState.Test));
|
||||||
|
|
||||||
|
/**@type {(inState:Store.State)=>void} */
|
||||||
|
const SaveSettings =(inState)=> localStorage.setItem("app-settings", JSON.stringify({
|
||||||
|
Chan:inState.Chan,
|
||||||
|
Freq:inState.Freq,
|
||||||
|
Stim:inState.Stim,
|
||||||
|
Show:inState.Show,
|
||||||
|
TestIndex:inState.TestIndex,
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
/** @type {Store.Test[]} */
|
||||||
|
const TestActual = Array.isArray(TestSaved) ? TestSaved : TestDefault
|
||||||
|
|
||||||
|
export const Initial = Reducer(
|
||||||
|
{
|
||||||
|
Chan: { Min:0, Max:1, Value:0, Step:1 },
|
||||||
|
Freq: { Min:2, Max:8, Value:3, Step:1 },
|
||||||
|
Stim: { Min:-10, Max:120, Value:30, Step:5 },
|
||||||
|
Live:
|
||||||
|
{
|
||||||
|
Test: undefined,
|
||||||
|
Freq: undefined,
|
||||||
|
Mark: undefined
|
||||||
|
},
|
||||||
|
Draw:
|
||||||
|
{
|
||||||
|
UserL:{Points:[], Paths:[]},
|
||||||
|
UserR:{Points:[], Paths:[]},
|
||||||
|
TestL:{Points:[], Paths:[]},
|
||||||
|
TestR:{Points:[], Paths:[]}
|
||||||
|
},
|
||||||
|
Show:
|
||||||
|
{
|
||||||
|
Cursor:true,
|
||||||
|
Answer:false
|
||||||
|
},
|
||||||
|
TestIndex: 0,
|
||||||
|
Test: TestActual
|
||||||
}, {Name:"Test", Data:0});
|
}, {Name:"Test", Data:0});
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user