Loading static/js/snakeoil.mjs +9 −0 Original line number Diff line number Diff line Loading @@ -45,3 +45,12 @@ export function getHandInToken(state) { */ return btoa(state.toString()) } /** * Generate a random session uuid, whose sole purpose it is * to distinguish a hand-in token from this session from a hand-in * token from any other session. */ export function generateSessionUuid() { return crypto.randomUUID() } static/js/state.mjs +15 −0 Original line number Diff line number Diff line /** Read and modify the current state of the application. Allows saving to local storage. */ import { generateSessionUuid } from "./snakeoil.mjs" export class State { /** Loading @@ -11,6 +13,19 @@ export class State { this.realm = realm } /** * Return a uuid for this test session */ get sessionUuid() { let uuid = localStorage.getItem(`${this.realm}.sessionUuid`) if(uuid === null) { uuid = generateSessionUuid() localStorage.setItem(`${this.realm}.sessionUuid`, uuid) } return uuid } /** * Return if this is the first time the application was started */ Loading Loading
static/js/snakeoil.mjs +9 −0 Original line number Diff line number Diff line Loading @@ -45,3 +45,12 @@ export function getHandInToken(state) { */ return btoa(state.toString()) } /** * Generate a random session uuid, whose sole purpose it is * to distinguish a hand-in token from this session from a hand-in * token from any other session. */ export function generateSessionUuid() { return crypto.randomUUID() }
static/js/state.mjs +15 −0 Original line number Diff line number Diff line /** Read and modify the current state of the application. Allows saving to local storage. */ import { generateSessionUuid } from "./snakeoil.mjs" export class State { /** Loading @@ -11,6 +13,19 @@ export class State { this.realm = realm } /** * Return a uuid for this test session */ get sessionUuid() { let uuid = localStorage.getItem(`${this.realm}.sessionUuid`) if(uuid === null) { uuid = generateSessionUuid() localStorage.setItem(`${this.realm}.sessionUuid`, uuid) } return uuid } /** * Return if this is the first time the application was started */ Loading