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

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