Created
April 23, 2017 21:38
-
-
Save meta-meta/665d3f27d00d23573057781a12282519 to your computer and use it in GitHub Desktop.
Atom chaos nullspace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// var str = 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890~!@#$%^*()-_=+,./<>?;:\'"[]{}|`&'; | |
var str = 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890'; | |
var randChar = () => str.substr(Math.floor(Math.random() * str.length), 1) | |
// this one works better. I think maybe the random chars are being parsed to some degree so they don't fill the space?? | |
var randStr = len => new Array(len) | |
.fill('') | |
.map(randChar) | |
.join(''); | |
var editor = atom.workspace.getActiveTextEditor(); | |
var getNullLength = (line) => editor.getMaxScreenLineLength() - line.textContent.length; | |
var fillLine = line => { | |
var noise = line.querySelector('.noise'); | |
if(noise) { | |
noise.textContent = randStr(noise.textContent.length); | |
} else { | |
line.insertAdjacentHTML('beforeEnd', `<span class="noise">${randStr(getNullLength(line))}</span>`) | |
} | |
}; | |
var interval = setInterval(() => document.querySelectorAll('.line').forEach(fillLine), 20); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment