jsketcher/web/app/cad/projectPlugin.js
2018-01-22 02:10:31 -08:00

38 lines
767 B
JavaScript

const STORAGE_PREFIX = "TCAD.projects.";
export function activate({services}) {
const id = processHints();
const sketchNamespace = id + '.sketch.';
const sketchStorageNamespace = STORAGE_PREFIX + sketchNamespace;
function sketchStorageKey(faceId) {
return sketchStorageNamespace + faceId;
}
function projectStorageKey() {
return STORAGE_PREFIX + id;
}
function getSketchURL(sketchId) {
return sketchNamespace + sketchId;
}
services.project = {
id, sketchStorageKey, projectStorageKey, sketchStorageNamespace, getSketchURL;
}
}
function processHints() {
let id = window.location.hash.substring(1);
if (!id) {
id = window.location.search.substring(1);
}
if (!id) {
id = "DEFAULT";
}
return id;
}