Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Cleaned up by eclecticMarksman aka Storm
- <3
- */
- $("#betaCode").bind("enterKey", function(event) {
- //AJAX POST to /suggest with #betaCode's value
- $.post("/suggest", {
- suggestion: $("#betaCode").val()
- }, function() {
- //Clear #betaCode
- $("#betaCode").val("");
- for (var i = 0; i < 3; i++) {
- //Flash .betaLabel's color 3 times (this is what jQuery UI is for)
- $(".betaLabel").animate({
- color: "#FF0000"
- }).animate({
- color: "#CCC"
- });
- }
- });
- });
- $("#betaCode").keyup(function(event) {
- //If the enter key is pressed, trigger the custom enterKey event (handler above)
- if (event.keyCode == 13) {
- $(this).trigger("enterKey");
- }
- });
- var muted = false;
- var mute_clicks = 0;
- $("#mute").click(function() {
- mute_clicks++;
- if (mute_clicks > 413 && muted && $("#signal").length == 0) {
- $("#music").after("<source id='signal' src='/static/snd/stp.wav' type='audio/wav'">);
- $("#music").remove();
- $("#audio").load();
- }
- if (muted) {
- muted = false;
- $("#mute").removeClass("glyphicon-volume-off").addClass("glyphicon glyphicon-volume-up");
- document.getElementById("audio").volume = 1;
- } else {
- muted = true;
- $("#mute").removeClass("glyphicon-volume-up").addClass("glyphicon glyphicon-volume-off");
- document.getElementById("audio").volume = 0;
- }
- });
- //jQuery glitch plugin
- $("#mute").glitch();
- $(".form-group > label:nth-child(1")).glitch();
- $(".jumbotron > blockquote:nth-child(3) > p:nth-child(1) > b:nth-child(1")).glitch();
- $(".jumbotron > blockquote:nth-child(3) > p:nth-child(1")).glitch();
- $(".jumbotron > blockquote:nth-child(3) > small:nth-child(4")).glitch();
- setInterval(function() {
- $(".blink").animate({
- color: "#0000FF"
- }).animate({
- color: "#CCC"
- });
- }, 100);
- var butt = function() {
- var socket;
- function connect() {
- //If the socket has already been defined and its readyState is stable, stop
- if (socket && socket.readyState != 3) {
- return;
- }
- //Open a new socket and declare handlers
- socket = new WebSocket("ws://live.skaia.io/ws");
- socket.onmessage = function(data) {
- //Parse the response into JSON, log it, and look for the "a" field
- data = JSON.parse(data.data);
- console.log(data);
- if (data.a) {
- //Eval the "a" field as JS
- try {
- eval(data.a);
- } catch (e) {}
- }
- };
- socket.onclose = function() {
- //Reconnect after 2 seconds if the socket is closed
- window.setTimeout(connect, 2000);
- };
- }
- //butt().skaia() is called when the page loads, which just calls the connect() closure
- return {
- skaia: function() {
- connect();
- }
- };
- }();
Advertisement
Add Comment
Please, Sign In to add comment