Add select field to select game files

master
Guillaume Dott 2014-12-15 12:44:53 +01:00
parent 6a8b0425fa
commit 6b887c7029
1 changed files with 17 additions and 0 deletions

View File

@ -23,6 +23,14 @@ class Nikoli.Game
buttons_div.appendChild button
files_select = document.createElement 'select'
files_select.classList.add 'files'
files_select.addEventListener('change', (evt) =>
@file = evt.target.value
@newgame())
buttons_div.appendChild files_select
@board.appendChild buttons_div
@board.querySelector('.check').addEventListener('click', @check.bind(this))
@ -92,6 +100,15 @@ class Nikoli.Game
@files = files
@file = @files[0]
select = @board.querySelector('select')
select.innerHTML = ''
@files.forEach((file) ->
option = document.createElement('option')
option.text = file
select.appendChild option
)
@newgame() unless @game?
newgame: ->