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

updated sc-im (-> 0.8.4)
author Hans-G?nter Theisgen
date Thu Aug 22 14:48:42 2024 +0100 (2 months ago)
parents db9d9cb3c164
children
line source
1 #!/bin/sh
3 [ -s level.htm ] && rm level.htm && patch -p0 <<EOT
4 --- main.htm
5 +++ main.htm
6 @@ -19,7 +19,11 @@
7 width:30px;
8 height:30px;
9 }
10 -
11 +a{
12 +color:red;
13 +text-decoration:none;
14 +display:block;
15 +}
16 @media screen and (max-width: 450px) {
17 img.r{
18 width:29px;
19 @@ -77,8 +81,11 @@
20 var ie4= (navigator.appName == "Microsoft Internet Explorer")?1:0;
21 var ns4= (navigator.appName=="Netscape")?1:0;
23 -Row = 16
24 -Col = 16
25 +Row = eval(parent.frames[0].document.forms[1].elements[0].value)
26 +Col = eval(parent.frames[0].document.forms[1].elements[1].value)
27 +CurSet = parent.frames[0].document.forms[1].elements[2].value
28 +maxLevel = eval(parent.frames[0].document.forms[1].elements[3].value)
29 +nbLevel = eval(parent.frames[0].document.forms[0].elements[(Row*Col)+1].value)
31 function Nmajevent(evenement)
32 {
33 @@ -124,6 +131,10 @@
35 <script type="text/javascript">
36 <!--
37 +if (parent.window.location.search.length > 1 && parent.frames[0].location.hash.length == 0 &&
38 + parent.frames[0].location.href.indexOf(parent.window.location.search.substring(1)) < 0)
39 + parent.frames[0].location = parent.window.location.search.substring(1)
40 +
41 if (document.all) {
42 top.window.resizeTo(800, 600);
43 } else if (document.layers || document.getElementById) {
44 @@ -151,13 +162,26 @@
45 manD = new Image(30, 30); manD.src = "9.gif"; // down
47 level = new Array()
48 -maxLevel = 97
49 moves = 0
50 saved = ""
52 +function urlself()
53 +{
54 + var l = parent.window.location.href+"?"
55 + return l.substring(0, l.search(/[#?]/))+
56 + "?"+CurSet+"/level"+nbLevel+".htm#"+saved
57 +}
58 +
59 +function seturl()
60 +{
61 + var e = document.getElementById("urlsave")
62 + e.setAttribute("href", urlself());
63 +}
64 +
65 function ReloadLevel() {
66 manpos = parent.frames[0].document.forms[0].elements[Row*Col].value
67 moves = 0
68 + saved = ""
69 window.status = ""
70 nbBoxin = 0
71 for (i = 0 ; i < Row * Col; i++) {
72 @@ -168,9 +192,18 @@
73 document.images[manpos].src = eval("manD.src")
74 }
76 +function Go(d,n) {
77 + parent.frames[0].document.location = d + "/level" + n + ".htm#" + d
78 + seturl()
79 +}
80 +
81 function GoLevel(n) {
82 if (n == nbLevel) ReloadLevel()
83 - parent.frames[0].document.location = "level" + n + ".htm"
84 + Go(CurSet, n)
85 +}
86 +
87 +function GoSet() {
88 + Go(document.getElementById('set').value, 0)
89 }
91 function dir(d) {
92 @@ -214,6 +247,7 @@
93 m = eval("man"+c.toUpperCase()+".src")
94 } while (c == c.toLowerCase())
95 document.images[manpos].src = m
96 + seturl()
97 }
98 }
100 @@ -224,9 +258,9 @@
101 var m = dir(d).toLowerCase()
102 if (level[a] == boxin || level[a] == boxout) {
103 b = a + d
104 - ++moves
105 m = dir(d)
106 if (level[b] == floor || level[b] == dest) {
107 + ++moves
108 level[a] == boxin ? (level[a] = dest, nbBoxin++) : level[a] = floor
109 level[b] == dest ? (level[b] = boxin, nbBoxin--) : level[b] = boxout
110 document.images[b].src = eval("img" + level[b] + ".src")
111 @@ -243,7 +277,7 @@
112 if (nbBoxin == 0) {
113 if (nbLevel < maxLevel) {
114 alert("You have done a good job !")
115 - parent.frames[0].location = "level" + (++nbLevel) + ".htm"
116 + parent.frames[0].document.location = CurSet + "/level" + (++nbLevel) + ".htm"
117 GoLevel(nbLevel)
118 } else {
119 alert("Congratulations !")
120 @@ -251,6 +285,7 @@
121 }
122 }
123 }
124 + seturl()
125 }
126 window.focus()
127 window.status = ""
128 @@ -277,21 +312,32 @@
129 }
130 document.write("<\/TABLE>")
131 manpos = parent.frames[0].document.forms[0].elements[Row*Col].value
132 - nbLevel = parent.frames[0].document.forms[0].elements[(Row*Col)+1].value
134 document.write("</table><TABLE cellspacing=0 cellpadding=0 style='max-width:300px'><TD>")
136 document.write("<FORM>",
137 "<INPUT TYPE=button onClick=\"Javascript:ReloadLevel();\" value=\"Restart\">",
138 "<INPUT TYPE=button onClick=\"Javascript:UndoMove();\" value=\"Undo\"><p id=\"moves\" style=\"color:white\">0 moves</p></center>")
139 + 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..'"
140 + document.write("<select id='set' "+style+" onChange=\"Javascript:GoSet();\">")
141 + document.write("<option>Change level pack</option>");
142 + document.write("<option>sokojs</option>");
143 + document.write("</select><br />")
144 + document.write("<body style=\"margin:0\" bgcolor=\"black\">&nbsp;<b><FONT FACE=\"Comic Sans MS\" SIZE=4 COLOR=\"red\">",
145 + "<a id=\"urlsave\" href=\"",urlself(),"\">",CurSet," LEVEL ",nbLevel + 1,"</a><br/>")
146 for (i = 0; i <= maxLevel; i++) {
147 - 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), "\">")
148 + document.write("<INPUT "+style+" TYPE=\"button\" onClick=\"Javascript:GoLevel(", i, ");\" value=\"", (i<9?"&nbsp;":"")+(i+1), "\">")
149 }
150 document.write("<\/FORM></table>")
152 document.images[manpos].src = eval("manD.src")
153 +
154 + if (parent.window.location.hash.length > 1 && parent.frames[0].location.hash.length == 0) {
155 + for (i = 2; i <= parent.window.location.hash.length; i++)
156 + Move(manpos-undoDir(parent.window.location.hash.substring(i-1,i)))
157 + }
158 //-->
159 </script>
161 </body>
162 -</html>
163 \ No newline at end of file
164 +</html>
165 --- sokojs.htm
166 +++ sokojs.htm
167 @@ -22,14 +22,13 @@ Foundation, Inc., 59 Temple Place - Suit
168 <html>
169 <head>
170 <TITLE>Sokoban (C) Michel Buze</TITLE>
171 -<META HTTP-EQUIV="Keywords" CONTENT="boxworld,javascript,sokoban,jeu,jeux,game,buze,web">
172 +<META HTTP-EQUIV="Content Type" CONTENT="text/html;charset=utf-8">
173 <META NAME="Keywords" CONTENT="boxworld,javascript,sokoban,jeu,jeux,game,buze,web">
174 <meta name="viewport" content="width=device-width, initial-scale=1">
175 </head>
177 -<frameset border="0" rows="0,700,*">
178 -<frame src="level0.htm">
179 -<frame src="0.gif">
180 +<frameset border="0" rows="0,*">
181 +<frame src="sokojs/level0.htm">
182 <frame src="0.gif">
183 <noframes>
184 <body>
185 EOT
186 [ -s level0.htm ] && mkdir sokojs && for l in level*.htm ; do
187 col=$(sed '/^Col/!d;s|Col=||' $l)
188 pos=$(sed '/write/!d;/value=\\"[0-9]/!d;s|.*value=."||;s|.".*||' $l)
189 awk -vx=$(($pos%$col+2)) -vy=$(($pos/$col+10)) '{ c="@"
190 if (substr($0,x,1) == ".") c="+"
191 if(l++==y) $0=substr($0,1,x-1) c substr($0,x+1)
192 print }' < $l | sed -e "s|1)|&.replace('+','.').replace('@','_')|" \
193 -e '/level.htm/d;s|location = "|&../|;/.*main.htm/i document.write("<FORM ACTION=\\"\\">")\
194 document.write("<INPUT TYPE=\\"button\\" value=\\""+Row+"\\">",\
195 "<INPUT TYPE=\\"button\\" value=\\""+Col+"\\">",\
196 "<INPUT TYPE=\\"button\\" value=\\"sokojs\\">",\
197 "<INPUT TYPE=\\"button\\" value=\\"97\\"><\\/FORM>")' > sokojs/$l
198 rm -f $l
199 done
200 [ -s sokojs/description.txt ] || cat > sokojs/description.txt <<EOT
201 SokoJS
202 Sokoban Game for Javascript
203 michel.buze@gmail.com
204 http://buze.michel.chez.com
205 copyright Michel BUZE
206 EOT