Skip to content

Commit

Permalink
Claen up scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Declan Chidlow committed Jun 16, 2024
1 parent 38a93c4 commit 7c1bc20
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 145 deletions.
5 changes: 5 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/vale.rocks.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 5 additions & 9 deletions config/global/scripts/blogrefine.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Show refine bar if user has JS enabled
const refinePosts = (document.getElementById("refine-posts").style.display = "flex");
document.getElementById("refine-posts").style.display = "flex"

const blogPosts = document.getElementById("blog-posts"),
blogSearch = document.getElementById("blog-search"),
Expand All @@ -21,10 +21,8 @@ function searchPosts() {

posts.forEach((div) => {
const a = div.querySelector("a"),
txtValue = a.textContent.trim().toUpperCase(),
displayStyle = txtValue.includes(blogSearchSanitised) ? "" : "none";

div.style.display = displayStyle;
txtValue = a.textContent.trim().toUpperCase();
div.style.display = txtValue.includes(blogSearchSanitised) ? "" : "none";
});
}

Expand All @@ -35,9 +33,7 @@ function filterPosts() {
const [postType] = div.textContent
.trim()
.split("\n")
.map((line) => line.toUpperCase()),
displayStyle = blogFilterSanitised === "ALL" || postType === blogFilterSanitised ? "" : "none";

div.style.display = displayStyle;
.map((line) => line.toUpperCase());
div.style.display = blogFilterSanitised === "ALL" || postType === blogFilterSanitised ? "" : "none";
});
}
64 changes: 2 additions & 62 deletions config/global/scripts/puddle.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ class AsciiNode {
this.computeForceAndDrawNode = this.computeForceAndDrawNodeHelias;

// Forces and direction variables
this.omniForce = 0;
this.fx = 0;
this.fy = 0;
this.nextFx = 0;
this.nextFy = 0;
this.currentForce = 0;
this.nextForce = 0;

Expand Down Expand Up @@ -52,7 +47,6 @@ class AsciiNode {
// Start a ripple effect from this node
startRipple(rippleStrength = 0) {
if (!rippleStrength) rippleStrength = this.data.maxRippleStrength;
this.omniForce = rippleStrength;
this.currentForce = rippleStrength;

this.drawNode(rippleStrength);
Expand All @@ -65,18 +59,6 @@ class AsciiNode {
}
}

// Update forces acting on this node based on neighboring nodes
updateForces(xChange, yChange, xForce, yForce) {
if (xChange == 0 || yChange == 0) {
// Orthogonal
this.nextFy += yForce;
this.nextFx += xForce;
} else {
this.nextFy += yForce >> 1;
this.nextFx += xForce >> 1;
}
}

// Update node's force based on the Helias algorithm
updateNodeHelias() {
// Helias math mode taken from https://web.archive.org/web/20160418004149/http://freespace.virgin.net/hugo.elias/graphics/x_water.htm
Expand Down Expand Up @@ -135,7 +117,6 @@ class PuddleData {
this.maxRippleStrength = 100.0;
this.forceDampeningRatio = 0.85; // Force dampening percent
this.forceCutOff = 2; // Axial force less than this is set to 0
this.rippleOnMove = true;
}

// Refresh and set new dimensions for the simulation
Expand Down Expand Up @@ -211,8 +192,6 @@ class Puddle {
this.parentNode = document.querySelector(queryElement);
this.data = new PuddleData(this.numRows, this.numCols);
this.updateInterval = updateInterval;
this.randomGenerationInterval = this.updateInterval;
this.randomTimeRange = this.updateInterval;
this.nodeStyle = AsciiNode;
this.nodeSize = 14;
this.updateLoop = undefined;
Expand All @@ -228,21 +207,6 @@ class Puddle {
this.setupGrid();
}

// Get the size of each node
getNodeSize() {
return this.nodeSize;
}

// Set the size of each node in the grid
setNodeSize(nodeSize) {
this.nodeSize = nodeSize;
if (this.elementHeight) {
this.numRows = Math.floor(this.elementHeight / this.nodeSize);
this.numCols = Math.floor(this.elementWidth / this.nodeSize);
}
this.setupGrid();
}

// Set default options for the simulation based on parent node dimensions
setupDefaultOptions() {
this.elementWidth = this.parentNode.scrollWidth;
Expand Down Expand Up @@ -271,7 +235,7 @@ class Puddle {
this.resizeGrid();
}

// Setup the grid structure and initialize nodes for the simulation
// Set up the grid structure and initialize nodes for the simulation
setupGrid() {
clearInterval(this.updateLoop);
this.data.refresh(this.numRows, this.numCols);
Expand All @@ -290,33 +254,9 @@ class Puddle {
this.updateLoop = setInterval(() => this.tryUpdateElements(), this.updateInterval);
}

// Set the maximum strength of ripples in the simulation
setMaxRippleStrength(maxRippleStrength) {
this.data.maxRippleStrength = maxRippleStrength;
}

// Set the force dampening ratio for the simulation
setDampeningRatio(dampeningRatio) {
this.data.forceDampeningRatio = dampeningRatio;
}

// Set the interval for updating the simulation
setUpdateInterval(updateInterval) {
clearInterval(this.updateLoop);
this.updateInterval = updateInterval;
this.updateLoop = setInterval(() => this.tryUpdateElements(), this.updateInterval);
}

// Create a wave effect by triggering ripples in the first column of nodes
createWave() {
for (let yy = 0; yy < this.numRows; ++yy) {
this.data.getNode(0, yy).startRipple(400);
}
}

// Try to update elements in the simulation
tryUpdateElements() {
if (this.data.isUpdateDone) this.data.updateElements();
else console.log("Previous update not completed, skipping update");
}
}
}
14 changes: 5 additions & 9 deletions docs/scripts/blogrefine.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Show refine bar if user has JS enabled
const refinePosts = (document.getElementById("refine-posts").style.display = "flex");
document.getElementById("refine-posts").style.display = "flex"

const blogPosts = document.getElementById("blog-posts"),
blogSearch = document.getElementById("blog-search"),
Expand All @@ -21,10 +21,8 @@ function searchPosts() {

posts.forEach((div) => {
const a = div.querySelector("a"),
txtValue = a.textContent.trim().toUpperCase(),
displayStyle = txtValue.includes(blogSearchSanitised) ? "" : "none";

div.style.display = displayStyle;
txtValue = a.textContent.trim().toUpperCase();
div.style.display = txtValue.includes(blogSearchSanitised) ? "" : "none";
});
}

Expand All @@ -35,9 +33,7 @@ function filterPosts() {
const [postType] = div.textContent
.trim()
.split("\n")
.map((line) => line.toUpperCase()),
displayStyle = blogFilterSanitised === "ALL" || postType === blogFilterSanitised ? "" : "none";

div.style.display = displayStyle;
.map((line) => line.toUpperCase());
div.style.display = blogFilterSanitised === "ALL" || postType === blogFilterSanitised ? "" : "none";
});
}
64 changes: 2 additions & 62 deletions docs/scripts/puddle.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ class AsciiNode {
this.computeForceAndDrawNode = this.computeForceAndDrawNodeHelias;

// Forces and direction variables
this.omniForce = 0;
this.fx = 0;
this.fy = 0;
this.nextFx = 0;
this.nextFy = 0;
this.currentForce = 0;
this.nextForce = 0;

Expand Down Expand Up @@ -52,7 +47,6 @@ class AsciiNode {
// Start a ripple effect from this node
startRipple(rippleStrength = 0) {
if (!rippleStrength) rippleStrength = this.data.maxRippleStrength;
this.omniForce = rippleStrength;
this.currentForce = rippleStrength;

this.drawNode(rippleStrength);
Expand All @@ -65,18 +59,6 @@ class AsciiNode {
}
}

// Update forces acting on this node based on neighboring nodes
updateForces(xChange, yChange, xForce, yForce) {
if (xChange == 0 || yChange == 0) {
// Orthogonal
this.nextFy += yForce;
this.nextFx += xForce;
} else {
this.nextFy += yForce >> 1;
this.nextFx += xForce >> 1;
}
}

// Update node's force based on the Helias algorithm
updateNodeHelias() {
// Helias math mode taken from https://web.archive.org/web/20160418004149/http://freespace.virgin.net/hugo.elias/graphics/x_water.htm
Expand Down Expand Up @@ -135,7 +117,6 @@ class PuddleData {
this.maxRippleStrength = 100.0;
this.forceDampeningRatio = 0.85; // Force dampening percent
this.forceCutOff = 2; // Axial force less than this is set to 0
this.rippleOnMove = true;
}

// Refresh and set new dimensions for the simulation
Expand Down Expand Up @@ -211,8 +192,6 @@ class Puddle {
this.parentNode = document.querySelector(queryElement);
this.data = new PuddleData(this.numRows, this.numCols);
this.updateInterval = updateInterval;
this.randomGenerationInterval = this.updateInterval;
this.randomTimeRange = this.updateInterval;
this.nodeStyle = AsciiNode;
this.nodeSize = 14;
this.updateLoop = undefined;
Expand All @@ -228,21 +207,6 @@ class Puddle {
this.setupGrid();
}

// Get the size of each node
getNodeSize() {
return this.nodeSize;
}

// Set the size of each node in the grid
setNodeSize(nodeSize) {
this.nodeSize = nodeSize;
if (this.elementHeight) {
this.numRows = Math.floor(this.elementHeight / this.nodeSize);
this.numCols = Math.floor(this.elementWidth / this.nodeSize);
}
this.setupGrid();
}

// Set default options for the simulation based on parent node dimensions
setupDefaultOptions() {
this.elementWidth = this.parentNode.scrollWidth;
Expand Down Expand Up @@ -271,7 +235,7 @@ class Puddle {
this.resizeGrid();
}

// Setup the grid structure and initialize nodes for the simulation
// Set up the grid structure and initialize nodes for the simulation
setupGrid() {
clearInterval(this.updateLoop);
this.data.refresh(this.numRows, this.numCols);
Expand All @@ -290,33 +254,9 @@ class Puddle {
this.updateLoop = setInterval(() => this.tryUpdateElements(), this.updateInterval);
}

// Set the maximum strength of ripples in the simulation
setMaxRippleStrength(maxRippleStrength) {
this.data.maxRippleStrength = maxRippleStrength;
}

// Set the force dampening ratio for the simulation
setDampeningRatio(dampeningRatio) {
this.data.forceDampeningRatio = dampeningRatio;
}

// Set the interval for updating the simulation
setUpdateInterval(updateInterval) {
clearInterval(this.updateLoop);
this.updateInterval = updateInterval;
this.updateLoop = setInterval(() => this.tryUpdateElements(), this.updateInterval);
}

// Create a wave effect by triggering ripples in the first column of nodes
createWave() {
for (let yy = 0; yy < this.numRows; ++yy) {
this.data.getNode(0, yy).startRipple(400);
}
}

// Try to update elements in the simulation
tryUpdateElements() {
if (this.data.isUpdateDone) this.data.updateElements();
else console.log("Previous update not completed, skipping update");
}
}
}
6 changes: 3 additions & 3 deletions gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ for page_config in "${pages[@]}"; do
done

# Generate blog posts
cd blog
cd blog || exit
blog_feeds=(
"Welcome"
"School_Internet"
Expand All @@ -42,12 +42,12 @@ cp -r feed/export/. ../docs/blog
cd ..

# Generate portfolio items
cd portfolio
cd portfolio || exit
portfolio_feeds=(
"Mutant_Remix"
"CapChord"
"Pam_Carters_Scriptural_Poetry"
"Photography"
"Photography"
"Meat_Typeface"
)
for feed in "${portfolio_feeds[@]}"; do
Expand Down

0 comments on commit 7c1bc20

Please sign in to comment.