wok view sokojs/stuff/multiset.sh @ rev 24127

sokojs: get slc levels
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Oct 16 16:30:13 2021 +0000 (2021-10-16)
parents
children 787a1807d2bb
line source
1 #!/bin/sh
3 grep -q 'text/html' level.htm || patch -p0 <<EOT
4 --- level.htm
5 +++ level.htm
6 @@ -22,12 +22,14 @@
7 <html>
8 <head>
9 <title></title>
10 +<META HTTP-EQUIV="Content Type" CONTENT="text/html;charset=utf-8">
11 <script type="text/javascript">
12 <!--
13 if (parent.frames[0] == null) { document.location = "sokojs.htm" }
14 -Row=16
15 -Col=16
16 -document.write("<body style=\"margin:0\" bgcolor=\"black\">&nbsp;<b><FONT FACE=\"Comic Sans MS\" SIZE=4 COLOR=\"red\">LEVEL ",
17 +Row = eval(parent.frames[0].document.forms[1].elements[0].value)
18 +Col = eval(parent.frames[0].document.forms[1].elements[1].value)
19 +document.write("<body style=\"margin:0\" bgcolor=\"black\">&nbsp;<b><FONT FACE=\"Comic Sans MS\" SIZE=4 COLOR=\"red\">",
20 + parent.frames[0].document.forms[1].elements[2].value," LEVEL ",
21 eval(parent.frames[0].document.forms[0].elements[(Row*Col)+1].value) + 1);
24 --- main.htm
25 +++ main.htm
26 @@ -11,8 +11,9 @@
27 -->
28 <html>
29 <head>
30 +<META HTTP-EQUIV="Content Type" CONTENT="text/html;charset=utf-8">
31 <meta name="viewport" content="width=device-width, initial-scale=1">
32 -<style>
33 +<style type="text/css">
34 <!--
35 img.r{
36 width:30px;
37 @@ -76,19 +77,19 @@
38 var ie4= (navigator.appName == "Microsoft Internet Explorer")?1:0;
39 var ns4= (navigator.appName=="Netscape")?1:0;
41 -Row = 16
42 -Col = 16
43 +Row = eval(parent.frames[0].document.forms[1].elements[0].value)
44 +Col = eval(parent.frames[0].document.forms[1].elements[1].value)
46 function Nmajevent(evenement)
47 {
48 if (evenement.which == 52 || evenement.which == 37) {
49 Move(eval(manpos) - 1)
50 } else if (evenement.which == 56 || evenement.which == 38) {
51 - Move(eval(manpos) - Row)
52 + Move(eval(manpos) - Col)
53 } else if (evenement.which == 54 || evenement.which == 39) {
54 Move(eval(manpos) + 1)
55 } else if (evenement.which == 50 || evenement.which == 40) {
56 - Move(eval(manpos) + Row)
57 + Move(eval(manpos) + Col)
58 }
59 }
61 @@ -108,7 +109,7 @@
62 if (window.event.keyCode == 37) {
63 Move(eval(manpos) - 1)
64 } else if (window.event.keyCode == 38) {
65 - Move(eval(manpos) - Row)
66 + Move(eval(manpos) - Col)
67 } else if (window.event.keyCode == 39) {
68 Move(eval(manpos) + 1)
69 } else if (window.event.keyCode == 40) {
70 @@ -150,7 +151,7 @@
71 manD = new Image(30, 30); manD.src = "9.gif"; // down
73 level = new Array()
74 -maxLevel = 97
75 +maxLevel = eval(parent.frames[0].document.forms[1].elements[3].value)
76 moves = 0
78 function ReloadLevel() {
79 @@ -168,14 +169,18 @@
81 function GoLevel(n) {
82 if (n == nbLevel) ReloadLevel()
83 - parent.frames[0].document.location = "level" + n + ".htm"
84 + parent.frames[0].document.location = parent.frames[0].document.forms[1].elements[2].value + "/level" + n + ".htm"
85 +}
86 +
87 +function GoSet() {
88 + parent.frames[0].document.location = document.getElementById('set').value + "/level0.htm"
89 }
91 function dir(d) {
92 if (d == -1) return "L";
93 if (d == 1) return "R";
94 - if (d == Row) return "D";
95 - if (d == -Row) return "U";
96 + if (d == Col) return "D";
97 + if (d == -Col) return "U";
98 }
100 function print_moves(m) {
101 @@ -226,7 +231,7 @@
102 if (nbBoxin == 0) {
103 if (nbLevel < maxLevel) {
104 alert("You have done a good job !")
105 - parent.frames[0].location = "level" + (++nbLevel) + ".htm"
106 + parent.frames[0].document.location = parent.frames[0].document.forms[1].elements[2].value + "/level" + (++nbLevel) + ".htm"
107 GoLevel(nbLevel)
108 } else {
109 alert("Congratulations !")
110 @@ -246,14 +251,14 @@
111 for (y = 0 ; y < Row; y++) {
112 document.write ("<TR>")
113 for (x = 0; x < Col; x++) {
114 - level[x + Row * y] = parent.frames[0].document.forms[0].elements[x + Row * y].value
115 - if (level[x + Row * y] == dest) nbBoxin++
116 - if (level[x + Row * y] == land || level[x + Row * y] == wall)
117 + level[x + Col * y] = parent.frames[0].document.forms[0].elements[x + Col * y].value
118 + if (level[x + Col * y] == dest) nbBoxin++
119 + if (level[x + Col * y] == land || level[x + Col * y] == wall)
120 document.write("<TD VALIGN=TOP>",
121 - "<IMG align=middle class=r border=0 src=\"", level[x + Row * y], ".gif\"<\/TD>")
122 + "<IMG align=middle class=r border=0 src=\"", level[x + Col * y], ".gif\"<\/TD>")
123 else
124 - document.write("<TD VALIGN=TOP><A HREF=\"JavaScript:Move(", x + Row * y, ")\">",
125 - "<IMG align=middle class=r border=0 src=\"", level[x + Row * y], ".gif\"</A><\/TD>")
126 + document.write("<TD VALIGN=TOP><A HREF=\"JavaScript:Move(", x + Col * y, ")\">",
127 + "<IMG align=middle class=r border=0 src=\"", level[x + Col * y], ".gif\"</A><\/TD>")
128 }
129 document.write("<\/TR>")
130 }
131 @@ -266,8 +271,12 @@
132 document.write("<FORM>",
133 "<INPUT TYPE=button onClick=\"Javascript:ReloadLevel();\" value=\"Restart\">",
134 "<INPUT TYPE=button onClick=\"Javascript:UndoMove();\" value=\"Undo\"><p id=\"moves\" style=\"color:white\">0 moves</p></center>")
135 + style="style='font-family:Courier New;font-size:14px;font-weight:bold;border:1;border-color:0;padding:0;margin:0px;background-color:#c0c0c0;color:#404040..'"
136 + document.write("<select id='set' "+style+" onChange=\"Javascript:GoSet();\">")
137 + document.write("<option>sokojs</option>");
138 + document.write("</select><br />")
139 for (i = 0; i <= maxLevel; i++) {
140 - document.write("<INPUT style='font-family:Courier New;font-size:14px;font-weight:bold;border:1;border-color:0;padding:0;margin:0px;background-color:#c0c0c0;color:#404040รน' TYPE=\"button\" onClick=\"Javascript:GoLevel(", i, ");\" value=\"", (i<9?"&nbsp;":"")+(i+1), "\">")
141 + document.write("<INPUT "+style+" TYPE=\"button\" onClick=\"Javascript:GoLevel(", i, ");\" value=\"", (i<9?"&nbsp;":"")+(i+1), "\">")
142 }
143 document.write("<\/FORM></table>")
145 --- sokojs.htm
146 +++ sokojs.htm
147 @@ -22,13 +22,13 @@
148 <html>
149 <head>
150 <TITLE>Sokoban (C) Michel Buze</TITLE>
151 -<META HTTP-EQUIV="Keywords" CONTENT="boxworld,javascript,sokoban,jeu,jeux,game,buze,web">
152 +<META HTTP-EQUIV="Content Type" CONTENT="text/html;charset=utf-8">
153 <META NAME="Keywords" CONTENT="boxworld,javascript,sokoban,jeu,jeux,game,buze,web">
154 <meta name="viewport" content="width=device-width, initial-scale=1">
155 </head>
157 <frameset border="0" rows="0,700,*">
158 -<frame src="level0.htm">
159 +<frame src="sokojs/level0.htm">
160 <frame src="0.gif">
161 <frame src="0.gif">
162 <noframes>
163 EOT
164 [ -s level0.htm ] && mkdir sokojs && mv level?*.htm sokojs &&
165 sed -i 's|location = "|&../|;/.*main.htm/i document.write("<FORM ACTION=\\"\\">")\
166 document.write("<INPUT TYPE=\\"button\\" value=\\""+Row+"\\">",\
167 "<INPUT TYPE=\\"button\\" value=\\""+Col+"\\">",\
168 "<INPUT TYPE=\\"button\\" value=\\"sokojs\\">",\
169 "<INPUT TYPE=\\"button\\" value=\\"97\\"><\\/FORM>")' sokojs/level*.htm