added voting with keyboard shortcuts (keys 1-5)
This commit is contained in:
parent
467f2dbdad
commit
a16e4229cf
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
header( 'Content-type: text/javascript; charset=utf-8' );
|
header( 'Content-type: text/javascript; charset=utf-8' );
|
||||||
?>
|
?>
|
||||||
|
var imageId;
|
||||||
|
|
||||||
document.onkeydown=function(e){
|
document.onkeydown=function(e){
|
||||||
var pressedKey = e.keyCode || e.which;
|
var pressedKey = e.keyCode || e.which;
|
||||||
|
@ -8,16 +9,16 @@ document.onkeydown=function(e){
|
||||||
up: 38, //
|
up: 38, //
|
||||||
right: 39, // navigate back
|
right: 39, // navigate back
|
||||||
down: 40, //
|
down: 40, //
|
||||||
one: 49, // vote 1* // TODO
|
one: 49, // vote 1*
|
||||||
two: 50, // vote 2* // TODO
|
two: 50, // vote 2*
|
||||||
three: 51, // vote 3* // TODO
|
three: 51, // vote 3*
|
||||||
four: 52, // vote 4* // TODO
|
four: 52, // vote 4*
|
||||||
five: 53, // vote 5* // TODO
|
five: 53, // vote 5*
|
||||||
num1: 97, // vote 1* // TODO
|
num1: 97, // vote 1*
|
||||||
num2: 98, // vote 2* // TODO
|
num2: 98, // vote 2*
|
||||||
num3: 99, // vote 3* // TODO
|
num3: 99, // vote 3*
|
||||||
num4: 100, // vote 4* // TODO
|
num4: 100, // vote 4*
|
||||||
num5: 101, // vote 5* // TODO
|
num5: 101, // vote 5*
|
||||||
plus: 107, // toggle image display size
|
plus: 107, // toggle image display size
|
||||||
minus: 109, // toggle image display size
|
minus: 109, // toggle image display size
|
||||||
c: 67, // focus cursor into comments field
|
c: 67, // focus cursor into comments field
|
||||||
|
@ -30,7 +31,6 @@ document.onkeydown=function(e){
|
||||||
};
|
};
|
||||||
|
|
||||||
var focusedElement = document.activeElement;
|
var focusedElement = document.activeElement;
|
||||||
console.log("focused: " + focusedElement.id);
|
|
||||||
|
|
||||||
if( focusedElement.id != "commentContent" && focusedElement.id != "q" )
|
if( focusedElement.id != "commentContent" && focusedElement.id != "q" )
|
||||||
{
|
{
|
||||||
|
@ -45,22 +45,27 @@ document.onkeydown=function(e){
|
||||||
break;
|
break;
|
||||||
case keyCodes.one:
|
case keyCodes.one:
|
||||||
case keyCodes.num1:
|
case keyCodes.num1:
|
||||||
|
rate(imageId,1);
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
case keyCodes.two:
|
case keyCodes.two:
|
||||||
case keyCodes.num2:
|
case keyCodes.num2:
|
||||||
|
rate(imageId,2);
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
case keyCodes.three:
|
case keyCodes.three:
|
||||||
case keyCodes.num3:
|
case keyCodes.num3:
|
||||||
|
rate(imageId,3);
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
case keyCodes.four:
|
case keyCodes.four:
|
||||||
case keyCodes.num4:
|
case keyCodes.num4:
|
||||||
|
rate(imageId,4);
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
case keyCodes.five:
|
case keyCodes.five:
|
||||||
case keyCodes.num5:
|
case keyCodes.num5:
|
||||||
|
rate(imageId,5);
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
case keyCodes.plus:
|
case keyCodes.plus:
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<div id="imageContainer">
|
<div id="imageContainer">
|
||||||
<img id="image" onclick="swap(this, 'scaled', 'full')" class="scaled" src="<?php echo Config::$absolutePath.Config::$images['imagePath'].$iv->image['path']; ?>" alt="<?php echo htmlspecialchars($iv->image['tags']) ?>"/>
|
<img id="image" onclick="swap(this, 'scaled', 'full')" class="scaled" src="<?php echo Config::$absolutePath.Config::$images['imagePath'].$iv->image['path']; ?>" alt="<?php echo htmlspecialchars($iv->image['tags']) ?>" onload="imageId = <?php echo $iv->image['id']; ?>"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="imageInfo">
|
<div id="imageInfo">
|
||||||
|
|
Loading…
Reference in New Issue
Block a user