Skip to content

Instantly share code, notes, and snippets.

@AnderssonPeter
Last active August 6, 2019 09:10
Show Gist options
  • Save AnderssonPeter/a74ec570a32b5c71ebce6882d03bc0f5 to your computer and use it in GitHub Desktop.
Save AnderssonPeter/a74ec570a32b5c71ebce6882d03bc0f5 to your computer and use it in GitHub Desktop.

Revisions

  1. AnderssonPeter revised this gist Aug 6, 2019. 1 changed file with 7 additions and 5 deletions.
    12 changes: 7 additions & 5 deletions You shall not debug
    Original file line number Diff line number Diff line change
    @@ -44,11 +44,13 @@ const fadeText = function () {
    return div;
    }

    var counter = 0;

    var callback = function (event) {
    event.stopPropagation();
    event.preventDefault();
    document.removeEventListener('click', callback);
    fadeText();
    return false;
    counter++;
    if (counter == 10) {
    document.removeEventListener('click', callback);
    fadeText();
    }
    }
    document.addEventListener('click', callback, true);
  2. AnderssonPeter created this gist Aug 6, 2019.
    54 changes: 54 additions & 0 deletions You shall not debug
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,54 @@
    const fadeText = function () {
    function getRandomColor () {
    return '#'+Math.floor(Math.random()*16777215).toString(16);
    }
    const words = 'You shall not debug I am a servant of the JavaScript wielder of the flame of V8. You cannot Debug. The dark fire will not avail you flame of Google. Go back to the IE! You cannot pass.'.split(' ');
    var div = document.createElement('div');
    div.setAttribute('style', 'position: fixed; right: 10px; bottom: 10px;z-index: 100000; font-size: 100px; font-weight: bold;');
    document.body.appendChild(div);
    function fade(initial, step, delay, callback) {
    div.style.display = 'block';
    var op = initial; // initial opacity
    var timer = setInterval(function () {
    div.style.opacity = op;
    div.style.filter = 'alpha(opacity=' + op * 100 + ")";
    op += step;
    if (op <= 0){
    clearInterval(timer);
    div.style.display = 'none';
    callback();
    }
    else if (op >= 1) {
    clearInterval(timer);
    callback();
    }
    }, delay);
    }
    div.style.opacity = 0;

    function fadeInNextWord() {
    if (words.length > 0) {
    div.style.position = 'fixed';
    div.style.left = (Math.random() * 50) + '%';
    div.style.top = (Math.random() * 50) + '%';
    div.innerText = words.shift();
    div.style.color = getRandomColor();
    fade(0, 0.2, 75, fadeOut);
    }
    }

    function fadeOut() {
    fade(1, -0.2, 75, fadeInNextWord);
    }
    fadeInNextWord();
    return div;
    }

    var callback = function (event) {
    event.stopPropagation();
    event.preventDefault();
    document.removeEventListener('click', callback);
    fadeText();
    return false;
    }
    document.addEventListener('click', callback, true);