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
var Robot = function (robot) {}; | |
Robot.prototype.onIdle = function (ev) { | |
var robot = ev.robot; | |
//search | |
robot.ahead(4); | |
robot.rotateCannon(6); | |
robot.turn(1); | |
}; |
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
//FightCode can only understand your robot | |
//if its class is called Robot | |
var Robot = function(robot) { | |
var rx = robot.position.x; | |
var ry = robot.position.y; | |
var aH = robot.arenaHeight; | |
var aW = robot.arenaWidth; | |
robot.clone() | |
}; |
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
//FightCode can only understand your robot | |
//if its class is called Robot | |
var Robot = function(robot) { | |
}; | |
Robot.prototype.onIdle = function(ev) { | |
var robot = ev.robot; | |
robot.clone(); |
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
var matched, browser; | |
// Use of jQuery.browser is frowned upon. | |
// More details: http://api.jquery.com/jQuery.browser | |
// jQuery.uaMatch maintained for back-compat | |
jQuery.uaMatch = function( ua ) { | |
ua = ua.toLowerCase(); | |
var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) || | |
/(webkit)[ \/]([\w.]+)/.exec( ua ) || |
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
//http://tryhandlebarsjs.com/ | |
//{{#list_fl people}}{{firstName}} {{lastName}}{{/list_fl}} | |
{ | |
people : [ | |
{ firstName: "Yehuda", lastName: "Katz" }, | |
{ firstName: "Carl", lastName: "Lerche" }, | |
{ firstName: "Alan", lastName: "Johnson" } | |
] |
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
//http://stackoverflow.com/questions/7388001/javascript-regex-to-validate-date | |
//http://jsfiddle.net/mplungjan/Mqh8D/ | |
var isDate = function (str) { | |
var parms = str.split(/[\.\-\/]/); | |
var yyyy = parseInt(parms[2],10); | |
var mm = parseInt(parms[1],10); | |
var dd = parseInt(parms[0],10); | |
var date = new Date(yyyy,mm-1,dd,0,0,0,0); | |
return mm === (date.getMonth()+1) && dd === date.getDate() && yyyy === date.getFullYear(); | |
} |
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
$(function() { | |
if (jQuery.browser.msie) | |
$('img[src$=".png"]').each(function() { // must have quotes around .png | |
this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+this.src+",sizingMethod='scale')"; | |
}); | |
}); |
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
// http://stackoverflow.com/questions/7193425/how-do-you-animate-fb-canvas-scrollto | |
function scrollTo(y){ | |
FB.Canvas.getPageInfo(function(pageInfo){ | |
$({y: pageInfo.scrollTop}).animate( | |
{y: y}, | |
{duration: 1000, step: function(offset){ | |
FB.Canvas.scrollTo(0, offset); | |
} | |
}); |
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
var getURLParameter = function (name) { | |
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[undefined,""])[1].replace(/\+/g, '%20'))||null; | |
}; |
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
// http://stackoverflow.com/questions/118241/calculate-text-width-with-javascript | |
function stringWidth(s, className) { | |
var c = className || "", | |
o = $('<div class="' + c + '">' + s + '</div>') | |
.css({'position': 'absolute', 'float': 'left', 'white-space': 'nowrap', 'visibility': 'hidden'}) | |
.appendTo($('body')), | |
w = o.width(); | |
o.remove(); |
OlderNewer