crossword design update & javascript input changes
This commit is contained in:
parent
b4a04d393f
commit
32f254a0c3
3 changed files with 56 additions and 12 deletions
|
|
@ -1,4 +1,4 @@
|
|||
<form method="post">
|
||||
<form method="post" class="crossword">
|
||||
<table>
|
||||
<tbody>
|
||||
<?php foreach(range(0, $maxY) as $y) : ?>
|
||||
|
|
@ -6,7 +6,8 @@
|
|||
<?php foreach(range(0, $maxX) as $x) : ?>
|
||||
<td>
|
||||
<?php if(array_key_exists($x, $matrix) && array_key_exists($y, $matrix[$x]) && !is_null($matrix[$x][$y])) : ?>
|
||||
<input type="text" name="answers[<?=$x?>][<?=$y?>]" maxlength="1" size="1" placeholder="<?=implode('/',$matrix[$x][$y]['indices'])?>" value="<?=(!is_null($matrix[$x][$y]['answer'])) ? $matrix[$x][$y]['answer'] : ''?>" />
|
||||
<span class="index"><?=implode('/',$matrix[$x][$y]['indices'])?></span>
|
||||
<input type="text" name="answers[<?=$x?>][<?=$y?>]" maxlength="1" size="1" value="<?=(!is_null($matrix[$x][$y]['answer'])) ? $matrix[$x][$y]['answer'] : ''?>" />
|
||||
<?php endif ?>
|
||||
</td>
|
||||
<?php endforeach ?>
|
||||
|
|
@ -14,13 +15,28 @@
|
|||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<ul>
|
||||
<ol>
|
||||
<?php foreach($words as &$word) : ?>
|
||||
<li><?=$word['question']?></li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
|
||||
<br /><br />
|
||||
</ol>
|
||||
<input type="submit" name="submit" value="<?=_('solve')?>" />
|
||||
</form>
|
||||
<script type="text/javascript">
|
||||
$('input:text').bind("keyup", function(e) {
|
||||
var n = $("input:text").length;
|
||||
if(e.which == 8 || e.which == 46) {
|
||||
var nextIndex = $('input:text').index(this) - 1;
|
||||
var del = 1;
|
||||
}
|
||||
else {
|
||||
var nextIndex = $('input:text').index(this) + 1;
|
||||
}
|
||||
if(nextIndex < n) {
|
||||
$('input:text')[nextIndex].focus();
|
||||
if(del == 1) {
|
||||
$('input:text')[nextIndex].value = '';
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<form method="post">
|
||||
<form method="post" class="crossword">
|
||||
<table>
|
||||
<tbody>
|
||||
<?php foreach(range(0, $maxY) as $y) : ?>
|
||||
|
|
@ -6,7 +6,8 @@
|
|||
<?php foreach(range(0, $maxX) as $x) : ?>
|
||||
<td>
|
||||
<?php if(array_key_exists($x, $matrix) && array_key_exists($y, $matrix[$x]) && !is_null($matrix[$x][$y])) : ?>
|
||||
<input type="text" name="answers[<?=$x?>][<?=$y?>]" maxlength="1" size="1" disabled="disabled" style="background-color:<?=($matrix[$x][$y]['right']) ? 'green' : 'red'?>" placeholder="<?=implode('/',$matrix[$x][$y]['indices'])?>" value="<?=(!is_null($matrix[$x][$y]['answer'])) ? $matrix[$x][$y]['answer'] : ''?>" />
|
||||
<span class="index"><?=implode('/',$matrix[$x][$y]['indices'])?></span>
|
||||
<input type="text" name="answers[<?=$x?>][<?=$y?>]" maxlength="1" size="1" disabled="disabled" style="background-color:<?=($matrix[$x][$y]['right']) ? 'green' : 'red'?>" value="<?=(!is_null($matrix[$x][$y]['answer'])) ? $matrix[$x][$y]['answer'] : ''?>" />
|
||||
<?php endif ?>
|
||||
</td>
|
||||
<?php endforeach ?>
|
||||
|
|
@ -14,10 +15,27 @@
|
|||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<ul>
|
||||
<ol>
|
||||
<?php foreach($words as &$word) : ?>
|
||||
<li><?=$word['question']?></li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
</ol>
|
||||
</form>
|
||||
<script type="text/javascript">
|
||||
$('input:text').bind("keyup", function(e) {
|
||||
var n = $("input:text").length;
|
||||
if(e.which == 8 || e.which == 46) {
|
||||
var nextIndex = $('input:text').index(this) - 1;
|
||||
var del = 1;
|
||||
}
|
||||
else {
|
||||
var nextIndex = $('input:text').index(this) + 1;
|
||||
}
|
||||
if(nextIndex < n) {
|
||||
$('input:text')[nextIndex].focus();
|
||||
if(del == 1) {
|
||||
$('input:text')[nextIndex].value = '';
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue