diff --git a/views/application.coffee b/views/application.coffee index 05bfa60..d1108a7 100644 --- a/views/application.coffee +++ b/views/application.coffee @@ -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: ->