Skip to content

Instantly share code, notes, and snippets.

@silasrm
Created July 10, 2013 16:54
Show Gist options
  • Save silasrm/5968028 to your computer and use it in GitHub Desktop.
Save silasrm/5968028 to your computer and use it in GitHub Desktop.
Easter Eggs from Vogue British

Easter Eggs from Vogue British


jQuery Raptorize

Official plugin site

External plugin file in Vogue

Vogue code

Konami codes:

up up down down left right left right b a => call Raptorize plugin

up up down down left right left right a b => open debug console

Javascript code to call functions when the konami code is typed:

/* -----------------------------*/
/* Debugging */
// Show d(ebug)alerts only when in DEBUG mode
window.dalert = function (a, b, c, d) {
    if (window.ALLOW_DEBUG) window.alert(a, b, c, d);
};
window.dtitle = function (a) {
    if (window.ALLOW_DEBUG) document.title=a;
};
$(function () {
    // konami code - up up down down left right left right b a
    var code1 = String.fromCharCode(38, 38, 40, 40, 37, 39, 37, 39, 66, 65);
    var code2 = String.fromCharCode(38, 38, 40, 40, 37, 39, 37, 39, 65, 66);
    var codeBuffer = "";
    $(document).keyup(function (e) {
        codeBuffer += String.fromCharCode(e.which);
        if (code1.substring(0, codeBuffer.length) == codeBuffer) {
            if (code1.length == codeBuffer.length) {
                toggle1();
                codeBuffer = String.fromCharCode(38, 38, 40, 40, 37, 39, 37, 39, 66);
            }
        } else if (code2.substring(0, codeBuffer.length) == codeBuffer) {
            if (code2.length == codeBuffer.length) {
                toggle2();
                codeBuffer = "";
            }
        } else {
            codeBuffer = "";
        }
    });

    function toggle1() {
        if ($("body").raptorize) {
            $("body").raptorize();
        } else {
            $("head").append('<script src="/_/logic/jquery.raptorize.1.0.js"></script>');
        }
    }

    function toggle2() {
        window.DEBUG_FLAG = !window.DEBUG_FLAG;
        window.DEBUG_FILTER_INCLUDE = null;
        window.DEBUG_FILTER_EXCLUDE = null;
        window.logInited=true;

        updateConsoleVisibility();
    }
});
function updateConsoleVisibility() {
    var displayMode=2;
    if (window.DEBUG_FLAG) {
        var console = $("#console");
        if (console.length == 0) {
            $("body").addClass("jsDebug").keyup(function (e) { if (e.which == 46/*delete*/) $("#console").empty(); });
            console = $("<div/>").attr("id", "console").css("z-index", "20000").css("position", "fixed").css("width", "100%").css("bottom", "0").css("height", "20%").css("overflow", "scroll").css("background", "#fff").css("color","#000").css("border", "1px solid #000").css("font","11px monospace").appendTo("body");
            console.dblclick(function () {
                displayMode++;
                updateForDisplayMode();
            });
        }
        $.each(window.beforeReadyRows || [], function (index, elem) {
            console.append(elem);
        });
        console.show();
        log("Debug innited");
        if (window.DEBUG_FILTER_INCLUDE != null || window.DEBUG_FILTER_EXCLUDE != null) {
            log("...", "Debug innited WITH FILTERS. You may not see all log messages!!!");
        } else {
            log("...", "Debug innited");
        }
        updateForDisplayMode();
    } else {
        $("#console").hide();
        $("body").removeClass("jsDebug");
    }


    function updateForDisplayMode() {
        switch (displayMode) {
            case 0:
            default:
                displayMode = 0;
                console.css("top", "auto").css("bottom", "0").height("20%");
                break;
            case 1:
                console.css("top", "auto").css("bottom", "0").height("40%");
                break;
            case 2:
                console.css("bottom", "auto").css("top", "0").height("20%");
                break;
            case 3:
                console.css("bottom", "auto").css("top", "0").height("40%");
                break;
        }
    }
}
window.evenLogRow=false;
function log(textOrTag, text) {
    if (window.DEBUG_FLAG) {
        if (text == null) {
            text = textOrTag;
            textOrTag = null;
        }

        if (textOrTag!="..." && window.DEBUG_FILTER_INCLUDE != null) {
            if ((","+window.DEBUG_FILTER_INCLUDE+",").indexOf(","+textOrTag+",")<0) {
                // don't log it
                return;
            }
        }
        if (textOrTag != "..." && window.DEBUG_FILTER_EXCLUDE != null) {
            if (("," + window.DEBUG_FILTER_EXCLUDE + ",").indexOf("," + textOrTag + ",") >= 0) {
                // don't log it
                return;
            }
        }

        var date = new Date();
        var logRow = $("<div/>").
            css("background", evenLogRow ? "#fff" : "#fafafa").
            css("border-top","1px solid #eee").
            append($("<span/>").
                css("font-weight","bold").
                text(date.getHours() + ":" + pad(date.getMinutes(), 2) + ":" + pad(date.getSeconds(), 2) + "." + pad(date.getMilliseconds(), 3) + ": ")
            ).
            append(textOrTag==null
                ? null
                : ($("<span/>").
                    css("color","#666").
                    text(textOrTag + " - ")
                )
            ).
            append($("<span/>").text(text));
        if (window.logInited) {
            $("#console").append(logRow);
        } else {
            window.beforeReadyRows = window.beforeReadyRows || [];
            window.beforeReadyRows.push(logRow);
        }
        $("#console").scrollTop(500000);
    }
    evenLogRow=!evenLogRow;
}

function pad(num, size) {
    var s = "000000000" + num;
    return s.substr(s.length - size);
}

if (window.DEBUG_FLAG) $(function () { window.logInited=true });
$(updateConsoleVisibility);
/* End debugger */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment