Skip to content

Commit

Permalink
Fix public preset fetching
Browse files Browse the repository at this point in the history
  • Loading branch information
itzTerra committed Mar 31, 2024
1 parent 5869c9a commit 295db20
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions static/js/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { DoublePendulum } from "./double_pendulum.js"

const PRESETS_PUBLIC_PATH = "static/presets.json";

const app = Vue.createApp({
setup() {
const TOOLBAR_PADDING = 10;
Expand Down Expand Up @@ -35,7 +37,7 @@ const app = Vue.createApp({
this.canvasColor = canvasColor;
}

fetch("/static/presets.json")
fetch(PRESETS_PUBLIC_PATH)
.then(response => response.json())
.then(json => this.presets.public = json);

Expand All @@ -55,7 +57,7 @@ const app = Vue.createApp({
canvas.addEventListener('mousemove', this.onPointerMove)
canvas.addEventListener('touchmove', (e) => this.handleTouch(e, this.onPointerMove))
canvas.addEventListener('wheel', (e) => this.adjustZoom(e.deltaY * 0.0005))

p.frameRate(60);
p.simulate = true;

Expand Down Expand Up @@ -163,7 +165,7 @@ const app = Vue.createApp({
}
else if (classes.contains("editDisabled")){
classes.remove("editDisabled");

inputs[0].disabled = false;

inputs[1].disabled = false;
Expand Down Expand Up @@ -298,7 +300,7 @@ const app = Vue.createApp({
this.editData = JSON.parse(JSON.stringify(data));

let colors = [
this.editData.origin.color, this.editData.bob1.color, this.editData.bob2.color,
this.editData.origin.color, this.editData.bob1.color, this.editData.bob2.color,
this.editData.bob1.lineColor, this.editData.bob2.lineColor,
this.editData.bob1.trailColor, this.editData.bob2.trailColor];
$(`#editOffcanvas input[type='color']`).each(function(i){
Expand Down Expand Up @@ -341,7 +343,7 @@ const app = Vue.createApp({
val = Number(i.value);
}
}

data[i.name] = val;
}
})
Expand Down Expand Up @@ -445,10 +447,10 @@ const app = Vue.createApp({

if (elem.requestFullscreen) {
elem.requestFullscreen();
}
}
else if (elem.webkitRequestFullscreen) { /* Safari */
elem.webkitRequestFullscreen();
}
}
else if (elem.msRequestFullscreen) { /* IE11 */
elem.msRequestFullscreen();
}
Expand Down Expand Up @@ -514,7 +516,7 @@ const app = Vue.createApp({
if (name == ""){
name = $("#saveCurrentNameInput").attr("placeholder");
}

this.addPreset(name, this.DPs.map((i) => i.data));
},
importPreset(e){
Expand Down Expand Up @@ -598,7 +600,7 @@ const app = Vue.createApp({
}
}
})

this.drawOnce();
}
},
Expand Down

0 comments on commit 295db20

Please sign in to comment.