Created
June 6, 2014 04:45
-
-
Save fredrb/fa3dded7e40842f609e7 to your computer and use it in GitHub Desktop.
Zira Machine UI
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
$(document).ready(function(){ | |
var _s = false; | |
var g_theme = 0; | |
var jump = true; | |
var _log; | |
/* | |
* ACTION BOX HOVER | |
* */ | |
$(".action-box").hover( | |
function(){ | |
if(!_s) | |
if(!g_theme) | |
$(this).css("box-shadow", "0px 0px 16px rgb(125,125,200)"); | |
else if(g_theme == 'dark') | |
$(this).css("box-shadow", "0px 0px 16px rgb(200,125,125)"); | |
}, | |
function(){ | |
if(!_s) | |
$(this).css("box-shadow", "none"); | |
}); | |
/* | |
* ACTION BOX CLICK TO ACTIVATE | |
* */ | |
$(".action-box").click(function(){ | |
if(!g_theme) | |
$(this).css("box-shadow", "0px 0px 35px rgba(100,100,230,0.6)"); | |
else if(g_theme == 'dark') | |
$(this).css("box-shadow", "0px 0px 35px rgba(182,100,100,0.6)"); | |
_s = true; | |
}); | |
/* | |
* CHECK FOR 'ESCAPE' KEY TO DESELECT ACTION BOX | |
* */ | |
$(document).keyup(function(e){ | |
if(e.keyCode == 27){ | |
$(".action-box").css("box-shadow", "none"); | |
_s = false; | |
} ; | |
}); | |
$(document).on("keydown", function(key){ | |
//this line is just for key mapping | |
$(".text-roller").text(key.type + ":" +key.keyCode); | |
if(key.keyCode == 115){ | |
sysRestore(); | |
} | |
if(key.keyCode == 8) | |
$("#text-pane").text(" "); | |
//CHECKS IF 'ENTER' WAS HIT | |
if(key.keyCode == 13){ | |
_log = $("#text-pane").text(); | |
alert(_log); | |
command(_log); | |
if($("#text-pane").text() != null) { | |
$(".test-box").text( | |
$(".test-box").text() + " - " + $("#text-pane").text() | |
); | |
$("#text-pane").text(" "); | |
} | |
animateMe(".bit-roller"), 2000 + (Math.random() * 2000); | |
}; | |
if(_s) { | |
$("#text-pane").text( | |
$("#text-pane").text() + String.fromCharCode(key.keyCode) | |
); | |
} | |
}); | |
/* | |
* BIT-ROLLER JUMP AROUND ACTION BOX | |
* */ | |
var animateMe = function(targetElement, speed){ | |
var _y; | |
var f_w_rand = Math.floor(Math.random()*($(".action-box").width() - 250) + 10); | |
var f_h_rand = Math.floor(Math.random()*($(".action-box").height() - 150)); | |
var _flip = true; | |
if(!_flip) | |
f_h_rand * (-1); | |
$(targetElement).animate( | |
{'left': f_w_rand, 'margin-top': f_h_rand, 'opacity' : Math.random() - 0.4}, | |
{ | |
duration: speed + Math.random() * 500, | |
complete: function(){ | |
_y = $(targetElement).css("top"); | |
if(_y > $(".action-box").height() - 150) | |
_flip = !_flip; | |
animateMe(this, (Math.random() * 5000) + 1500); | |
} | |
} | |
); | |
}; | |
animateMe(".bit-roller", 2000 + Math.random() * 2000); | |
/* | |
* CHECK COMMANDS TYPED IN TEXT PANE | |
* */ | |
var command = function(c){ | |
if(c === "DARTH VADER") | |
change_theme('dark'); | |
if(c === "DEFAULT") | |
alert('def'); | |
if(c === "HI") | |
alert('hi'); | |
var str = c.split(" "); | |
if(str[0] === "ADD"){ | |
$(".action-box").append("<div class='bit-roller'>" + str[1] +"</div>"); | |
} | |
/* | |
CALL FUNCTION AS ARRAY VALUE @todo | |
var c_list = { | |
"DARTH VADER" : change_theme('dark') | |
} | |
for(var i in c_list){ | |
if(c === i) | |
}*/ | |
} | |
var sysRestore = function(){ | |
alert('sys_restore'); | |
change_theme("asd"); | |
} | |
var change_theme = function(c){ | |
if(c === 'dark'){ | |
$("html").css({'background-color' : 'black', 'color' : 'white'}); | |
$(".action-box").css({ | |
"box-shadow" : "0px 0px 16px rgb(200,125,125)", | |
"background-color" : "rgb(10,10,11)" | |
}); | |
g_theme = 'dark'; | |
}else{ | |
g_theme = 0; | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment