diff --git a/js/Makefile b/js/Makefile index 186c4f2..1ef7d05 100644 --- a/js/Makefile +++ b/js/Makefile @@ -1,8 +1,18 @@ -MAPS=$(wildcard ../maps/contest*.map ../maps/flood*.map) +MAPS=$(wildcard ../maps/flood*.map) +MAPS+=$(wildcard ../maps/contest?.map ../maps/contest10.map) +MAPS+=$(wildcard ../maps/ems*.map) +MAPS+=../maps/pacman.map ../maps/pacman2.map all: maps.js - maps.js: mapsToJson.js $(MAPS) ./mapsToJson.js $(MAPS) > maps.js + +clean: + rm -f maps.js + +.PHONY: all clean + +# just build it everytime +.PHONY: maps.js diff --git a/js/gui.js b/js/gui.js index abee99a..fe59612 100644 --- a/js/gui.js +++ b/js/gui.js @@ -44,68 +44,64 @@ function mineGui_start() { for (i = 0; i < txt.length; ++i) { if (validMoves[txt[i]]) mineGui_moves += txt[i]; } - inpMoves.blur(); mineGui_updateMine(); }; - var delayInpValidate = function() { window.setTimeout(inpValidate, 0); }; + var delayInpValidate = function(event) { +// console.log("input", event, event.type); + window.setTimeout(inpValidate, 0); + }; inpMoves.onchange = delayInpValidate; inpMoves.onpaste = delayInpValidate; inpMoves.onkeypress = delayInpValidate; - document.onkeypress = function (event) { + document.body.onkeydown = function (event) { +// console.log("body", event, event.type); if (document.activeElement === customMapInput) return; if (event.ctrlKey || event.altKey || event.metaKey) return; var handled = true; - if (event.keyCode == 8 || event.charCode == 8) { + var cmd = String.fromCharCode(event.charCode || event.keyCode).toUpperCase(); + if (validMoves[cmd]) { + mineGui_move(cmd); + } else if (cmd == 'C') { // clear + mineGui_moves = ""; + mineGui_updateMine(); + } else if (event.keyCode == 8 || event.charCode == 8) { // backspace -> undo mineGui_moves = mineGui_moves.slice(0,-1); mineGui_updateMine(); - } else if (event.which === 0 && event.keyCode) { - switch (event.keyCode) { - case 33: // page up - if (selMap.selectedIndex > 0) { - selMap.selectedIndex--; - selMap.onchange(); - } - break; - case 34: // page down - if (selMap.selectedIndex+1 < selMap.options.length) { - selMap.selectedIndex++; - selMap.onchange(); - } - break; - case 37: // left - mineGui_move('L'); - break; - case 38: // up - mineGui_move('U'); - break; - case 39: // right - mineGui_move('R'); - break; - case 40: // down - mineGui_move('D'); - break; - default: - handled = false; - break; + } else switch (event.keyCode) { + case 33: // page up + if (selMap.selectedIndex > 0) { + selMap.selectedIndex--; + selMap.onchange(); } - } else if (event.charCode) { - console.log(event.charCode); - cmd = String.fromCharCode(event.charCode).toUpperCase(); - if (validMoves[cmd]) { - mineGui_move(cmd); - } else if (cmd == 'R') { // redraw - mineGui_updateMine(); - } else if (cmd == 'C') { // clear - mineGui_moves = ""; - mineGui_updateMine(); - } else { - handled = false; + break; + case 34: // page down + if (selMap.selectedIndex+1 < selMap.options.length) { + selMap.selectedIndex++; + selMap.onchange(); } - } else { + break; + case 37: // left + mineGui_move('L'); + break; + case 38: // up + mineGui_move('U'); + break; + case 39: // right + mineGui_move('R'); + break; + case 40: // down + mineGui_move('D'); + break; + default: handled = false; + break; + } + if (handled) { +// console.log("body handled", event, event.type); + event.preventDefault(); + return true; } - if (handled) event.preventDefault(); }; for (k in mineMaps) { if (mineMaps.hasOwnProperty(k)) { diff --git a/js/index.html b/js/index.html index 4b7005c..7863d54 100644 --- a/js/index.html +++ b/js/index.html @@ -33,8 +33,9 @@
Help:
 (L)eft/(U)p/(R)ight/(D)own work as expected (letter and arrow keys), (A)bort and (W)ait too.
