Created
August 21, 2017 18:33
-
-
Save benjamingr/acb43e8e9a8f3e9308e30de564c11af7 to your computer and use it in GitHub Desktop.
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
Eggs.Map = function() {} | |
, | |
Eggs.Map.init = function() { | |
function t() { | |
var t = ($(window).scrollTop() + $(window).height()) / $(document).height() * .6; | |
s.css("background-size", t * a + "px auto"), | |
s.css("background-position", 800 - o.x * t + "px " + (40 - o.y * t) + "px") | |
} | |
function e() { | |
var t = i() | |
, e = t.winterUtcOffset | |
, n = 360 * e / 24 | |
, s = t.north ? 45 : t.south ? -20 : 0 | |
, o = navigator.language.substring(0, 2); | |
-6 >= e ? t.north && "es" === o ? s = 23 : t.north && (s = 40) : -3 >= e ? 0 === s && /pt|es/.test(o) ? s = -20 : t.north && "en" === o ? s = 38 : t.north && "fr" === o && (s = 52) : 3 >= e ? "ar" === o ? s = 30 : t.hasDst ? t.north && (s = 50) : s = 0 : 0 === s && ("ru" === o && (s = 63), | |
"zh" === o ? s = 35 : "en" === o && e >= 8 && 10 >= e && (s = -23)); | |
var a = 790 + n / 90 * 410; | |
a >= 1667 ? a -= 1667 : 0 > a && (a += 1667); | |
var r = 560 - s / 45 * 230; | |
return { | |
"x": a, | |
"y": r | |
} | |
} | |
function i() { | |
for (var t, e, i = { | |
"winterUtcOffset": n(new Date) | |
}, s = (new Date).getFullYear(), o = 0; 5 >= o; o++) { | |
if (t = n(new Date(s,o,1)), | |
"undefined" != typeof e && e !== t) { | |
i.hasDst = !0, | |
i.north = t > e, | |
i.south = e > t, | |
i.winterUtcOffset = i.north ? e : t; | |
break | |
} | |
e = t | |
} | |
return i | |
} | |
function n(t) { | |
return -t.getTimezoneOffset() / 60 | |
} | |
var s = $("#input-area") | |
, o = e() | |
, a = 1667; | |
$(window).on("scroll", t), | |
t() | |
} | |
, | |
Eggs.MovieStrip = function() {} | |
, | |
Eggs.MovieStrip.init = function() { | |
function t() { | |
var t = 1 - ($(window).scrollTop() + $(window).height()) / $(document).height(); | |
e.css("background-position", (800 * t | 0) + "px -81px") | |
} | |
var e = $("#input-area"); | |
$(window).on("scroll", t), | |
t() | |
} | |
, | |
Eggs.Assistant = function(t) { | |
var e = /(?:^|[.!?:]\s+)(?:(?:how\s+(?:can|do)\s+i)\s+([^?!.:]+)\?|(?:i(?:\s+want|(?:\s+am|'m)\s+(?:wanting|trying)|'d\s+like|\s+would\s+like)\s+to\s+([^?!.:]+)(?:$|\.|!)))/i | |
, i = e.exec(t); | |
if (i) { | |
var n = i[1] || i[2]; | |
if (n && n.length > 10) { | |
var s = $("<div class='assistant'/>").css({ | |
"position": "fixed", | |
"left": 850, | |
"bottom": 50, | |
"zIndex": 1e3 | |
}) | |
, o = $("<div/>").css({ | |
"position": "absolute", | |
"right": 99, | |
"bottom": 50, | |
"backgroundColor": "#f7f0ad", | |
"border": "1px solid black", | |
"width": 300, | |
"minHeight": 100, | |
"padding": 5, | |
"fontFamily": "'Comic Sans MS', serif", | |
"fontSize": "14px", | |
"borderRadius": 5, | |
"color": "black" | |
}).text("It looks like you're trying to " + n.replace(/\byou\b/gi, "someone").replace(/\byour\b/gi, "their").replace(/\b(?:i|me)\b/gi, "you").replace(/\bmy\b/gi, "your") + ".").appendTo(s); | |
o.append("<br/><br/>Would you like help?<br/><br/>"); | |
var a = $("<a/>").attr("href", "//superuser.com/search?q=" + encodeURIComponent(n)).text("Yes, please!").click(function() { | |
s.remove() | |
}) | |
, r = $("<a/>").attr("href", "#").text("No, thanks.").click(function(t) { | |
t.preventDefault(), | |
s.remove() | |
}); | |
a.add(r).css({ | |
"color": "black", | |
"border": "1px solid black", | |
"display": "inline-block", | |
"padding": 2, | |
"marginRight": 10 | |
}).appendTo(o); | |
var l = $("<img/>").attr("src", IMAGE("su-assistant.png")).css({ | |
"position": "absolute", | |
"right": 0, | |
"bottom": 0 | |
}).appendTo(s); | |
s.hide().appendTo("body"), | |
l[0].complete || 4 === l[0].readyState ? s.fadeIn(500) : window.setTimeout(function() { | |
s.fadeIn(500) | |
}, 1e3) | |
} | |
} | |
} | |
, | |
Eggs.Console = function(t) { | |
var e, i; | |
if (t.search(/\brm -r/) >= 0) | |
e = "[root@localhost /]# ", | |
i = "rm -rf /"; | |
else { | |
if (!(t.search(/\bdel \/s/i) >= 0)) | |
return; | |
e = "C:WINDOWS>", | |
i = "del /S /Q *.*" | |
} | |
if (!$("#egg-console").length) { | |
var n = $("<div/>").attr("id", "egg-console").css({ | |
"position": "fixed", | |
"left": 0, | |
"top": 0, | |
"width": "100%", | |
"height": "100%", | |
"color": "white", | |
"fontFamily": "monospace", | |
"zIndex": 1e3, | |
"backgroundColor": "black" | |
}).html(e + i + "<br>").appendTo("body") | |
, s = ($("<span/>").text(e).appendTo(n), | |
$("<span/>").appendTo(n)) | |
, o = $("<span/>").appendTo(n).text("_") | |
, a = setInterval(function() { | |
o.text({ | |
"": "_", | |
"_": "" | |
}[o.text()]), | |
s.text($("#input").focus().val()) | |
}, 200); | |
n.fadeTo(1e4, .9, function() { | |
$(this).fadeOut(1e4, function() { | |
$(this).remove(), | |
clearInterval(a) | |
}) | |
}) | |
} | |
} | |
, | |
Eggs.Asteroids = function(t) { | |
function e() { | |
if (!a) { | |
a = !0; | |
var t = (new Date).getTime() | |
, e = $(".signature .avatar:visible").css({ | |
"position": "relative", | |
"zIndex": 4 | |
}).get(); | |
for (var i in e) { | |
var l = e[i]; | |
l in r || (r[i] = { | |
"speed": { | |
"x": 0, | |
"y": 0 | |
}, | |
"pos": { | |
"x": 0, | |
"y": 0 | |
} | |
}) | |
} | |
var h = (new Date).getTime() | |
, c = h - t | |
, d = Math.min(3, Math.max(c / 30, 1)); | |
$("body").css({ | |
"backgroundColor": "black", | |
"color": "white", | |
"backgroundImage": "url(" + IMAGE("gaming-stars.png") + ")", | |
"backgroundRepeat": "repeat" | |
}), | |
$("#chat").css("opacity", .8), | |
$(".messages").css("color", "black"), | |
50 > c && (s = $("<div/>").css({ | |
"position": "fixed", | |
"left": 0, | |
"top": 0, | |
"width": "100%", | |
"height": "100%", | |
"zIndex": -5, | |
"backgroundImage": "url(" + IMAGE("gaming-stars2.png") + ")", | |
"backgroundRepeat": "repeat" | |
}).appendTo("body")); | |
var u = 0; | |
$("#input-area").fadeOut(1e3), | |
o = window.setInterval(function() { | |
100 > c && ($("body").css("background-position", "0 " + Math.round(2 * u) + "px"), | |
s && s.css("background-position", Math.round(u) + "px " + Math.round(3 * u) + "px"), | |
u += d); | |
for (var t in e) { | |
var i = e[t] | |
, n = r[t] | |
, o = n.pos | |
, a = n.speed; | |
a.x += d * (Math.random() / 1 - .5 + Math.max(-.2, .2 - o.x / 1e3)), | |
a.y += d * (Math.random() / 1 - .5), | |
o.y < -100 && (a.y += .2), | |
o.x += a.x * d, | |
o.y += a.y * d, | |
$(i).css({ | |
"left": Math.round(o.x) + "px", | |
"top": Math.round(o.y) + "px" | |
}) | |
} | |
}, 100 * d), | |
n() | |
} | |
} | |
function i() { | |
window.clearInterval(o), | |
$("body").css({ | |
"backgroundColor": null, | |
"color": null, | |
"backgroundImage": null | |
}), | |
$("#chat").css("opacity", 1), | |
$(".messages").css("color", null), | |
s && (s.remove(), | |
s = null), | |
$("#input-area").fadeIn(1e3), | |
a = !1 | |
} | |
if ("insert coin" == t) { | |
if (Eggs.Asteroids.go) | |
return Eggs.Asteroids.go(), | |
void 0; | |
var n, s, o, a = !1, r = {}, n = initAsteroids(i); | |
if (n) { | |
var l; | |
Eggs.Asteroids.go = function() { | |
if (!a && !l) { | |
var t = $(window).width(); | |
l = $("<button/>").addClass("button").text("click me").css({ | |
"position": "fixed", | |
"top": -40, | |
"left": 0, | |
"zIndex": 10 | |
}).appendTo("body").animate({ | |
"left": t, | |
"top": 300 | |
}, 10 * t, "swing", function() { | |
l.remove(), | |
l = null | |
}).click(function() { | |
e(), | |
l.stop().fadeOut(1e3, function() { | |
l.remove(), | |
l = null | |
}) | |
}) | |
} | |
} | |
, | |
Eggs.Asteroids.go() | |
} | |
} | |
} | |
, | |
window.initAsteroids = function(doneCallback) { | |
function Asteroids() { | |
function Vector(t, e) { | |
"Object" == typeof t ? (this.x = t.x, | |
this.y = t.y) : (this.x = t, | |
this.y = e) | |
} | |
function Line(t, e) { | |
this.p1 = t, | |
this.p2 = e | |
} | |
function radians(t) { | |
return .0174532925 * t | |
} | |
function random(t, e) { | |
return Math.floor(Math.random() * (e + 1) + t) | |
} | |
function code(t) { | |
var e = { | |
"up": 38, | |
"down": 40, | |
"left": 37, | |
"right": 39, | |
"esc": 27 | |
}; | |
return e[t] ? e[t] : t.charCodeAt(0) | |
} | |
function boundsCheck(t) { | |
t.x > w ? t.x = 0 : t.x < 0 && (t.x = w), | |
t.y > h ? t.y = 0 : t.y < 0 && (t.y = h) | |
} | |
function addEvent(t, e, i) { | |
t.addEventListener ? t.addEventListener(e, i, !1) : t.attachEvent && (t["e" + e + i] = i, | |
t[e + i] = function() { | |
t["e" + e + i](window.event) | |
} | |
, | |
t.attachEvent("on" + e, t[e + i])) | |
} | |
function removeEvent(t, e, i) { | |
t.removeEventListener ? t.removeEventListener(e, i, !1) : t.detachEvent && (t.detachEvent("on" + e, t[e + i]), | |
t[e + i] = null, | |
t["e" + e + i] = null) | |
} | |
function applyVisibility(t) { | |
for (var e, i = 0; e = window.ASTEROIDSPLAYERS[i]; i++) | |
e.gameContainer.style.visibility = t | |
} | |
function getElementFromPoint(t, e) { | |
applyVisibility("hidden"); | |
var i = document.elementFromPoint(t, e); | |
return i ? (3 == i.nodeType && (i = i.parentNode), | |
applyVisibility("visible"), | |
i) : (applyVisibility("visible"), | |
!1) | |
} | |
function addParticles(t) { | |
for (var e = (new Date).getTime(), i = maxParticles, n = 0; i > n; n++) | |
that.particles.push({ | |
"dir": new Vector(20 * Math.random() - 10,20 * Math.random() - 10).normalize(), | |
"pos": t.cp(), | |
"cameAlive": e | |
}) | |
} | |
function setScore() { | |
that.points.innerHTML = 10 * window.ASTEROIDS.enemiesKilled | |
} | |
function indexOf(t, e, i) { | |
if (t.indexOf) | |
return t.indexOf(e, i); | |
for (var n = t.length, s = 0 > i ? Math.max(0, n + i) : i || 0; n > s; s++) | |
if (t[s] === e) | |
return s; | |
return -1 | |
} | |
function addClass(t, e) { | |
-1 == t.className.indexOf(e) && (t.className = (t.className + " " + e).replace(/\s+/g, " ").replace(/^\s+|\s+$/g, "")) | |
} | |
function removeClass(t, e) { | |
t.className = t.className.replace(new RegExp("(^|\\s)" + e + "(?:\\s|$)"), "$1") | |
} | |
function removeStylesheet(t) { | |
var e = document.getElementById(t); | |
e && e.parentNode.removeChild(e) | |
} | |
function destroy() { | |
removeEvent(document, "keydown", eventKeydown), | |
removeEvent(document, "keypress", eventKeypress), | |
removeEvent(document, "keyup", eventKeyup), | |
removeEvent(window, "resize", eventResize), | |
isRunning = !1, | |
removeStylesheet("ASTEROIDSYEAHSTYLES"), | |
removeClass(document.body, "ASTEROIDSYEAH"), | |
this.gameContainer.parentNode.removeChild(this.gameContainer), | |
doneCallback() | |
} | |
window.ASTEROIDS || (window.ASTEROIDS = { | |
"enemiesKilled": 0 | |
}), | |
Vector.prototype = { | |
"cp": function() { | |
return new Vector(this.x,this.y) | |
}, | |
"mul": function(t) { | |
return this.x *= t, | |
this.y *= t, | |
this | |
}, | |
"mulNew": function(t) { | |
return new Vector(this.x * t,this.y * t) | |
}, | |
"add": function(t) { | |
return this.x += t.x, | |
this.y += t.y, | |
this | |
}, | |
"addNew": function(t) { | |
return new Vector(this.x + t.x,this.y + t.y) | |
}, | |
"sub": function(t) { | |
return this.x -= t.x, | |
this.y -= t.y, | |
this | |
}, | |
"subNew": function(t) { | |
return new Vector(this.x - t.x,this.y - t.y) | |
}, | |
"rotate": function(t) { | |
var e = this.x | |
, i = this.y; | |
return this.x = e * Math.cos(t) - Math.sin(t) * i, | |
this.y = e * Math.sin(t) + Math.cos(t) * i, | |
this | |
}, | |
"rotateNew": function(t) { | |
return this.cp().rotate(t) | |
}, | |
"setAngle": function(t) { | |
var e = this.len(); | |
return this.x = Math.cos(t) * e, | |
this.y = Math.sin(t) * e, | |
this | |
}, | |
"setAngleNew": function(t) { | |
return this.cp().setAngle(t) | |
}, | |
"setLength": function(t) { | |
var e = this.len(); | |
return e ? this.mul(t / e) : this.x = this.y = t, | |
this | |
}, | |
"setLengthNew": function(t) { | |
return this.cp().setLength(t) | |
}, | |
"normalize": function() { | |
var t = this.len(); | |
return this.x /= t, | |
this.y /= t, | |
this | |
}, | |
"normalizeNew": function() { | |
return this.cp().normalize() | |
}, | |
"angle": function() { | |
return Math.atan2(this.y, this.x) | |
}, | |
"collidesWith": function(t) { | |
return this.x > t.x && this.y > t.y && this.x < t.x + t.width && this.y < t.y + t.height | |
}, | |
"len": function() { | |
var t = Math.sqrt(this.x * this.x + this.y * this.y); | |
return .005 > t && t > -.005 ? 0 : t | |
}, | |
"is": function(t) { | |
return "object" == typeof t && this.x == t.x && this.y == t.y | |
}, | |
"toString": function() { | |
return "[Vector(" + this.x + ", " + this.y + ") angle: " + this.angle() + ", length: " + this.len() + "]" | |
} | |
}, | |
Line.prototype = { | |
"shift": function(t) { | |
this.p1.add(t), | |
this.p2.add(t) | |
}, | |
"intersectsWithRect": function(t) { | |
var e = new Vector(t.x,t.y + t.height) | |
, i = new Vector(t.x,t.y) | |
, n = new Vector(t.x + t.width,t.y + t.height) | |
, s = new Vector(t.x + t.width,t.y); | |
return this.p1.x > e.x && this.p1.x < s.x && this.p1.y < e.y && this.p1.y > s.y && this.p2.x > e.x && this.p2.x < s.x && this.p2.y < e.y && this.p2.y > s.y ? !0 : this.intersectsLine(new Line(i,e)) ? !0 : this.intersectsLine(new Line(e,n)) ? !0 : this.intersectsLine(new Line(i,s)) ? !0 : this.intersectsLine(new Line(s,n)) ? !0 : !1 | |
}, | |
"intersectsLine": function(t) { | |
var e = this.p1 | |
, i = this.p2 | |
, n = t.p1 | |
, s = t.p2 | |
, o = (s.y - n.y) * (i.x - e.x) - (s.x - n.x) * (i.y - e.y) | |
, a = (s.x - n.x) * (e.y - n.y) - (s.y - n.y) * (e.x - n.x) | |
, r = (i.x - e.x) * (e.y - n.y) - (i.y - e.y) * (e.x - n.x); | |
if (0 == o) | |
return !1; | |
var l = a / o | |
, h = r / o; | |
return l >= 0 && 1 >= l && h >= 0 && 1 >= h | |
} | |
}; | |
var that = this | |
, isIE = !!window.ActiveXObject | |
, isIEQuirks = isIE && "BackCompat" == document.compatMode | |
, w = document.documentElement.clientWidth | |
, h = document.documentElement.clientHeight; | |
isIEQuirks && (w = document.body.clientWidth, | |
h = document.body.clientHeight); | |
var playerWidth = 20 | |
, playerHeight = 30 | |
, playerVerts = [[-1 * playerHeight / 2, -1 * playerWidth / 2], [-1 * playerHeight / 2, playerWidth / 2], [playerHeight / 2, 0]] | |
, FPS = 50 | |
, acc = 300 | |
, maxSpeed = 600 | |
, rotSpeed = 360 | |
, bulletSpeed = 700 | |
, particleSpeed = 400 | |
, timeBetweenFire = 150 | |
, bulletRadius = 2 | |
, maxParticles = isIE ? 20 : 40 | |
, maxBullets = isIE ? 10 : 20; | |
this.flame = { | |
"r": [], | |
"y": [] | |
}, | |
this.pos = new Vector(100,100), | |
this.lastPos = !1, | |
this.vel = new Vector(0,0), | |
this.dir = new Vector(0,1), | |
this.keysPressed = {}, | |
this.firedAt = !1, | |
this.updated = { | |
"flame": (new Date).getTime() | |
}, | |
this.scrollPos = new Vector(0,0), | |
this.bullets = [], | |
this.enemies = $(".signature .avatar:visible").get(), | |
this.dying = [], | |
this.totalEnemies = this.enemies.length, | |
this.particles = []; | |
var createFlames; | |
with (function() { | |
var t = playerWidth | |
, e = .1 * playerWidth | |
, i = .6 * playerWidth | |
, n = .2 * i | |
, s = t / 2 | |
, o = i / 2 | |
, a = playerHeight / 2; | |
createFlames = function() { | |
that.flame.r = [[-1 * a, -1 * s]], | |
that.flame.y = [[-1 * a, -1 * o]]; | |
for (var r = 0; t > r; r += e) | |
that.flame.r.push([-random(2, 7) - a, r - s]); | |
that.flame.r.push([-1 * a, s]); | |
for (var r = 0; i > r; r += n) | |
that.flame.y.push([-random(2, 7) - a, r - o]); | |
that.flame.y.push([-1 * a, o]) | |
} | |
}(), | |
createFlames(), | |
this.gameContainer = document.createElement("div"), | |
this.gameContainer.className = "ASTEROIDSYEAH", | |
document.body.appendChild(this.gameContainer), | |
this.canvas = document.createElement("canvas"), | |
this.canvas.setAttribute("width", w), | |
this.canvas.setAttribute("height", h), | |
this.canvas.className = "ASTEROIDSYEAH", | |
this.canvas.style) | |
width = w + "px", | |
height = h + "px", | |
position = "fixed", | |
top = "0px", | |
left = "0px", | |
bottom = "0px", | |
right = "0px", | |
zIndex = "10000"; | |
addEvent(this.canvas, "mousedown", function(t) { | |
t = t || window.event; | |
var e = document.createElement("span"); | |
e.style.position = "absolute", | |
e.style.border = "1px solid #999", | |
e.style.background = "white", | |
e.style.color = "black", | |
e.innerHTML = "Press Esc to quit", | |
document.body.appendChild(e); | |
var i = t.pageX || t.clientX + document.documentElement.scrollLeft | |
, n = t.pageY || t.clientY + document.documentElement.scrollTop; | |
e.style.left = i - e.offsetWidth / 2 + "px", | |
e.style.top = n - e.offsetHeight / 2 + "px", | |
setTimeout(function() { | |
try { | |
e.parentNode.removeChild(e) | |
} catch (t) {} | |
}, 1e3) | |
}); | |
var eventResize = function() { | |
if (isIE) | |
w = document.documentElement.clientWidth, | |
h = document.documentElement.clientHeight, | |
isIEQuirks && (w = document.body.clientWidth, | |
h = document.body.clientHeight), | |
that.canvas.setAttribute("width", w), | |
that.canvas.setAttribute("height", h); | |
else | |
with (that.canvas.style.display = "none", | |
w = document.documentElement.clientWidth, | |
h = document.documentElement.clientHeight, | |
that.canvas.setAttribute("width", w), | |
that.canvas.setAttribute("height", h), | |
that.canvas.style) | |
display = "block", | |
width = w + "px", | |
height = h + "px" | |
}; | |
if (addEvent(window, "resize", eventResize), | |
this.gameContainer.appendChild(this.canvas), | |
this.ctx = this.canvas.getContext("2d"), | |
this.ctx.fillStyle = "#00a0ff", | |
this.ctx.strokeStyle = "black", | |
document.getElementById("ASTEROIDS-NAVIGATION")) | |
this.navigation = document.getElementById("ASTEROIDS-NAVIGATION"), | |
this.points = document.getElementById("ASTEROIDS-POINTS"); | |
else { | |
with (this.navigation = document.createElement("div"), | |
this.navigation.id = "ASTEROIDS-NAVIGATION", | |
this.navigation.className = "ASTEROIDSYEAH", | |
this.navigation.style) | |
fontFamily = "Arial,sans-serif", | |
position = "fixed", | |
zIndex = "10001", | |
bottom = "10px", | |
right = "10px", | |
textAlign = "right"; | |
this.navigation.innerHTML = "(press esc to quit) ", | |
this.gameContainer.appendChild(this.navigation), | |
this.points = document.createElement("span"), | |
this.points.id = "ASTEROIDS-POINTS", | |
this.points.style.font = "28pt Arial, sans-serif", | |
this.points.style.fontWeight = "bold", | |
this.points.className = "ASTEROIDSYEAH", | |
this.navigation.appendChild(this.points) | |
} | |
if (isIEQuirks && (this.gameContainer.style.position = this.canvas.style.position = this.navigation.style.position = "absolute"), | |
setScore(), | |
"undefined" != typeof G_vmlCanvasManager) | |
for (var c, children = this.canvas.getElementsByTagName("*"), i = 0; c = children[i]; i++) | |
addClass(c, "ASTEROIDSYEAH"); | |
var eventKeydown = function(t) { | |
switch (t = t || window.event, | |
that.keysPressed[t.keyCode] = !0, | |
t.keyCode) { | |
case code(" "): | |
that.firedAt = 1 | |
} | |
return -1 != indexOf([code("up"), code("down"), code("right"), code("left"), code(" "), code("B"), code("W"), code("A"), code("S"), code("D")], t.keyCode) ? (t.preventDefault && t.preventDefault(), | |
t.stopPropagation && t.stopPropagation(), | |
t.returnValue = !1, | |
t.cancelBubble = !0, | |
!1) : void 0 | |
}; | |
addEvent(document, "keydown", eventKeydown); | |
var eventKeypress = function(t) { | |
return t = t || window.event, | |
-1 != indexOf([code("up"), code("down"), code("right"), code("left"), code(" "), code("W"), code("A"), code("S"), code("D")], t.keyCode || t.which) ? (t.preventDefault && t.preventDefault(), | |
t.stopPropagation && t.stopPropagation(), | |
t.returnValue = !1, | |
t.cancelBubble = !0, | |
!1) : void 0 | |
}; | |
addEvent(document, "keypress", eventKeypress); | |
var eventKeyup = function(t) { | |
return t = t || window.event, | |
that.keysPressed[t.keyCode] = !1, | |
-1 != indexOf([code("up"), code("down"), code("right"), code("left"), code(" "), code("B"), code("W"), code("A"), code("S"), code("D")], t.keyCode) ? (t.preventDefault && t.preventDefault(), | |
t.stopPropagation && t.stopPropagation(), | |
t.returnValue = !1, | |
t.cancelBubble = !0, | |
!1) : void 0 | |
}; | |
addEvent(document, "keyup", eventKeyup), | |
this.ctx.clear = function() { | |
this.clearRect(0, 0, w, h) | |
} | |
, | |
this.ctx.clear(), | |
this.ctx.drawLine = function(t, e, i, n) { | |
this.beginPath(), | |
this.moveTo(t, e), | |
this.lineTo(i, n), | |
this.lineTo(i + 1, n + 1), | |
this.closePath(), | |
this.fill() | |
} | |
, | |
this.ctx.tracePoly = function(t) { | |
this.beginPath(), | |
this.moveTo(t[0][0], t[0][1]); | |
for (var e = 1; e < t.length; e++) | |
this.lineTo(t[e][0], t[e][1]); | |
this.closePath() | |
} | |
, | |
this.ctx.drawPlayer = function() { | |
this.save(), | |
this.translate(that.pos.x, that.pos.y), | |
this.rotate(that.dir.angle()), | |
this.tracePoly(playerVerts), | |
this.fillStyle = "white", | |
this.fill(), | |
this.tracePoly(playerVerts), | |
this.stroke(), | |
this.restore() | |
} | |
; | |
var PI_SQ = 2 * Math.PI; | |
this.ctx.drawBullets = function(t) { | |
for (var e = 0; e < t.length; e++) | |
this.beginPath(), | |
this.arc(t[e].pos.x, t[e].pos.y, bulletRadius, 0, PI_SQ, !0), | |
this.closePath(), | |
this.fill() | |
} | |
; | |
var randomParticleColor = function() { | |
return ["red", "yellow"][random(0, 1)] | |
}; | |
this.ctx.drawParticles = function(t) { | |
for (var e = this.fillStyle, i = 0; i < t.length; i++) | |
this.fillStyle = randomParticleColor(), | |
this.drawLine(t[i].pos.x, t[i].pos.y, t[i].pos.x - 10 * t[i].dir.x, t[i].pos.y - 10 * t[i].dir.y); | |
this.fillStyle = e | |
} | |
, | |
this.ctx.drawFlames = function(t) { | |
this.save(), | |
this.translate(that.pos.x, that.pos.y), | |
this.rotate(that.dir.angle()); | |
var e = this.strokeStyle; | |
this.strokeStyle = "red", | |
this.tracePoly(t.r), | |
this.stroke(), | |
this.strokeStyle = "yellow", | |
this.tracePoly(t.y), | |
this.stroke(), | |
this.strokeStyle = e, | |
this.restore() | |
} | |
; | |
try { | |
window.focus() | |
} catch (e) {} | |
addParticles(this.pos), | |
addClass(document.body, "ASTEROIDSYEAH"); | |
var isRunning = !0 | |
, lastUpdate = (new Date).getTime(); | |
this.update = function() { | |
var t = !1 | |
, e = (new Date).getTime() | |
, i = (e - lastUpdate) / 1e3; | |
lastUpdate = e; | |
var n = !1; | |
if (e - this.updated.flame > 50 && (createFlames(), | |
this.updated.flame = e), | |
this.scrollPos.x = window.pageXOffset || document.documentElement.scrollLeft, | |
this.scrollPos.y = window.pageYOffset || document.documentElement.scrollTop, | |
this.keysPressed[code("up")] || this.keysPressed[code("W")] ? (this.vel.add(this.dir.mulNew(acc * i)), | |
n = !0) : this.vel.mul(.96), | |
(this.keysPressed[code("left")] || this.keysPressed[code("A")]) && (t = !0, | |
this.dir.rotate(radians(rotSpeed * i * -1))), | |
(this.keysPressed[code("right")] || this.keysPressed[code("D")]) && (t = !0, | |
this.dir.rotate(radians(rotSpeed * i))), | |
this.keysPressed[code(" ")] && e - this.firedAt > timeBetweenFire && (this.bullets.unshift({ | |
"dir": this.dir.cp(), | |
"pos": this.pos.cp(), | |
"startVel": this.vel.cp(), | |
"cameAlive": e | |
}), | |
this.firedAt = e, | |
this.bullets.length > maxBullets && this.bullets.pop()), | |
this.keysPressed[code("esc")]) | |
return destroy.apply(this), | |
void 0; | |
this.vel.len() > maxSpeed && this.vel.setLength(maxSpeed), | |
this.pos.add(this.vel.mulNew(i)), | |
this.pos.x > w ? (window.scrollTo(this.scrollPos.x + 50, this.scrollPos.y), | |
this.pos.x = 0) : this.pos.x < 0 && (window.scrollTo(this.scrollPos.x - 50, this.scrollPos.y), | |
this.pos.x = w), | |
this.pos.y > h ? (window.scrollTo(this.scrollPos.x, this.scrollPos.y + .75 * h), | |
this.pos.y = 0) : this.pos.y < 0 && (window.scrollTo(this.scrollPos.x, this.scrollPos.y - .75 * h), | |
this.pos.y = h); | |
for (var s = this.bullets.length - 1; s >= 0; s--) | |
if (e - this.bullets[s].cameAlive > 2e3) | |
this.bullets.splice(s, 1), | |
t = !0; | |
else { | |
var o = this.bullets[s].dir.setLengthNew(bulletSpeed * i).add(this.bullets[s].startVel.mulNew(i)); | |
this.bullets[s].pos.add(o), | |
boundsCheck(this.bullets[s].pos); | |
var a = getElementFromPoint(this.bullets[s].pos.x, this.bullets[s].pos.y); | |
$(a).is(".signature .avatar:visible *") && (didKill = !0, | |
addParticles(this.bullets[s].pos), | |
this.dying.push(a), | |
this.bullets.splice(s, 1)) | |
} | |
if (this.dying.length) { | |
for (var s = this.dying.length - 1; s >= 0; s--) | |
try { | |
this.dying[s].parentNode && window.ASTEROIDS.enemiesKilled++, | |
this.dying[s].parentNode.removeChild(this.dying[s]) | |
} catch (r) {} | |
setScore(), | |
this.dying = [] | |
} | |
for (var s = this.particles.length - 1; s >= 0; s--) | |
this.particles[s].pos.add(this.particles[s].dir.mulNew(particleSpeed * i * Math.random())), | |
e - this.particles[s].cameAlive > 1e3 && (this.particles.splice(s, 1), | |
t = !0); | |
isIEQuirks && (this.gameContainer.style.left = this.canvas.style.left = document.documentElement.scrollLeft + "px", | |
this.gameContainer.style.top = this.canvas.style.top = document.documentElement.scrollTop + "px", | |
this.navigation.style.right = "10px", | |
this.navigation.style.top = document.documentElement.scrollTop + document.body.clientHeight - this.navigation.clientHeight - 10 + "px"), | |
(t || 0 != this.bullets.length || 0 != this.particles.length || !this.pos.is(this.lastPos) || this.vel.len() > 0) && (this.ctx.clear(), | |
this.ctx.drawPlayer(), | |
n && this.ctx.drawFlames(that.flame), | |
this.bullets.length && this.ctx.drawBullets(this.bullets), | |
this.particles.length && this.ctx.drawParticles(this.particles)), | |
this.lastPos = this.pos, | |
setTimeout(updateFunc, 1e3 / FPS) | |
} | |
; | |
var updateFunc = function() { | |
that.update.call(that) | |
}; | |
setTimeout(updateFunc, 1e3 / FPS) | |
} | |
return document.createElement("canvas").getContext ? (window.ASTEROIDSPLAYERS || (window.ASTEROIDSPLAYERS = []), | |
function() { | |
window.ASTEROIDSPLAYERS[window.ASTEROIDSPLAYERS.length] = new Asteroids | |
} | |
) : !1 | |
} | |
, | |
Eggs.Cthulu = function(t) { | |
function e() { | |
function t() { | |
for (var t = Math.random() - .7, e = "", i = 0; t > i; i += .15) | |
e += "&#" + (768 + Math.round(95 * Math.random())) + ";"; | |
return e | |
} | |
if (!Eggs.Cthulu.Functions) { | |
var e = []; | |
Eggs.Cthulu.Functions = {}; | |
var i = ["The <center> cannot hold it is too late.", "You can't parse [X]HTML with regex.", "Regex is not a tool that can be used to correctly parse HTML.", "The use of regex will not allow you to consume HTML.", "Russian hackers pwn your webapp", "ALL IS LOST ALL IS LOST", "ZALGO IS TONY THE PONY HE COMES", "so many times but it is not getting to me.", "HTML is not a regular language", "not equipped to break down HTML into its meaningful parts", "go no NO NOOOO NO stop the angles are not real", "we cannot be saved", "You will never make me crack.", "a breach between this world and the dread realm of corrupt entities", "Even Jon Skeet cannot parse HTML using regular expressions.", "the unholy child weeps the blood of virgins", "it is too late it is too late", "an eternity of dread torture and security holes", "your psyche withering in the onslaught of horror", "will destroy your mind like so much watery putty", "his unholy radiance destroying all enlightenmnent", "HTML tags leaking from your eyes like liquid pain", "I can see it can you see it", "the One whose Name cannot be expressed in the Basic Multilingual Plane", "summons tainted souls into the realm of the living", "the pony he comes he comes he comes", "regex will consume all living tissue", "the ichor permeates all MY FACE MY FACE"]; | |
Eggs.Cthulu.Functions.sentence = function() { | |
return i[Math.round(Math.pow(Math.random(), 2) * (i.length - 1))] | |
} | |
; | |
var n = !1; | |
Eggs.Cthulu.Functions.startTicking = function() { | |
n || (n = !0, | |
window.setTimeout(tick, 40)) | |
} | |
, | |
Eggs.Cthulu.Functions.stopTicking = function() { | |
n = !1 | |
} | |
; | |
var s = 1; | |
tick = function() { | |
for (var t = (new Date).getTime(), i = e.length - 1; i >= 0; i--) { | |
var o = e[i] | |
, a = o.step += s; | |
if (!(0 > a)) | |
if (150 >= a) { | |
var r = .5 - Math.cos(Math.PI * o.step / 150) / 2 | |
, l = Math.sin(r * Math.PI * 2) | |
, h = o.startX + r * o.deltaX + l * o.drift | |
, c = o.startY + r * o.deltaY + l * o.drift | |
, d = o.startSize + r * o.deltaSize - 10 * l | |
, u = null; | |
(s = 1) && (u = "rotate(" + l * o.rotation + "deg)"); | |
var p = o.elem[0]; | |
p.style.left = h + "px", | |
p.style.top = c + "px", | |
p.style.fontSize = d + "px", | |
p.style.WebkitTransform = u | |
} else if (250 >= a) { | |
var r = (o.step - 150) / 100; | |
o.elem[0].style.opacity = 1 - r | |
} else | |
o.elem.remove(), | |
e.splice(i, 1) | |
} | |
var g = (new Date).getTime() - t; | |
if (s = Math.max(1, Math.ceil((g + 20) / 40)), | |
s = Math.min(s, 25), | |
n) | |
window.setTimeout(tick, 40 * s); | |
else { | |
for (var i = 0; i < e.length; i++) | |
e[i].elem.remove(); | |
e = [] | |
} | |
} | |
, | |
Eggs.Cthulu.Functions.fly = function(i, n) { | |
function s(s) { | |
return function() { | |
for (var c = i.substr(s, h), d = "", u = 0; u < c.length; u++) | |
d += t() + c.substr(u, 1); | |
d = d.replace("<", "<").replace(">", ">"), | |
l.text(i.substr(s)); | |
var p = $(window).width() / 2 + (2 * Math.round(Math.random()) - 1) * ($(window).width() / 2 + Math.round(500 * Math.random())) | |
, g = $(window).height() / 2 + (2 * Math.round(Math.random()) - 1) * ($(window).height() / 2 + Math.round(500 * Math.random())) | |
, m = { | |
"position": "absolute", | |
"left": p, | |
"top": g, | |
"color": o | |
}; | |
Math.random() > .5 && (m.fontWeight = "bold"), | |
Math.random() > .5 && (m.fontStyle = "italic"); | |
var f = $("<span/>").html(t() + d).css(m).appendTo(n) | |
, y = l.offset().left; | |
e.push({ | |
"elem": f, | |
"startX": p, | |
"startY": g, | |
"startSize": 11, | |
"deltaX": y - p, | |
"deltaY": a - g, | |
"deltaSize": r - 11, | |
"rotation": 180 * (Math.random() - .5), | |
"drift": 400 * (Math.random() - .5), | |
"step": Math.round(-25 * Math.random()) | |
}) | |
} | |
} | |
for (var o = "rgb(" + Math.round(255 * Math.random()) + ",0,0)", a = Math.round(Math.random() * ($(window).height() - 100)), r = 30 * Math.random() + 20, l = $("<div>lg</div>").css({ | |
"whiteSpace": "nowrap", | |
"fontSize": r, | |
"position": "absolute", | |
"top": a, | |
"right": 100 + Math.round(500 * Math.random()), | |
"visibility": "hidden" | |
}).appendTo(n), h = 1 + Math.round(i.length / 10), c = 0; c < i.length; c += h) | |
window.setTimeout(s(c), 25 * c * (1 + Math.random())) | |
} | |
} | |
} | |
if (Eggs.Cthulu.running = !1, | |
-1 != t.search(/<[^>]*\[\^[^\]]*>.*\]/)) { | |
Eggs.Cthulu.running = !0, | |
e(); | |
var i = $("<div/>").css({ | |
"position": "fixed", | |
"width": "100%", | |
"height": "100%", | |
"zIndex": 4, | |
"left": 0, | |
"top": 0, | |
"cursor": "pointer" | |
}).appendTo("#main").click(function() { | |
window.open("//stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454"), | |
Eggs.Cthulu.running = !1 | |
}) | |
, n = function() { | |
Eggs.Cthulu.running ? (Eggs.Cthulu.Functions.fly(Eggs.Cthulu.Functions.sentence(), i), | |
window.setTimeout(n, 3e3 * Math.random() + 2e3)) : (i.unbind("click"), | |
i.fadeOut(5e3, function() { | |
i.remove(), | |
Eggs.Cthulu.Functions.stopTicking() | |
})) | |
}; | |
n(), | |
Eggs.Cthulu.Functions.startTicking() | |
} | |
} | |
, | |
Eggs.WOB = function() {} | |
, | |
Eggs.WOB.init = function() { | |
$("#sound").click(function() { | |
setTimeout(function() { | |
function t(t, s) { | |
$('<li><a href="#" /></li>').appendTo(n).find("a").click(function() { | |
return localStorage.setItem("wheelsound", s), | |
i.remove(), | |
!1 | |
}).text(t + (e === s ? " (current setting)" : "")) | |
} | |
var e = parseInt(localStorage.getItem("wheelsound")) || 0 | |
, i = $(".popup"); | |
$("<br />").appendTo(i), | |
$("<h2 />").text("Wheel music").appendTo(i); | |
var n = $("<ul />").appendTo(i); | |
t("on", 2), | |
t("off", 1), | |
t("like mentioned", 0) | |
}, 0) | |
}) | |
} | |
, | |
Eggs.WOB.blame = function(t, e) { | |
function i(t) { | |
return t * t | |
} | |
function n() { | |
m.clearRect(0, 0, r, l); | |
var t = !0; | |
for (var n in f) { | |
var s = f[n]; | |
if (w < s.entryTime) { | |
var o = Math.sqrt(i(s.startX - b.startX) + 0 * i(s.startY - b.startY)) | |
, a = w / s.entryTime; | |
s.x = b.startX + a * (v.x - b.startX) + (1 - a) * Math.cos(a * Math.PI * 4) * o, | |
s.y = s.startY + a * (v.y - s.startY) + (1 - a) * Math.sin(a * Math.PI * 4) * o, | |
t = !1 | |
} else { | |
var h = w - s.entryTime + 25 | |
, c = 2 * h * Math.PI / 100 | |
, d = u; | |
s.x = r / 2 + Math.cos(c) * d - 16, | |
s.y = l / 2 - Math.sin(c) * d - 16 | |
} | |
if (actualX = s.x, | |
actualY = s.y, | |
.1 > S) | |
if (s != p) | |
m.globalAlpha = 2 * Math.max(S / .1 - .5, 0); | |
else { | |
m.globalAlpha = 1; | |
var g = e.offset(); | |
g.top -= $(window).scrollTop(); | |
var y = 1 - Math.max(0, S - .03) / .07; | |
actualX = s.x + y * (g.left - s.x), | |
actualY = s.y + y * (g.top - s.y) | |
} | |
m.drawImage(s.image, actualX, actualY, 32, 32), | |
x = t | |
} | |
} | |
function s() { | |
E.x += E.vx, | |
E.y += E.vy, | |
E.z += E.vz; | |
var t = (E.x - d.x) / u | |
, e = (E.y - d.y) / u | |
, i = Math.sqrt(Math.pow(t, 2) + Math.pow(e, 2)); | |
E.vz -= .1, | |
E.z <= 0 && (E.vz *= -.8, | |
E.z *= -1, | |
E.vy -= 50 * t, | |
E.vx += 50 * e), | |
i >= 1 && (E.vx *= -.9, | |
E.vy *= -.9, | |
E.x = d.x + u * Math.min(t, .95), | |
E.y = d.y + u * Math.min(e, .95)); | |
var n = 0; | |
.5 > S && (n = .1 > S ? 1 : Math.cos((S - .1) / .4 * Math.PI) / 2 + .5), | |
actualX = E.x + n * (p.x - E.x), | |
actualY = E.y + n * (p.y - E.y), | |
actualZ = E.z * (1 - n), | |
m.beginPath(), | |
m.arc(actualX, actualY, 10 + actualZ, 0, 2 * Math.PI, !1), | |
m.save(), | |
m.fill(), | |
m.restore(), | |
m.stroke() | |
} | |
function o() { | |
var t = window.setInterval(function() { | |
x && (A -= 2e3, | |
S = A / 1e6), | |
w += S, | |
n(), | |
x && s(), | |
.03 > S && (window.clearInterval(t), | |
c.fadeIn(), | |
e.css("visibility", "visible"), | |
h.remove(), | |
setTimeout(function() { | |
k.remove() | |
}, 1e4)) | |
}, 40) | |
} | |
var a = e.closest(".message"); | |
if (0 != a.length && a.hasClass("neworedit") && !a.find(".quote").length) { | |
var r = $(window).width() | |
, l = $(window).height() | |
, h = $('<canvas width="' + r + '" height="' + l + '" />'); | |
if (h.get(0).getContext) { | |
e.css("visibility", "hidden"); | |
var c = a.find(".blamee").hide() | |
, d = { | |
"x": r / 2, | |
"y": l / 2 | |
} | |
, u = .4 * Math.min(r, l); | |
h.css({ | |
"position": "fixed", | |
"left": 0, | |
"top": 0, | |
"width": r, | |
"height": l, | |
"zIndex": 100 | |
}).appendTo("body"); | |
var p, g, m = h.get(0).getContext("2d"), f = [], y = $("#present-users > li").filter(function() { | |
var t = $(this).attr("id") || ""; | |
return parseInt(t.replace("present-user-", "")) > 0 | |
}); | |
0 == y.filter(".user-" + t).length && (y = y.add(a), | |
g = a), | |
y.each(function(e) { | |
var i = $(this).find("img") | |
, n = g && this == g.get(0) | |
, s = n ? $("#present-users").offset() : i.offset() | |
, o = { | |
"image": i.get(0), | |
"startX": s.left, | |
"startY": s.top - $(window).scrollTop(), | |
"entryTime": 100 + 100 * e / y.length | |
}; | |
($(this).hasClass("user-" + t) || n) && (p = o), | |
f.push(o) | |
}); | |
var v = { | |
"x": d.x - 16, | |
"y": d.y - u - 16 | |
} | |
, w = 0 | |
, x = !1 | |
, b = f[0] | |
, E = { | |
"x": d.x, | |
"y": d.y, | |
"z": 20, | |
"vx": 40 * Math.random() - 20, | |
"vy": 40 * Math.random() - 20, | |
"vz": 0 | |
} | |
, S = 1 | |
, T = $.cookie("sl") | |
, M = parseInt(localStorage.getItem("wheelsound")) || 0 | |
, k = $("<div/>").css("opacity", 0).appendTo("body"); | |
if (2 === M || 0 === M && (null == T || T >= 1)) { | |
var I = "/Content/wheel7"; | |
k.one($.jPlayer.event.playing, o), | |
k.jPlayer({ | |
"ready": function() { | |
k.jPlayer("setMedia", { | |
"mp3": I + ".mp3", | |
"oga": I + ".ogg" | |
}), | |
k.jPlayer("play") | |
}, | |
"solution": "html", | |
"supplied": "mp3,oga", | |
"volume": .5 | |
}) | |
} else | |
o(); | |
var A = 1e6; | |
m.fillStyle = "white", | |
m.strokeStyle = "black" | |
} | |
} | |
} | |
, | |
Eggs.MTG = function() {} | |
, | |
Eggs.MTG.init = function() { | |
$(function() { | |
$(".mtg-autocard").live("click", function() { | |
var t = $(this).attr("href"); | |
return window.open(t, "autocard" + +new Date, "toolbar=0, location=0, directories=0, status=0,menubar=0, scrollbars=0, resizable=0, width=770, height=890"), | |
!1 | |
}) | |
}) | |
} | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment