2022-07-28 17:39:51 +02:00
|
|
|
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) {
|
2022-07-31 16:34:49 +02:00
|
|
|
Grid.clear();
|
|
|
|
Mode.setEnabled(false, ['play', 'solve']);
|
2022-07-28 17:39:51 +02:00
|
|
|
return File.load(input.files[0]);
|
|
|
|
},
|
|
|
|
function(data) {
|
2022-08-10 21:12:39 +02:00
|
|
|
Grid.Color.setColors(JSON.parse(data));
|
2022-08-06 20:18:30 +02:00
|
|
|
return Async.wrap();
|
2022-07-28 17:39:51 +02:00
|
|
|
}
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function save() {
|
2022-08-06 20:15:53 +02:00
|
|
|
File.save('data:text/json,' + JSON.stringify(Grid.get().colors), "grid.json");
|
2022-07-28 17:39:51 +02:00
|
|
|
}
|