Last active
December 15, 2015 13:09
-
-
Save wraithan/5265087 to your computer and use it in GitHub Desktop.
Works, needs dotjs. Could use polish.
This file contains hidden or 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 replayURL = 'http://fightcodegame.com/robots/replay/' | |
var ai = 'duck' | |
function load(event) { | |
event.preventDefault() | |
var player = document.getElementById('playerNumber') | |
$.get(replayURL+$('#replayID').val()).done(function (data) { | |
$('#'+ai+'-code').text( | |
$(data).filter('[id*="-code"]').eq( | |
player.options[player.selectedIndex].value | |
).text() | |
) | |
}) | |
} | |
function insertInputs() { | |
if ($('.editor').length) { | |
var form = $('<form>') | |
form.addClass('form') | |
form.append($('<input>').attr({ | |
id: 'replayID', | |
})) | |
form.append($('<select>').attr({ | |
id: 'playerNumber' | |
}).append($('<option>').attr({ | |
value: '0', | |
name: '1' | |
}).text('1')).append($('<option>').attr({ | |
value: '1', | |
name: '2' | |
}).text('2'))) | |
form.append($('<button>').text('Load Bot').click(load)) | |
$('.buttons-bar').append(form) | |
} | |
} | |
insertInputs() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment