import * as File from WTK.File; import * as Async from UnitJS.Async; import Grid; import Grid.Color; import Mode; return { init: init } function init() { document.getElementById('load').addEventListener('click', load); document.getElementById('save').addEventListener('click', save); } function load() { Async.run( Async.bind( File.pick({accept: 'text/json,.json'}), function(input) { Grid.clear(); Mode.setEnabled(false, ['play', 'solve']); return File.load(input.files[0]); }, function(data) { Grid.Color.set(JSON.parse(data)); return Async.wrap(); } ) ); } function save() { File.save('data:text/json,' + JSON.stringify(Grid.get().colors), "grid.json"); }