Quiz Simple Sudoku - Website X5 Helpsite

Logo Schriftzug
Logo WSX5
Scan QR or Download Android App
Direkt zum Seiteninhalt

Quiz Simple Sudoku

Scripte > Additional

Simples Sudoku Quiz

Simple Sudoku - ein Klassiker unter den Spielen.
Ein kleiner Zeitvertreib für das Training der Gehirnzellen. Sieht einfach aus, aber wie schwer fällt einem das logische Denken.
Einfach mal ausprobieren. Die Anpassung an die Homepage erfolgt in der Datei "style.css".
Leider kann die Einbindung in die Webseite nur per iframe <iframe .... ></iframe> erfolgen, was aber keinen Einfluss auf die Funktionstüchtigkeit hat. Es liegt eine große Daten-Datei 'sudoku.csv' bei, die nicht gelöscht werden darf.
ZIP-Datei in ein beliebiges Verzeichnis auf dem PC entpacken und das Verzeichnis "wsX5Obj" auf den Webserver in das Root-Verzeichnis kopieren. Frame-Code einfach nur in den BODY-Bereich <body>.....</body> der aufrufende Datei einfügen, Höhe und Breite anpassen.
Eine demo.php ist beigefügt, die zum Test in das Root-Verzeichnis des Webservers kopiert werden kann.
Aufruf: "http://www.domain.tld/demo.php". Die ausführende Datei muss die Dateiendung .php aufweisen, um den Code ausführen zu können.
Beilegend auch eine Anleitung "Sudoku für Anfänger" im PDF-Format.
Download Button
x runter geladen
Code für den <BODY> Bereich
<iframe src="wsX5Obj/Obj198_0/index.php" height="520" width="100%" name="Sudoku"></iframe>
Code Datei "sudoku.php"
<html>
<head>
<title>Quiz Simple Sudoku</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="sudoku.js"></script>
<link rel="stylesheet" href="sudoku.css">
</head>
<body>
<div align="center">
<div id="sudoku">
<table border="0">
<tr>
<td>
<form name="theClock" method="post">
<input type="text" name="theTime" id="clock" size="8">
</form>
<script>
var clockID = 0;
var init = new Date();
var start = init.getTime();
function UpdateClock() {
  if(clockID) {
 clearTimeout(clockID);
 clockID  = 0;
  }
  var now = new Date ();
  var nowtime = now.getTime();
  var sec = Math.floor((nowtime - start) / 1000);
  var min = Math.floor((sec / 60));
  var std = Math.floor((min / 60));
  sec = sec % 60;
  min = min % 60;
  if (sec < 10) sec = "0" + sec;
  if (min < 10) min = "0" + min;
  if (std < 10) std = "0" + std;
  document.theClock.theTime.value = std + ":" + min + ":" + sec;
  clockID = setTimeout("UpdateClock()", 100);
}
function StartClock() {
clockID = setTimeout("UpdateClock()", 100);
}
StartClock();
</script>
</td>
</tr>
<tr>
<td>
<?php
function getSudoku () {
$ls = 164;
$filename = "sudoku.csv";
$size = filesize ($filename);
$lines = $size / $ls;
$rand = rand(0, $lines);
$handle = fopen ($filename, "r");
$pos = $ls * $rand;
fseek ($handle, $pos, SEEK_SET);
$contents = fread ($handle, $ls);
fclose ($handle);
return $contents;
}
$sudokustr = getSudoku ();
$sudoku    = explode(";", $sudokustr);
echo "<table cellspacing='0' cellpadding='1' border='0' bgcolor='#000000'>";
$count = 0;
for ($x = 0; $x < 9; $x++) {
echo "<tr>";
for ($y = 0; $y < 9; $y++) {
echo "<td><div class='cell'>";
$data = "";
if ($y == 2 || $y == 5) {
$border = "border-right:2px solid #000000;";
} else {
$border = "";
}
if ($x == 2 || $x == 5) {
$border .= "border-bottom:2px solid #000000;";
}
if (intval($sudoku[$count]) > 0 ) {
$data = "value='" . $sudoku[$count] . "' readonly style='background:#DDDDDD; " . $border . "'";
} else {
$data = " style='" . $border . "'";
}
echo "\r\n<input valign='middle' type='text'
id='i" . $count . "' name='i" . $count . "' " . $data . " size='5'
maxlength='5' class='cell' onkeyup='fontsize(this, this.value)'>\r\n";
echo "</div></td>";
$count ++;
}
echo "</tr>";
}
echo "</table>";
?>
</td>
</tr>
<tr>
<td align="center" height="28" valign="bottom">
<form method=post>
<nobr><input type="button" value="L&ouml;sung zeigen" onclick="solveMySudoku()">
<input type="button" value="Pr&uuml;fung" onclick="checkMySudoku()">
<input type="submit" value="Neues Sudoku">
<input type="button" value="Fertig" onclick="checkMySudoku2()"></nobr>
</form>
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
Code Datei "style.css"
div.cell { width: 40px; height: 40px; }
a.sudoku { font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #000000; }
a.sudokumin { font-family: Arial, Helvetica, sans-serif; font-size: 10px; color: #000000; text-decoration: none; }
td.sol {
width: 30px;
height: 30px;
text-align: center;
font-family: Arial, Helvetica, sans-serif;
font-size: 24px;
background: #FFFFFF;
border: 1px solid #000000;
}
input.cell {
width: 40px;
height: 40px;
font-size: 30px;
text-align: center;
padding-top: 1px;
background: #FFFFFF;
border: 0px solid red;
}
h1.sudoku { margin: 0px; padding: 0px; }
input#clock { border:1px solid #000000; background:#DDDDDD; width:378px; font-size:19px; text-align:center; }
div#sudoku { background: #EEF6E9; padding: 10px; border: 1px solid #000000; width: 385px; }

» nach oben «
Logo Host Europe
Button Spenden
🏠 © 2009 - 2024
Hosting by
Zurück zum Seiteninhalt