misc fixes:
-image path -test preview -form data
This commit is contained in:
parent
bfc6778c76
commit
8ec1d9a0fa
@ -4,6 +4,7 @@
|
|||||||
"@twind/": "https://esm.sh/@twind/",
|
"@twind/": "https://esm.sh/@twind/",
|
||||||
"react": "https://esm.sh/preact@10.11.3/compat",
|
"react": "https://esm.sh/preact@10.11.3/compat",
|
||||||
"htm": "https://esm.sh/htm@3.1.1/preact",
|
"htm": "https://esm.sh/htm@3.1.1/preact",
|
||||||
"app": "./js/app.js"
|
"app": "./js/app.js",
|
||||||
|
"$/": "./static/"
|
||||||
}
|
}
|
||||||
}
|
}
|
66
js/store.js
66
js/store.js
@ -99,7 +99,7 @@ const ErrorProbability =(inState)=>
|
|||||||
const Reselect =(inState, inTest)=>
|
const Reselect =(inState, inTest)=>
|
||||||
{
|
{
|
||||||
/** @type {Store.Context} */
|
/** @type {Store.Context} */
|
||||||
const output = { Test:inTest??inState.Live.Test, Mark:{User:undefined} };
|
const output = { Test:inTest??inState.Live.Test, Mark:{User:undefined, Errs:0} };
|
||||||
const column = ColumnMapping[inState.Freq.Value];
|
const column = ColumnMapping[inState.Freq.Value];
|
||||||
if(column && output.Test)
|
if(column && output.Test)
|
||||||
{
|
{
|
||||||
@ -190,6 +190,7 @@ export function Reducer(inState, inAction)
|
|||||||
TestR: Redraw(test, 1, clone.Stim, false)
|
TestR: Redraw(test, 1, clone.Stim, false)
|
||||||
};
|
};
|
||||||
test.Done = Grade(test);
|
test.Done = Grade(test);
|
||||||
|
SaveTests(clone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Name == "Mark")
|
else if (Name == "Mark")
|
||||||
@ -248,6 +249,7 @@ export function Reducer(inState, inAction)
|
|||||||
ErrorProbability(clone);
|
ErrorProbability(clone);
|
||||||
SaveSettings(clone);
|
SaveSettings(clone);
|
||||||
|
|
||||||
|
document.dispatchEvent(new CustomEvent("EarmarkUpdate", {detail:clone}));
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,10 +309,41 @@ const TestDefault = [
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
let PreviewData = false;
|
||||||
|
const PreviewText = atob(new URL(window.location.href).searchParams.get("test")||"");
|
||||||
|
if(PreviewText)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PreviewData = JSON.parse(PreviewText);
|
||||||
|
}
|
||||||
|
catch(e)
|
||||||
|
{
|
||||||
|
alert(`Could not read test data`);
|
||||||
|
PreviewData = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const AppVersion = `0.0.0`;
|
||||||
|
const savedVersion = localStorage.getItem("app-version");
|
||||||
|
if(savedVersion && (AppVersion > savedVersion))
|
||||||
|
{
|
||||||
|
console.log(`New version "${AppVersion}"; clearing saved session.`);
|
||||||
|
localStorage.clear();
|
||||||
|
}
|
||||||
|
localStorage.setItem("app-version", AppVersion);
|
||||||
|
|
||||||
/** @type {Store.Test[]} */
|
/** @type {Store.Test[]} */
|
||||||
const TestActual = JSON.parse(localStorage.getItem("app-tests")||"false") || TestDefault;
|
const TestActual = PreviewData ? PreviewData : JSON.parse(localStorage.getItem("app-tests")||"false") || TestDefault;
|
||||||
/**@type {(inState:Store.State)=>void} */
|
/**@type {(inState:Store.State)=>void} */
|
||||||
const SaveTests =(inState)=> localStorage.setItem("app-tests", JSON.stringify(inState.Test));
|
const SaveTests =(inState)=>
|
||||||
|
{
|
||||||
|
if(!PreviewData)
|
||||||
|
{
|
||||||
|
localStorage.setItem("app-tests", JSON.stringify(inState.Test));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** @type {Store.StatePartSimple} */
|
/** @type {Store.StatePartSimple} */
|
||||||
const SettingsDefault =
|
const SettingsDefault =
|
||||||
@ -323,20 +356,23 @@ const SettingsDefault =
|
|||||||
Show: { Cursor:true, Answer:false }
|
Show: { Cursor:true, Answer:false }
|
||||||
};
|
};
|
||||||
/** @type {Store.StatePartSimple} */
|
/** @type {Store.StatePartSimple} */
|
||||||
const SettingsActual = JSON.parse(localStorage.getItem("app-settings")||"false") || SettingsDefault;
|
const SettingsActual = PreviewData ? SettingsDefault : JSON.parse(localStorage.getItem("app-settings")||"false") || SettingsDefault;
|
||||||
/**@type {(inState:Store.State)=>void} */
|
/**@type {(inState:Store.State)=>void} */
|
||||||
const SaveSettings =(inState)=>
|
const SaveSettings =(inState)=>
|
||||||
{
|
{
|
||||||
/** @type {Store.StatePartSimple} */
|
if(!PreviewData)
|
||||||
const clone = {
|
{
|
||||||
Chan:inState.Chan,
|
/** @type {Store.StatePartSimple} */
|
||||||
Freq:inState.Freq,
|
const clone = {
|
||||||
Stim:inState.Stim,
|
Chan:inState.Chan,
|
||||||
Errs:inState.Errs,
|
Freq:inState.Freq,
|
||||||
Pick:inState.Pick,
|
Stim:inState.Stim,
|
||||||
Show:inState.Show
|
Errs:inState.Errs,
|
||||||
};
|
Pick:inState.Pick,
|
||||||
localStorage.setItem("app-settings", JSON.stringify(clone));
|
Show:inState.Show
|
||||||
|
};
|
||||||
|
localStorage.setItem("app-settings", JSON.stringify(clone));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Initial = Reducer(
|
export const Initial = Reducer(
|
||||||
@ -347,7 +383,7 @@ export const Initial = Reducer(
|
|||||||
{
|
{
|
||||||
Test: undefined,
|
Test: undefined,
|
||||||
Freq: undefined,
|
Freq: undefined,
|
||||||
Mark: {User: undefined}
|
Mark: {User: undefined, Errs:0}
|
||||||
},
|
},
|
||||||
Draw:
|
Draw:
|
||||||
{
|
{
|
||||||
|
4
js/ui.js
4
js/ui.js
@ -35,6 +35,8 @@ export function Button({children, icon, light, disabled, inactive, onClick, clas
|
|||||||
</button>`;
|
</button>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const staticPath = await import.meta.resolve("$/");
|
||||||
|
|
||||||
/** @type {BasicElement} */
|
/** @type {BasicElement} */
|
||||||
export const Header =()=>
|
export const Header =()=>
|
||||||
{
|
{
|
||||||
@ -48,7 +50,7 @@ export const Header =()=>
|
|||||||
<div class="flex flex-row items-stretch bg-metal rounded-lg overflow-hidden shadow-md font-sans">
|
<div class="flex flex-row items-stretch bg-metal rounded-lg overflow-hidden shadow-md font-sans">
|
||||||
|
|
||||||
<div class="p-4">
|
<div class="p-4">
|
||||||
<img class="h-auto max-w-[200px]" src="./logo.png"/>
|
<img class="h-auto max-w-[200px]" src=${staticPath+"logo.png"}/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="p-4 flex-1">
|
<div class="p-4 flex-1">
|
||||||
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Loading…
Reference in New Issue
Block a user