wok diff sokojs/stuff/multiset.sh @ rev 24131
lxsession, lxsession-lxpolkit, lxappearance: misc fixes (thanks Saipul)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Oct 23 10:55:42 2021 +0000 (2021-10-23) |
parents | 787a1807d2bb |
children | 9c4b74f41985 |
line diff
1.1 --- a/sokojs/stuff/multiset.sh Mon Oct 18 14:47:15 2021 +0000 1.2 +++ b/sokojs/stuff/multiset.sh Sat Oct 23 10:55:42 2021 +0000 1.3 @@ -3,18 +3,20 @@ 1.4 [ -s level.htm ] && rm level.htm && patch -p0 <<EOT 1.5 --- main.htm 1.6 +++ main.htm 1.7 -@@ -11,8 +11,9 @@ Voir : http://www.gnu.org/licenses/gpl.h 1.8 - --> 1.9 - <html> 1.10 - <head> 1.11 -+<META HTTP-EQUIV="Content Type" CONTENT="text/html;charset=utf-8"> 1.12 - <meta name="viewport" content="width=device-width, initial-scale=1"> 1.13 --<style> 1.14 -+<style type="text/css"> 1.15 - <!-- 1.16 +@@ -19,7 +19,11 @@ 1.17 + width:30px; 1.18 + height:30px; 1.19 + } 1.20 +- 1.21 ++a{ 1.22 ++color:red; 1.23 ++text-decoration:none; 1.24 ++display:block; 1.25 ++} 1.26 + @media screen and (max-width: 450px) { 1.27 img.r{ 1.28 - width:30px; 1.29 -@@ -76,19 +77,19 @@ if (parent.frames[0] == null) { document 1.30 + width:29px; 1.31 +@@ -77,8 +81,11 @@ 1.32 var ie4= (navigator.appName == "Microsoft Internet Explorer")?1:0; 1.33 var ns4= (navigator.appName=="Netscape")?1:0; 1.34 1.35 @@ -22,93 +24,115 @@ 1.36 -Col = 16 1.37 +Row = eval(parent.frames[0].document.forms[1].elements[0].value) 1.38 +Col = eval(parent.frames[0].document.forms[1].elements[1].value) 1.39 ++CurSet = parent.frames[0].document.forms[1].elements[2].value 1.40 ++maxLevel = eval(parent.frames[0].document.forms[1].elements[3].value) 1.41 ++nbLevel = eval(parent.frames[0].document.forms[0].elements[(Row*Col)+1].value) 1.42 1.43 function Nmajevent(evenement) 1.44 { 1.45 - if (evenement.which == 52 || evenement.which == 37) { 1.46 - Move(eval(manpos) - 1) 1.47 - } else if (evenement.which == 56 || evenement.which == 38) { 1.48 -- Move(eval(manpos) - Row) 1.49 -+ Move(eval(manpos) - Col) 1.50 - } else if (evenement.which == 54 || evenement.which == 39) { 1.51 - Move(eval(manpos) + 1) 1.52 - } else if (evenement.which == 50 || evenement.which == 40) { 1.53 -- Move(eval(manpos) + Row) 1.54 -+ Move(eval(manpos) + Col) 1.55 - } 1.56 - } 1.57 +@@ -124,6 +131,10 @@ 1.58 1.59 -@@ -108,7 +109,7 @@ function Imajevent(){ 1.60 - if (window.event.keyCode == 37) { 1.61 - Move(eval(manpos) - 1) 1.62 - } else if (window.event.keyCode == 38) { 1.63 -- Move(eval(manpos) - Row) 1.64 -+ Move(eval(manpos) - Col) 1.65 - } else if (window.event.keyCode == 39) { 1.66 - Move(eval(manpos) + 1) 1.67 - } else if (window.event.keyCode == 40) { 1.68 -@@ -150,7 +151,7 @@ manU = new Image(30, 30); manU.src = "8 1.69 + <script type="text/javascript"> 1.70 + <!-- 1.71 ++if (parent.window.location.search.length > 1 && parent.frames[0].location.hash.length == 0 && 1.72 ++ parent.frames[0].location.href.indexOf(parent.window.location.search.substring(1)) < 0) 1.73 ++ parent.frames[0].location = parent.window.location.search.substring(1) 1.74 ++ 1.75 + if (document.all) { 1.76 + top.window.resizeTo(800, 600); 1.77 + } else if (document.layers || document.getElementById) { 1.78 +@@ -151,13 +162,26 @@ 1.79 manD = new Image(30, 30); manD.src = "9.gif"; // down 1.80 1.81 level = new Array() 1.82 -maxLevel = 97 1.83 -+maxLevel = eval(parent.frames[0].document.forms[1].elements[3].value) 1.84 moves = 0 1.85 + saved = "" 1.86 1.87 ++function urlself() 1.88 ++{ 1.89 ++ var l = parent.window.location 1.90 ++ return l.href.substring(0, l.href.length - l.search.length - l.hash.length)+ 1.91 ++ "?"+CurSet+"/level"+nbLevel+".htm#"+saved 1.92 ++} 1.93 ++ 1.94 ++function seturl() 1.95 ++{ 1.96 ++ var e = document.getElementById("urlsave") 1.97 ++ e.setAttribute("href", urlself()); 1.98 ++} 1.99 ++ 1.100 function ReloadLevel() { 1.101 -@@ -168,14 +169,18 @@ function ReloadLevel() { 1.102 + manpos = parent.frames[0].document.forms[0].elements[Row*Col].value 1.103 + moves = 0 1.104 ++ saved = "" 1.105 + window.status = "" 1.106 + nbBoxin = 0 1.107 + for (i = 0 ; i < Row * Col; i++) { 1.108 +@@ -168,9 +192,18 @@ 1.109 + document.images[manpos].src = eval("manD.src") 1.110 + } 1.111 1.112 ++function Go(d,n) { 1.113 ++ parent.frames[0].document.location = d + "/level" + n + ".htm#" + d 1.114 ++ seturl() 1.115 ++} 1.116 ++ 1.117 function GoLevel(n) { 1.118 if (n == nbLevel) ReloadLevel() 1.119 - parent.frames[0].document.location = "level" + n + ".htm" 1.120 -+ parent.frames[0].document.location = parent.frames[0].document.forms[1].elements[2].value + "/level" + n + ".htm" 1.121 ++ Go(CurSet, n) 1.122 +} 1.123 + 1.124 +function GoSet() { 1.125 -+ parent.frames[0].document.location = document.getElementById('set').value + "/level0.htm" 1.126 ++ Go(document.getElementById('set').value, 0) 1.127 } 1.128 1.129 function dir(d) { 1.130 - if (d == -1) return "L"; 1.131 - if (d == 1) return "R"; 1.132 -- if (d == Row) return "D"; 1.133 -- if (d == -Row) return "U"; 1.134 -+ if (d == Col) return "D"; 1.135 -+ if (d == -Col) return "U"; 1.136 +@@ -214,6 +247,7 @@ 1.137 + m = eval("man"+c.toUpperCase()+".src") 1.138 + } while (c == c.toLowerCase()) 1.139 + document.images[manpos].src = m 1.140 ++ seturl() 1.141 + } 1.142 } 1.143 1.144 - function print_moves(m) { 1.145 -@@ -226,7 +231,7 @@ function Move(a) { 1.146 +@@ -224,9 +258,9 @@ 1.147 + var m = dir(d).toLowerCase() 1.148 + if (level[a] == boxin || level[a] == boxout) { 1.149 + b = a + d 1.150 +- ++moves 1.151 + m = dir(d) 1.152 + if (level[b] == floor || level[b] == dest) { 1.153 ++ ++moves 1.154 + level[a] == boxin ? (level[a] = dest, nbBoxin++) : level[a] = floor 1.155 + level[b] == dest ? (level[b] = boxin, nbBoxin--) : level[b] = boxout 1.156 + document.images[b].src = eval("img" + level[b] + ".src") 1.157 +@@ -243,7 +277,7 @@ 1.158 if (nbBoxin == 0) { 1.159 if (nbLevel < maxLevel) { 1.160 alert("You have done a good job !") 1.161 - parent.frames[0].location = "level" + (++nbLevel) + ".htm" 1.162 -+ parent.frames[0].document.location = parent.frames[0].document.forms[1].elements[2].value + "/level" + (++nbLevel) + ".htm" 1.163 ++ parent.frames[0].document.location = CurSet + "/level" + (++nbLevel) + ".htm" 1.164 GoLevel(nbLevel) 1.165 } else { 1.166 alert("Congratulations !") 1.167 -@@ -246,14 +251,14 @@ function Move(a) { 1.168 - for (y = 0 ; y < Row; y++) { 1.169 - document.write ("<TR>") 1.170 - for (x = 0; x < Col; x++) { 1.171 -- level[x + Row * y] = parent.frames[0].document.forms[0].elements[x + Row * y].value 1.172 -- if (level[x + Row * y] == dest) nbBoxin++ 1.173 -- if (level[x + Row * y] == land || level[x + Row * y] == wall) 1.174 -+ level[x + Col * y] = parent.frames[0].document.forms[0].elements[x + Col * y].value 1.175 -+ if (level[x + Col * y] == dest) nbBoxin++ 1.176 -+ if (level[x + Col * y] == land || level[x + Col * y] == wall) 1.177 - document.write("<TD VALIGN=TOP>", 1.178 -- "<IMG align=middle class=r border=0 src=\"", level[x + Row * y], ".gif\"<\/TD>") 1.179 -+ "<IMG align=middle class=r border=0 src=\"", level[x + Col * y], ".gif\"<\/TD>") 1.180 - else 1.181 -- document.write("<TD VALIGN=TOP><A HREF=\"JavaScript:Move(", x + Row * y, ")\">", 1.182 -- "<IMG align=middle class=r border=0 src=\"", level[x + Row * y], ".gif\"</A><\/TD>") 1.183 -+ document.write("<TD VALIGN=TOP><A HREF=\"JavaScript:Move(", x + Col * y, ")\">", 1.184 -+ "<IMG align=middle class=r border=0 src=\"", level[x + Col * y], ".gif\"</A><\/TD>") 1.185 +@@ -251,6 +285,7 @@ 1.186 + } 1.187 } 1.188 - document.write("<\/TR>") 1.189 } 1.190 -@@ -266,8 +271,16 @@ function Move(a) { 1.191 ++ seturl() 1.192 + } 1.193 + window.focus() 1.194 + window.status = "" 1.195 +@@ -277,21 +312,32 @@ 1.196 + } 1.197 + document.write("<\/TABLE>") 1.198 + manpos = parent.frames[0].document.forms[0].elements[Row*Col].value 1.199 +- nbLevel = parent.frames[0].document.forms[0].elements[(Row*Col)+1].value 1.200 + 1.201 + document.write("</table><TABLE cellspacing=0 cellpadding=0 style='max-width:300px'><TD>") 1.202 + 1.203 document.write("<FORM>", 1.204 "<INPUT TYPE=button onClick=\"Javascript:ReloadLevel();\" value=\"Restart\">", 1.205 "<INPUT TYPE=button onClick=\"Javascript:UndoMove();\" value=\"Undo\"><p id=\"moves\" style=\"color:white\">0 moves</p></center>") 1.206 @@ -118,14 +142,26 @@ 1.207 + document.write("<option>sokojs</option>"); 1.208 + document.write("</select><br />") 1.209 + document.write("<body style=\"margin:0\" bgcolor=\"black\"> <b><FONT FACE=\"Comic Sans MS\" SIZE=4 COLOR=\"red\">", 1.210 -+ parent.frames[0].document.forms[1].elements[2].value," LEVEL ", 1.211 -+ eval(parent.frames[0].document.forms[0].elements[(Row*Col)+1].value) + 1,"<br/>") 1.212 ++ "<a id=\"urlsave\" href=\"",urlself(),"\">",CurSet," LEVEL ",nbLevel + 1,"</a><br/>") 1.213 for (i = 0; i <= maxLevel; i++) { 1.214 - 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?" ":"")+(i+1), "\">") 1.215 + document.write("<INPUT "+style+" TYPE=\"button\" onClick=\"Javascript:GoLevel(", i, ");\" value=\"", (i<9?" ":"")+(i+1), "\">") 1.216 } 1.217 document.write("<\/FORM></table>") 1.218 1.219 + document.images[manpos].src = eval("manD.src") 1.220 ++ 1.221 ++ if (parent.window.location.hash.length > 1 && parent.frames[0].location.hash.length == 0) { 1.222 ++ for (i = 2; i <= parent.window.location.hash.length; i++) 1.223 ++ Move(manpos-undoDir(parent.window.location.hash.substring(i-1,i))) 1.224 ++ } 1.225 + //--> 1.226 + </script> 1.227 + 1.228 + </body> 1.229 +-</html> 1.230 +\ No newline at end of file 1.231 ++</html> 1.232 --- sokojs.htm 1.233 +++ sokojs.htm 1.234 @@ -22,14 +22,13 @@ Foundation, Inc., 59 Temple Place - Suit 1.235 @@ -161,4 +197,10 @@ 1.236 "<INPUT TYPE=\\"button\\" value=\\"97\\"><\\/FORM>")' > sokojs/$l 1.237 rm -f $l 1.238 done 1.239 - 1.240 +[ -s sokojs/description.txt ] || cat > sokojs/description.txt <<EOT 1.241 +SokoJS 1.242 +Sokoban Game for Javascript 1.243 +michel.buze@gmail.com 1.244 +http://buze.michel.chez.com 1.245 +copyright Michel BUZE 1.246 +EOT