Done
This commit is contained in:
commit
0feaf568e9
54
billboard.js
Normal file
54
billboard.js
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
function genRandomText(length) {
|
||||||
|
var text = "";
|
||||||
|
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 .?-!(),\"'";
|
||||||
|
|
||||||
|
for (var i = 0; i < length; i++)
|
||||||
|
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
||||||
|
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
function genRandomInt(min, max) {
|
||||||
|
// inclusive min & max
|
||||||
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||||
|
}
|
||||||
|
|
||||||
|
function shiftArrayToRight(arr, places) {
|
||||||
|
for (var i = 0; i < places; i++) {
|
||||||
|
arr.unshift(arr.pop());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function textFillsScreen() {
|
||||||
|
var root = document.compatMode == 'BackCompat' ? document.body : document.documentElement;
|
||||||
|
return root.scrollHeight > root.clientHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
function fillScreenWithWhitespace() {
|
||||||
|
var text = document.getElementById("text");
|
||||||
|
var charArray = [" "];
|
||||||
|
var whitespace = " ";
|
||||||
|
while(!textFillsScreen()) {
|
||||||
|
text.innerHTML += whitespace;
|
||||||
|
charArray.push.apply(charArray, [" ", " ", " ", " ", " ", " ", " ", " ",
|
||||||
|
" ", " ", " ", " ", " ", " ", " "]);
|
||||||
|
}
|
||||||
|
for (var i = 0; i < 26; i++) {
|
||||||
|
text.innerHTML += whitespace;
|
||||||
|
charArray.push.apply(charArray, [" ", " ", " ", " ", " ", " ", " ", " ",
|
||||||
|
" ", " ", " ", " ", " ", " ", " "]);
|
||||||
|
}
|
||||||
|
return charArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.onload = function () {
|
||||||
|
var textElem = document.getElementById('text');
|
||||||
|
var charArray = fillScreenWithWhitespace();
|
||||||
|
window.setInterval(function () {
|
||||||
|
for (var i = 0; i < genRandomInt(1, 4); i++) {
|
||||||
|
charArray[genRandomInt(0, charArray.length - 1)] = genRandomText(1);
|
||||||
|
textElem.innerHTML = charArray.join("");
|
||||||
|
}
|
||||||
|
shiftArrayToRight(charArray, 1);
|
||||||
|
}, 25)
|
||||||
|
}
|
38
index.html
Normal file
38
index.html
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>Billboard</title>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<!-- open graph tags -->
|
||||||
|
<meta property="og:title" content="Billboard" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<style>
|
||||||
|
@font-face {
|
||||||
|
font-family: "LinearX";
|
||||||
|
src: url("linearx-20171201-180714-516307-740daec-24931da.ttf") format("truetype");
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
font-family: "LinearX";
|
||||||
|
line-height: 13px;
|
||||||
|
font-size: 4pt;
|
||||||
|
color: LimeGreen;
|
||||||
|
background-color: black;
|
||||||
|
padding: 0;
|
||||||
|
word-break: break-all;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<p id="text"> </p>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
<script async src="billboard.js"></script>
|
||||||
|
<!-- Google Analytics -->
|
||||||
|
<script>
|
||||||
|
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
|
||||||
|
ga('create', 'UA-39880341-1', 'auto');
|
||||||
|
ga('send', 'pageview');
|
||||||
|
</script>
|
||||||
|
<script async src='https://www.google-analytics.com/analytics.js'></script>
|
||||||
|
<!-- End Google Analytics -->
|
||||||
|
</html>
|
BIN
linearx-20171201-180714-516307-740daec-24931da.ttf
Normal file
BIN
linearx-20171201-180714-516307-740daec-24931da.ttf
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user