Quiz Sudoku Cheater - Website X5 Helpsite

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

Quiz Sudoku Cheater

Scripte > Additional

Gedächtnistraining mit Sudoku

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.
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/Obj113_0/index.php" height="600" width="100%" name="Sudoku"></iframe>
Code Datei "index.php"
<?php
require_once 'classes/Sudoku.php';
require_once 'classes/SudokuField.php';
require_once 'classes/Helper.php';
$defaultLanguage = 'de';
$defaultRndFields = 30;
$numRows = 9;
$numCols = 9;
$cellClass = 'cellEven';
$helper = new Helper();
$sudoku = new Sudoku();
$action = preg_replace('/[^a-z]/', '', $_REQUEST['action']);
switch ($_REQUEST['lang']) {
case 'de': $language = 'de'; break;
case 'en': $language = 'en'; break;
case 'fr': $language = 'fr'; break;
default: $language = $defaultLanguage; break;
}
$helper->loadLanguage($language);
if ($action == 'calculate' || $action == 'check') {
for ($row = 0; $row < $numRows; $row++) {
for ($col = 0; $col < $numCols; $col++) {
$value = preg_replace('/[^1-9]/', '', $_POST['field_'.$row.'_'.$col]);
$sudoku->setField($row, $col, $value);
}
}
if ($action == 'calculate') {
$sudoku->solve();
} else {
$sudoku->validateBoard();
}
} else if ($action == 'generate') {
$sudoku->generate(preg_replace('/[^0-9]/', '', $_POST['numRandomFields']));
}
$sudokuBoard = $sudoku->getBoard();
?>
<!DOCTYPE html><!-- HTML5 -->
<html prefix="og: http://ogp.me/ns#" lang="de-DE" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo LANG_PAGE_TITLE ?></title>
<link rel="stylesheet" type="text/css" media="screen" href="style.css" />
<script type="text/javascript" src="functions.js"></script>
</head>
<body>
<div class="mainContainer">
<form action="index.php" method="post">
<div class="header"></div>
<div class="leftsigns"></div>
<div style="float: left; width: 360px;">
<table cellspacing="0">
<?php for ($row = 0; $row < $numRows; $row++): ?>
<?php $cellClass = ($row > 2 && $row < 6) ? 'cellOdd' : 'cellEven'; ?>
<tr>
<?php for ($col = 0; $col < $numCols; $col++): ?>
<?php $field = $sudokuBoard[$row][$col] ?>
<?php $cellClass = ($col % 3 == 0) ? $helper->switchCellClass($cellClass) : $cellClass; ?>
<td class="<?php echo $cellClass ?>">
<input type="text" maxlength="1" class="inputText_<?php echo $cellClass ?>"
name="field_<?php echo $row.'_'.$col ?>" id="field_<?php echo $row.'_'.$col ?>"
value="<?php echo ($field->getIsGiven()) ? $field->getValue() : '' ?>"
onkeyup="checkField('<?php echo $row ?>', '<?php echo $col ?>');" />
</td>
<?php endfor ?>
</tr>
<?php endfor ?>
</table>
</div>
<div class="rightsigns"></div>
<div style="clear: both;"></div>
<p style="margin: 4px auto;">
<input type="button" value="<?php echo BUTTON_GENERATE ?>" onclick="confirmGenerate();" />
<input type="button" value="<?php echo BUTTON_CHECK ?>" onclick="checkSudoku();" />
<input type="submit" value="<?php echo BUTTON_SOLVE ?>" />
<input type="button" value="<?php echo BUTTON_RESET ?>" onclick="confirmReset();" />
<input type="hidden" name="action" id="action" value="calculate" />
<input type="hidden" name="numRandomFields" id="numRandomFields" value="0" />
<input type="hidden" name="lang" id="lang" value="<?php echo $language ?>" />
</p>
</form>
<?php if ($action == 'calculate' || $action == 'check'): ?>
<div class="infoBox">
<img src="images/information.png" style="float: left; margin-right: 3px;" alt="Info" />
<?php if ($action == 'calculate' && $sudoku->getIsSolved()): ?>
<?php echo MSG_SUDOKU_IS_SOLVABLE ?>
<?php elseif ($action == 'calculate' && !$sudoku->getIsSolved()): ?>
<?php echo MSG_SUDOKU_IS_NOT_SOLVABLE ?>
<?php elseif ($action == 'check' && $sudoku->getIsValid()): ?>
<?php echo MSG_SUDOKU_IS_VALID ?>
<?php elseif ($action == 'check' && !$sudoku->getIsValid()): ?>
<?php echo MSG_SUDOKU_IS_NOT_VALID ?>
<?php endif ?>
</div>
<?php if (($action == 'calculate' && $sudoku->getIsSolved()) || ($action == 'check')): ?>
<table cellspacing="0">
<?php for ($row = 0; $row < $numRows; $row++): ?>
<?php $cellClass = ($row > 2 && $row < 6) ? 'cellOdd' : 'cellEven'; ?>
<tr>
<?php for ($col = 0; $col < $numCols; $col++): ?>
<?php $field = $sudokuBoard[$row][$col] ?>
<?php $cellClass = ($col % 3 == 0) ? $helper->switchCellClass($cellClass) : $cellClass; ?>
<td class="<?php echo $cellClass ?>" <?php if (!$field->getIsValid()) echo 'style="color: red;"' ?>>
<?php echo (!is_null($field->getValue())) ? $field->getValue() : '&nbsp;' ?>
</td>
<?php endfor ?>
</tr>
<?php endfor ?>
</table>
<?php endif ?>
<?php else: ?>
<div class="infoBox">
<img src="images/information.png" style="float: left; margin-right: 3px;" alt="Info" />
<p style="font-weight: bold; margin-bottom: 6px;"><?php echo MSG_WELCOME_PART1 ?></p>
<p class="welcomeMsg"><?php echo MSG_WELCOME_PART2 ?></p>
<p class="welcomeMsg"><?php echo MSG_WELCOME_PART3 ?></p>
</div>
<?php endif ?>
</div>
<script>
function confirmLangChange() {
return confirm("<?php echo MSG_CONFIRM_LANGUAGE_CHANGE ?>");
}
function confirmGenerate() {
var myRandomFields = prompt("<?php echo MSG_PROMPT_NUM_RANDOM_FIELDS ?>", "<?php echo $defaultRndFields ?>");
if (myRandomFields.length > 0 && myRandomFields.length < 3) {
document.getElementById('numRandomFields').value = myRandomFields;
document.getElementById('action').value = 'generate';
document.forms[0].submit();
}
}
function confirmReset() {
if (confirm("<?php echo MSG_CONFIRM_RESET ?>")) {
location.href = 'index.php?lang=<?php echo $language ?>';
}
}
function checkSudoku() {
document.getElementById('action').value = 'check';
document.forms[0].submit();
}
</script>
</body>
</html>
Code Datei "style.css"
body,html { color: #7C6031; font-family: Tahoma; font-size: 9pt; margin: 0px; }
form { margin: 0px; }
input { font-family: Tahoma; font-size: 11pt; color: #7C6031; margin: 3px; background: #EEF6E9; border: 2px solid #7C6031; }
.inputText_cellOdd {
background: #EEF6E9;
border: 0px;
font-size: 14pt;
font-weight: bold;
padding: 0px;
padding-top: 1px;
text-align: center;
width: 30px;
}
.inputText_cellEven {
border: 0px;
font-size: 14pt;
font-weight: bold;
padding: 0px;
padding-top: 1px;
text-align: center;
width: 30px;
background: #FFFFFF;
}
p { font-family: Tahoma; font-size: 10pt; margin: 2px; }
table { border: 2px solid #7C6031; font-family: Tahoma; font-size: 9pt; margin: auto; }
table td {
font-size: 12pt;
font-weight: bold;
border-right: 1px solid #7C6031;
border-bottom: 1px solid #7C6031;
height: 35px;
width: 35px;
}
.cellOdd { background: #EEF6E9; }
.cellEven { background: #FFFFFF; }
.infoBox {
border: 2px solid #7C6031;
background: #EEF6E9;
text-align: left;
margin: 0px auto 6px auto;
padding: 5px;
width: 440px;
}
.welcomeMsg { margin-bottom: 4px; }
.welcomeMsg:first-letter { font-size: 11pt; font-weight: bold; }
.mainContainer { margin: 6px auto; padding: 6px; text-align: center; width: 460px; }
.header {
background: url(./images/header.png) no-repeat center;
height: 50px;
margin: auto;
text-align: right;
width: 100%;
}
.leftsigns { background: url(./images/leftsigns.png) no-repeat; float: left; height: 300px; width: 50px; }
.rightsigns { background: url(./images/rightsigns.png) no-repeat; float: left; height: 300px; width: 50px; }

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