music: change bg text function scope
This commit is contained in:
parent
77c75010b4
commit
cf7c1814c2
1 changed files with 18 additions and 15 deletions
|
|
@ -5,21 +5,24 @@
|
||||||
</cute-container>
|
</cute-container>
|
||||||
</music>
|
</music>
|
||||||
<script>
|
<script>
|
||||||
const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
(function () {
|
||||||
const container = document.getElementById("bg-text");
|
const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||||
const colWidth = 20;
|
const container = document.getElementById("bg-text");
|
||||||
const rowHeight = 24;
|
if (!container) return;
|
||||||
const cols = Math.ceil(window.innerWidth / colWidth);
|
const colWidth = 20;
|
||||||
const rows = Math.ceil(window.innerHeight / rowHeight);
|
const rowHeight = 24;
|
||||||
|
const cols = Math.ceil(window.innerWidth / colWidth);
|
||||||
|
const rows = Math.ceil(window.innerHeight / rowHeight);
|
||||||
|
|
||||||
for (let c = 0; c < cols; c++) {
|
for (let c = 0; c < cols; c++) {
|
||||||
const col = document.createElement("vertical-marquee-inner");
|
const col = document.createElement("vertical-marquee-inner");
|
||||||
col.style.left = c * colWidth + "px";
|
col.style.left = c * colWidth + "px";
|
||||||
for (let r = 0; r < rows; r++) {
|
for (let r = 0; r < rows; r++) {
|
||||||
const span = document.createElement("text");
|
const span = document.createElement("text");
|
||||||
span.textContent = chars[Math.floor(Math.random() * chars.length)];
|
span.textContent = chars[Math.floor(Math.random() * chars.length)];
|
||||||
col.appendChild(span);
|
col.appendChild(span);
|
||||||
|
}
|
||||||
|
container.appendChild(col);
|
||||||
}
|
}
|
||||||
container.appendChild(col);
|
})();
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue