import * as Decoder from Share.Decoder; import * as Encoder from Share.Encoder; import {generate, iter, square} from Grid.Util; import GUI; import Grid; var share = document.getElementById('share') return { get: get, naiveDecode: naiveDecode, link: link } function get() { return share; } function naiveEncode(grid) { var encoder = Encoder.make(); iter(grid, function(row, column) { encoder.int(3)(grid[row][column]); }); return encoder.output(); } function naiveDecode(size, input) { if(input != undefined) { var decoder = Decoder.make(input); return generate(size, size, function() {return decoder.int(3);}); } } function link(grid) { share.href = '?game=' + naiveEncode(Grid.get().colors); GUI.activate(true, share); }