Skip to content

Instantly share code, notes, and snippets.

@wraithan
Last active December 15, 2015 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wraithan/5265087 to your computer and use it in GitHub Desktop.
Save wraithan/5265087 to your computer and use it in GitHub Desktop.
Works, needs dotjs. Could use polish.
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