-Special keys: PageUp/PageDown for map select, Backspace for undo, (C)lear and (R)edraw
+Special keys: PageUp/PageDown for map select, Backspace for undo and (C)lear
 Be careful: a reload looses all custom maps and saved moves.
+Listed highscore can be outdated.
 	
Build custom map:
diff --git a/js/maps.js b/js/maps.js index 043f288..26e4bf0 100644 --- a/js/maps.js +++ b/js/maps.js @@ -1,2 +1,2 @@ -var mineMaps = {"contest10":"#############################\n#..........................\\#\n#..\\\\###...#.... ###.#\n#..\\*\\\\\\.. #.... ..##\\\\..\\#.#\n#..\\*\\.... #.... ..#\\#....#.#\n#...\\###.. #.... ....#....#.#\n#... ..... ..... .####......#\n#\\\\. #.... .......#\n#... #..#. .....*\\ ##.......#\n#.#....... ...#.. ....######\n#. ...#... ...#.\\ ....#..* #\n##........ ...#.. #....#.#\\\\#\n#.....*... .....*\\#\\\\.....*.#\n#.***.* .......*\\****.....#.#\n#.\\\\\\.. ................ .#\n#.##### .###### ##### #\n#....\\\\.................... #\n#....****...#.##.....\\\\\\\\..\\#\n#....\\\\\\\\...#.........*....\\#\n#....\\\\\\\\...#.\\\\. #\\###.\\#\n#.... ..#.... ...#\\\\\\\\. #\n#........ ..#.... ...#..... #\n#........ ........#R#\n###########################L#\n","contest1":"######\n#. *R#\n# \\.#\n#\\ * #\nL .\\#\n######\n","contest2":"#######\n#..***#\n#..\\\\\\#\n#...**#\n#.*.*\\#\nLR....#\n#######\n","contest3":"########\n#..R...#\n#..*...#\n#..#...#\n#.\\.\\..L\n####**.#\n#\\.....#\n#\\..* .#\n########\n","contest4":"#########\n#.*..#\\.#\n#.\\..#\\.L\n#.R .##.#\n#.\\ ...#\n#..\\ ..#\n#...\\ ##\n#....\\ \\#\n#########\n","contest5":"############\n#..........#\n#.....*....#\n#..\\\\\\\\\\\\..#\n#. ....#\n#..\\\\\\\\\\\\\\.#\n#..\\.. .#\n#..\\.. ....#\n#..... ..* #\n#..### ### #\n#...R#\\#\\\\.#\n######L#####\n","contest6":"###############\n#\\\\\\.......** #\n#\\\\#.#####...##\n#\\\\#.....*##. #\n#\\#####\\...## #\n#\\......####* #\n#\\.######* #.\\#\n#\\.#. *...##.##\n#\\##. .. *...#\n#\\...... L#.#.#\n###########.#.#\n#\\..........#.#\n##.##########.#\n#R.#\\.........#\n###############\n","contest7":" #######\n ## *#\n ##R *##\n ##\\\\\\\\##\n ##....##\n ##..\\ . ##\n ## . L . ##\n ##\\\\\\# #\\\\\\\\##\n ###### #######\n","contest8":"##############\n#\\\\... ......#\n###.#. ...*..#\n #.#. ... ..#\n### #. \\ ..#\n#. .#..... **#######\n#.#\\#..... ..\\\\\\*. #\n#*\\\\#.###. ####\\\\\\ #\n#\\\\.#. ...## \\ #\n#\\#.#..... ....# \\ # \n###.#..... ....# ##\n#\\\\.#..... ....#\\ # \n########.. ..###*####\n#......... .........#\n#......... ....***..#\n#..\\\\\\\\\\ # ####.....#\n#........*R..\\\\\\ .#\n##########L##########\n","contest9":" #L#######\n #*** \\\\ #\n #\\\\\\ .. #\n#########.## ##########\n#.......\\ ..........* .#\n#*******\\......#....#\\\\ .#\n###\\.\\\\\\...**..#....... *#\n#*****\\\\ .\\\\..## #\\.#\n######### .... ##########\n # #\n ####*#### \n #.......#\n######### \\\\\\\\*##########\n#*\\\\ **# *..*\\ \\\\\\\\\\#\n#.\\**\\*** .....**.# \\\\##\\#\n#\\R...... .\\\\.. \\\\\\\\\\#\n##########################\n","flood1":"###########\n#....R....#\n#.*******.#\n#.\\\\\\\\\\\\\\.#\n#. .#\n#..*\\\\\\*..#\n#.#*\\\\\\*#.#\n#########L#\n\nWater 1\nFlooding 8 \nWaterproof 5\n","flood2":"#######\n#..***#\n#..\\\\\\#\n#...**#\n#.*.*\\#\nLR....#\n#######\n\nFlooding 5\nWaterproof 3\n","flood3":"############\n#..........#\n#.....*....#\n#..\\\\\\\\\\\\..#\n#. ....#\n#..\\\\\\\\\\\\\\.#\n#..\\.. .#\n#..\\.. ....#\n#..... ..* #\n#..### ### #\n#...R#\\#\\\\.#\n######L#####\n\nWaterproof 10 \nFlooding 10\nWater 2\n","flood4":"########################\n#.....................\\#\n#......*\\ ...........#\n#......*... ......* ...#\n#.. \\\\... .*..... ...#\n#.. ....... ....... ...#\n#.. ....... .\\\\.... ...# ######\n#. .... .....\\...# #\\\\\\\\#\n#\\\\\\......... .........# #....#\n########### R ########*#####\n #.......... ........***\\\\\\#\n #.......... ............**#\n #.......... ......... *.*\\#\n #....\\\\.... ....\\\\..... ..L\n #.....................****#\n #........\\*...............#\n #........... .........#\n #.........................#\n ###########################\n\nWater 1\nFlooding 20\nWaterproof 10\n","flood5":"#########\n#.*..#\\.#\n#.\\..#\\.L\n#.R .##.#\n#.\\ ...#\n#..\\ ..#\n#...\\ ##\n#....\\ \\#\n#########\n\nWater 2\nFlooding 11\nWaterproof 5\n"}; +var mineMaps = {"flood1":"###########\n#....R....#\n#.*******.#\n#.\\\\\\\\\\\\\\.#\n#. .#\n#..*\\\\\\*..#\n#.#*\\\\\\*#.#\n#########L#\n\nWater 1\nFlooding 8 \nWaterproof 5\nHighscore 945\n","flood2":"#######\n#..***#\n#..\\\\\\#\n#...**#\n#.*.*\\#\nLR....#\n#######\n\nFlooding 5\nWaterproof 3\nHighscore 281\n","flood3":"############\n#..........#\n#.....*....#\n#..\\\\\\\\\\\\..#\n#. ....#\n#..\\\\\\\\\\\\\\.#\n#..\\.. .#\n#..\\.. ....#\n#..... ..* #\n#..### ### #\n#...R#\\#\\\\.#\n######L#####\n\nWaterproof 10 \nFlooding 10\nWater 2\nHighscore 1301","flood4":"########################\n#.....................\\#\n#......*\\ ...........#\n#......*... ......* ...#\n#.. \\\\... .*..... ...#\n#.. ....... ....... ...#\n#.. ....... .\\\\.... ...# ######\n#. .... .....\\...# #\\\\\\\\#\n#\\\\\\......... .........# #....#\n########### R ########*#####\n #.......... ........***\\\\\\#\n #.......... ............**#\n #.......... ......... *.*\\#\n #....\\\\.... ....\\\\..... ..L\n #.....................****#\n #........\\*...............#\n #........... .........#\n #.........................#\n ###########################\n\nWater 1\nFlooding 20\nWaterproof 10\nHighscore 1591\n","flood5":"#########\n#.*..#\\.#\n#.\\..#\\.L\n#.R .##.#\n#.\\ ...#\n#..\\ ..#\n#...\\ ##\n#....\\ \\#\n#########\n\nWater 2\nFlooding 11\nWaterproof 5\nHighscore 575\n","contest1":"######\n#. *R#\n# \\.#\n#\\ * #\nL .\\#\n######\n\nHighscore 212\n","contest2":"#######\n#..***#\n#..\\\\\\#\n#...**#\n#.*.*\\#\nLR....#\n#######\n\nHighscore 281\n","contest3":"########\n#..R...#\n#..*...#\n#..#...#\n#.\\.\\..L\n####**.#\n#\\.....#\n#\\..* .#\n########\n\nHighscore 275\n","contest4":"#########\n#.*..#\\.#\n#.\\..#\\.L\n#.R .##.#\n#.\\ ...#\n#..\\ ..#\n#...\\ ##\n#....\\ \\#\n#########\n\nHighscore 575\n","contest5":"############\n#..........#\n#.....*....#\n#..\\\\\\\\\\\\..#\n#. ....#\n#..\\\\\\\\\\\\\\.#\n#..\\.. .#\n#..\\.. ....#\n#..... ..* #\n#..### ### #\n#...R#\\#\\\\.#\n######L#####\n\nHighscore 1303\n","contest6":"###############\n#\\\\\\.......** #\n#\\\\#.#####...##\n#\\\\#.....*##. #\n#\\#####\\...## #\n#\\......####* #\n#\\.######* #.\\#\n#\\.#. *...##.##\n#\\##. .. *...#\n#\\...... L#.#.#\n###########.#.#\n#\\..........#.#\n##.##########.#\n#R.#\\.........#\n###############\n\nHighscore 1177\n","contest7":" #######\n ## *#\n ##R *##\n ##\\\\\\\\##\n ##....##\n ##..\\ . ##\n ## . L . ##\n ##\\\\\\# #\\\\\\\\##\n ###### #######\n\nHighscore 869\n","contest8":"##############\n#\\\\... ......#\n###.#. ...*..#\n #.#. ... ..#\n### #. \\ ..#\n#. .#..... **#######\n#.#\\#..... ..\\\\\\*. #\n#*\\\\#.###. ####\\\\\\ #\n#\\\\.#. ...## \\ #\n#\\#.#..... ....# \\ # \n###.#..... ....# ##\n#\\\\.#..... ....#\\ # \n########.. ..###*####\n#......... .........#\n#......... ....***..#\n#..\\\\\\\\\\ # ####.....#\n#........*R..\\\\\\ .#\n##########L##########\n\nHighscore 1973\n","contest9":" #L#######\n #*** \\\\ #\n #\\\\\\ .. #\n#########.## ##########\n#.......\\ ..........* .#\n#*******\\......#....#\\\\ .#\n###\\.\\\\\\...**..#....... *#\n#*****\\\\ .\\\\..## #\\.#\n######### .... ##########\n # #\n ####*#### \n #.......#\n######### \\\\\\\\*##########\n#*\\\\ **# *..*\\ \\\\\\\\\\#\n#.\\**\\*** .....**.# \\\\##\\#\n#\\R...... .\\\\.. \\\\\\\\\\#\n##########################\n\nHighscore 3093\n","contest10":"#############################\n#..........................\\#\n#..\\\\###...#.... ###.#\n#..\\*\\\\\\.. #.... ..##\\\\..\\#.#\n#..\\*\\.... #.... ..#\\#....#.#\n#...\\###.. #.... ....#....#.#\n#... ..... ..... .####......#\n#\\\\. #.... .......#\n#... #..#. .....*\\ ##.......#\n#.#....... ...#.. ....######\n#. ...#... ...#.\\ ....#..* #\n##........ ...#.. #....#.#\\\\#\n#.....*... .....*\\#\\\\.....*.#\n#.***.* .......*\\****.....#.#\n#.\\\\\\.. ................ .#\n#.##### .###### ##### #\n#....\\\\.................... #\n#....****...#.##.....\\\\\\\\..\\#\n#....\\\\\\\\...#.........*....\\#\n#....\\\\\\\\...#.\\\\. #\\###.\\#\n#.... ..#.... ...#\\\\\\\\. #\n#........ ..#.... ...#..... #\n#........ ........#R#\n###########################L#\n\nHighscore 3634\n","ems1":"#######\n#L\\\\\\##\n##* ##\n##* ##\n##* ##\n##* ##\n##* ##\n##* ##\n##* ##\n##* ##\n##* ##\n## ##\n## ##\n##R ##\n## # ##\n#\\ # \\#\n## # ##\n## # ##\n## # ##\n## # ##\n#######\n\nAuthor ems_ (irc)\nHighscore 334\n","ems2":"#########\n###***###\n###***###\n###***###\n###***###\n###***###\n###***###\n# .**\\\\#\n# # #*#\\#\n# # #*#\\#\n# # #*#\\#\n# # #*#\\#\n# # #*#\\#\n# .#\\#\n### **#\n### R \\\\#\n### #L#\n### ###\n### ###\n### ###\n### ###\n### ###\n### ###\n#########\n\nAuthor ems_ (irc)\nHighscore 691\n","ems3a":"################\n#\\.****####\\#*##\n#\\.\\\\\\\\.***...##\n##*####.#*###..#\n#\\.R....#...##\\#\n#\\ ####...#.#*.#\n#\\ **######.#..#\n##...\\\\\\\\\\\\...##\n#L.#\\########.##\n################\n\nAuthor ems_ (irc)\nHighscore 1256\n","ems3":"################\n#\\.****####\\#*##\n#\\.\\\\\\\\.***...##\n##*####.#*###..#\n#\\.R....#...##\\#\n#\\ ####...#.#*.#\n#\\ **######.#..#\n##...\\\\\\\\\\\\...##\n#L.##########.##\n################\n\nAuthor ems_ (irc)\nHighscore 1197\n","ems4":"#########\n#* L#\n#\\ #\n#\\\\ #\n##\\\\ #\n###\\\\ #\n####\\\\ #\n#####\\\\ #\n####### #\n# #*#*# #\n# * * #\n# #*#*# #\n# * * #\n# #*#*# #\n# R* * #\n# #*#*# #\n# * * #\n# #*#*# #\n# * * #\n# #*#*# #\n# * * #\n###*#*#.#\n#\\. . #\\#\n### # ###\n### # ###\n## # ##\n## # ##\n## # ##\n## # ##\n## # ##\n#########\n\nAuthor ems_ (irc)\nHighscore 908\n","ems5":"###################\n#************* ##\n##***********# * ##\n###*********##.*.##\n####*******####*###\n#####*****#####*###\n######***######*###\n#######*#######*###\n###### * ######*###\n#\\ . #*###\n#\\ \\ #*###\n#\\ ** #*###\n#\\ ## #*###\n#\\ #*###\n#\\ \\ \\ #*###\n#\\ ** ** #*###\n#\\ ## ## #*###\n#\\ #*###\n#\\ \\ \\ \\ #*###\n#R ** ** ** #*\\##\n#### ## ## ## #*###\n###L . ##\n#### ## ## ## ## #\n### # ## # # #\n### # ## # # #\n### # ## # # #\n###################\n\nAuthor ems_ (irc)\nHighscore 897\n","pacman":"###########################\n#............#............#\n#.####.#####.#.#####.####.#\n#\\# #.# #.#.# #.# #\\#\n#.####.#####.#.#####.####.#\n#.........................#\n#.####.#.#########.#.####.#\n#......#.....#.....#......#\n######.#####.#.#####.######\n #.# #.#\n######.# #### #### #.######\nL . # # . **\n######.# ######### #.######\n #.# #.#\n######.# ######### #.######\n#............#............#\n#.####.#####.#.#####.####.#\n#\\...#. R .#...\\#\n####.#.#.#########.#.#.####\n#......#.....#.....#......#\n#.##########.#.##########.#\n#.........................#\n###########################\n\nAuthor newsham (www.thenewsh.com/~newsham/x/pacman.map)\nHighscore 191\n","pacman2":"###########################\n#\\\\\\\\\\\\\\\\\\\\\\\\#\\\\\\\\\\\\\\\\\\\\\\\\#\n#\\####\\#####\\#\\#####\\####\\#\n#.# #\\# #\\#\\# #\\# #.#\n#\\####\\#####\\#\\#####\\####\\#\n#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\#\n#\\####\\#\\#########\\#\\####\\#\n#\\\\\\\\\\\\#\\\\\\\\\\#\\\\\\\\\\#\\\\\\\\\\\\#\n######\\#####\\#\\#####\\######\n #\\# #\\#\n######\\# #### #### #\\######\nL \\ # # \\ **\n######\\# ######### #\\######\n #\\# #\\#\n######\\# ######### #\\######\n#\\\\\\\\\\\\\\\\\\\\\\\\#\\\\\\\\\\\\\\\\\\\\\\\\#\n#\\####\\#####\\#\\#####\\####\\#\n#.\\\\\\#\\ R \\#\\\\\\.#\n####\\#\\#\\#########\\#\\#\\####\n#\\\\\\\\\\\\#\\\\\\\\\\#\\\\\\\\\\#\\\\\\\\\\\\#\n#\\##########\\#\\##########\\#\n#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\#\n###########################\n\nHighscore 15039\n"}; if (typeof exports !== "undefined") {exports.maps = mineMaps;}