Skip to content

Commit cc5cea8

Browse files
committed
style: apply prettier formatting
1 parent efe209d commit cc5cea8

File tree

3 files changed

+62
-57
lines changed

3 files changed

+62
-57
lines changed

index.html

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@
5858
<!-- libgif.js (SuperGif) provides low-level GIF frame extraction.
5959
Browsers expose only the first frame of a GIF; SuperGif lets us
6060
step through frames so animated GIFs can be drawn onto our canvas. -->
61-
<script src="https://cdn.jsdelivr.net/gh/buzzfeed/libgif-js/libgif.js"></script>
61+
<script src="https://cdn.jsdelivr.net/gh/buzzfeed/libgif-js/libgif.js" defer></script>
6262

6363
<!-- gif-animator.js integrates SuperGif with Music Blocks. It manages
6464
decoding and drawing GIF frames onto the turtle's overlay canvas.
6565
Canvas refreshing is handled separately by CreateJS Ticker. -->
66-
<script src="js/gif-animator.js"></script>
66+
<script src="js/gif-animator.js" defer></script>
6767
<script defer>
6868
document.addEventListener("DOMContentLoaded", function () {
6969
if (window.hljs) hljs.highlightAll();
@@ -84,9 +84,11 @@
8484
<script src="lib/tweenjs.min.js" defer></script>
8585
<script>
8686
let ast2blocklist_config;
87-
fetch("js/js-export/ast2blocks.min.json")
88-
.then(response => response.json())
89-
.then(data => { ast2blocklist_config = data })
87+
document.addEventListener("DOMContentLoaded", function () {
88+
fetch("js/js-export/ast2blocks.min.json")
89+
.then(response => response.json())
90+
.then(data => { ast2blocklist_config = data });
91+
});
9092
</script>
9193
</head>
9294

@@ -99,7 +101,7 @@
99101
<div id="loading-image-container"
100102
style="position: fixed; top: 0; left: 0; width: 100%; height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; background-color: #FFFFFF; z-index: 9999; contain: paint;">
101103
<div id="loading-media" style="width: 100%; padding: 0 20px; box-sizing: border-box;"></div>
102-
<div class="loading-text" id="loadingText" style="margin-top: 2rem; min-height: 1.5em; font-size: 1.2rem;">
104+
<div class="loading-text" id="loadingText" style="color:#333; margin-top: 2rem; min-height: 1.5em; font-size: 1.2rem;">
103105
</div>
104106
<a href="https://www.sugarlabs.org/" target="_blank" id="link-to-sugarLabs"
105107
style="position: fixed; bottom: 20px; right: 20px;">
@@ -507,8 +509,9 @@
507509

508510
// NOTE: Ticker is managed by Activity class in activity.js
509511
// to prevent duplicate stage updates that cause performance issues.
510-
// The Activity ticker includes optimization to only update when needed.
511512
createjs.Ticker.framerate = 60;
513+
// Removed: createjs.Ticker.addEventListener("tick", stage);
514+
// This was causing double rendering (120fps instead of 60fps)
512515
}
513516
document.addEventListener("DOMContentLoaded", init);
514517
</script>

js/activity.js

Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2043,7 +2043,7 @@ class Activity {
20432043
const changeText = () => {
20442044
const randomLoadMessage =
20452045
messages.load_messages[
2046-
Math.floor(Math.random() * messages.load_messages.length)
2046+
Math.floor(Math.random() * messages.load_messages.length)
20472047
];
20482048
document.getElementById("messageText").innerHTML = randomLoadMessage + "...";
20492049
counter++;
@@ -2987,11 +2987,11 @@ class Activity {
29872987
.data("item.autocomplete", item)
29882988
.append(
29892989
'<img src="' +
2990-
item.artwork +
2991-
'" height="20px">' +
2992-
"<a> " +
2993-
item.label +
2994-
"</a>"
2990+
item.artwork +
2991+
'" height="20px">' +
2992+
"<a> " +
2993+
item.label +
2994+
"</a>"
29952995
)
29962996
.appendTo(
29972997
ul.css({
@@ -3109,7 +3109,7 @@ class Activity {
31093109
if (
31103110
this.blocks.blockList[bottom].name === "hidden" &&
31113111
this.blocks.blockList[this.blocks.blockList[bottom].connections[0]].name ===
3112-
"newnote"
3112+
"newnote"
31133113
) {
31143114
// The note block macro creates nine blocks.
31153115
const newlyCreatedBlock = this.blocks.blockList.length - 9;
@@ -4526,8 +4526,8 @@ class Activity {
45264526
console.log(
45274527
"%cMusic Blocks",
45284528
"font-size: 24px; font-weight: bold; font-family: sans-serif; padding:20px 0 0 110px; background: url(" +
4529-
imgUrl +
4530-
") no-repeat;"
4529+
imgUrl +
4530+
") no-repeat;"
45314531
);
45324532
// eslint-disable-next-line no-console
45334533
console.log(
@@ -4599,10 +4599,10 @@ class Activity {
45994599
typeof flags !== "undefined"
46004600
? flags
46014601
: {
4602-
run: false,
4603-
show: false,
4604-
collapse: false
4605-
};
4602+
run: false,
4603+
show: false,
4604+
collapse: false
4605+
};
46064606
this.loading = true;
46074607
document.body.style.cursor = "wait";
46084608
this.doLoadAnimation();
@@ -4965,8 +4965,9 @@ class Activity {
49654965
[
49664966
"nameddo",
49674967
{
4968-
value: `V: ${parseInt(lineId) + 1} Line ${staffBlocksMap[lineId]?.baseBlocks?.length + 1
4969-
}`
4968+
value: `V: ${parseInt(lineId) + 1} Line ${
4969+
staffBlocksMap[lineId]?.baseBlocks?.length + 1
4970+
}`
49704971
}
49714972
],
49724973
0,
@@ -4975,12 +4976,12 @@ class Activity {
49754976
staffBlocksMap[lineId].baseBlocks.length === 0
49764977
? null
49774978
: staffBlocksMap[lineId].baseBlocks[
4978-
staffBlocksMap[lineId].baseBlocks.length - 1
4979-
][0][
4980-
staffBlocksMap[lineId].baseBlocks[
4981-
staffBlocksMap[lineId].baseBlocks.length - 1
4982-
][0].length - 4
4983-
][0],
4979+
staffBlocksMap[lineId].baseBlocks.length - 1
4980+
][0][
4981+
staffBlocksMap[lineId].baseBlocks[
4982+
staffBlocksMap[lineId].baseBlocks.length - 1
4983+
][0].length - 4
4984+
][0],
49844985
null
49854986
]
49864987
],
@@ -4996,8 +4997,9 @@ class Activity {
49964997
[
49974998
"text",
49984999
{
4999-
value: `V: ${parseInt(lineId) + 1} Line ${staffBlocksMap[lineId]?.baseBlocks?.length + 1
5000-
}`
5000+
value: `V: ${parseInt(lineId) + 1} Line ${
5001+
staffBlocksMap[lineId]?.baseBlocks?.length + 1
5002+
}`
50015003
}
50025004
],
50035005
0,
@@ -5032,14 +5034,14 @@ class Activity {
50325034
staffBlocksMap[staffIndex].startBlock.length - 3
50335035
][4][2] =
50345036
staffBlocksMap[staffIndex].baseBlocks[0][0][
5035-
staffBlocksMap[staffIndex].baseBlocks[0][0].length - 4
5037+
staffBlocksMap[staffIndex].baseBlocks[0][0].length - 4
50365038
][0];
50375039
// Update the first namedo block with settimbre
50385040
staffBlocksMap[staffIndex].baseBlocks[0][0][
50395041
staffBlocksMap[staffIndex].baseBlocks[0][0].length - 4
50405042
][4][0] =
50415043
staffBlocksMap[staffIndex].startBlock[
5042-
staffBlocksMap[staffIndex].startBlock.length - 3
5044+
staffBlocksMap[staffIndex].startBlock.length - 3
50435045
][0];
50445046
const repeatblockids = staffBlocksMap[staffIndex].repeatArray;
50455047
for (const repeatId of repeatblockids) {
@@ -5051,7 +5053,7 @@ class Activity {
50515053
0,
50525054
[
50535055
staffBlocksMap[staffIndex].startBlock[
5054-
staffBlocksMap[staffIndex].startBlock.length - 3
5056+
staffBlocksMap[staffIndex].startBlock.length - 3
50555057
][0] /*setribmre*/,
50565058
blockId + 1,
50575059
staffBlocksMap[staffIndex].nameddoArray[staffIndex][0],
@@ -5060,8 +5062,8 @@ class Activity {
50605062
] === null
50615063
? null
50625064
: staffBlocksMap[staffIndex].nameddoArray[staffIndex][
5063-
repeatId.end + 1
5064-
]
5065+
repeatId.end + 1
5066+
]
50655067
]
50665068
]);
50675069
staffBlocksMap[staffIndex].repeatBlock.push([
@@ -5095,7 +5097,7 @@ class Activity {
50955097
const secondnammedo = _searchIndexForMusicBlock(
50965098
staffBlocksMap[staffIndex].baseBlocks[repeatId.end + 1][0],
50975099
staffBlocksMap[staffIndex].nameddoArray[staffIndex][
5098-
repeatId.end + 1
5100+
repeatId.end + 1
50995101
]
51005102
);
51015103

@@ -5119,31 +5121,31 @@ class Activity {
51195121
const prevnameddo = _searchIndexForMusicBlock(
51205122
staffBlocksMap[staffIndex].baseBlocks[repeatId.start - 1][0],
51215123
staffBlocksMap[staffIndex].baseBlocks[repeatId.start][0][
5122-
currentnammeddo
5124+
currentnammeddo
51235125
][4][0]
51245126
);
51255127
const afternamedo = _searchIndexForMusicBlock(
51265128
staffBlocksMap[staffIndex].baseBlocks[repeatId.end][0],
51275129
staffBlocksMap[staffIndex].baseBlocks[repeatId.start][0][
5128-
currentnammeddo
5130+
currentnammeddo
51295131
][4][1]
51305132
);
51315133
let prevrepeatnameddo = -1;
51325134
if (prevnameddo === -1) {
51335135
prevrepeatnameddo = _searchIndexForMusicBlock(
51345136
staffBlocksMap[staffIndex].repeatBlock,
51355137
staffBlocksMap[staffIndex].baseBlocks[repeatId.start][0][
5136-
currentnammeddo
5138+
currentnammeddo
51375139
][4][0]
51385140
);
51395141
}
51405142
const prevBlockId =
51415143
staffBlocksMap[staffIndex].baseBlocks[repeatId.start][0][
5142-
currentnammeddo
5144+
currentnammeddo
51435145
][4][0];
51445146
const currentBlockId =
51455147
staffBlocksMap[staffIndex].baseBlocks[repeatId.start][0][
5146-
currentnammeddo
5148+
currentnammeddo
51475149
][0];
51485150

51495151
// Needs null checking optmizie
@@ -5157,7 +5159,7 @@ class Activity {
51575159
0,
51585160
[
51595161
staffBlocksMap[staffIndex].baseBlocks[repeatId.start][0][
5160-
currentnammeddo
5162+
currentnammeddo
51615163
][4][0],
51625164
blockId + 1,
51635165
currentBlockId,
@@ -5773,7 +5775,7 @@ class Activity {
57735775
this.update = true;
57745776
};
57755777

5776-
this.__showAltoAccidentals = () => { };
5778+
this.__showAltoAccidentals = () => {};
57775779

57785780
/*
57795781
* Shows musical alto staff
@@ -6440,12 +6442,12 @@ class Activity {
64406442
.data("item.autocomplete", item)
64416443
.append(
64426444
'<img src="' +
6443-
item.artwork +
6444-
'" height = "20px">' +
6445-
"<a>" +
6446-
" " +
6447-
item.label +
6448-
"</a>"
6445+
item.artwork +
6446+
'" height = "20px">' +
6447+
"<a>" +
6448+
" " +
6449+
item.label +
6450+
"</a>"
64496451
)
64506452
.appendTo(ul.css("z-index", 9999));
64516453
};
@@ -6560,10 +6562,10 @@ class Activity {
65606562
container.setAttribute(
65616563
"style",
65626564
"position: absolute; right:" +
6563-
(document.body.clientWidth - x) +
6564-
"px; top: " +
6565-
y +
6566-
"px;"
6565+
(document.body.clientWidth - x) +
6566+
"px; top: " +
6567+
y +
6568+
"px;"
65676569
);
65686570
document.getElementById("buttoncontainerBOTTOM").appendChild(container);
65696571
return container;

js/turtles.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -869,10 +869,10 @@ Turtles.TurtlesView = class {
869869
container.setAttribute(
870870
"style",
871871
"position: absolute; right:" +
872-
(document.body.clientWidth - x) +
873-
"px; top: " +
874-
y +
875-
"px;"
872+
(document.body.clientWidth - x) +
873+
"px; top: " +
874+
y +
875+
"px;"
876876
);
877877
docById("buttoncontainerTOP").appendChild(container);
878878
return container;

0 commit comments

Comments
 (0)