From 6dbee13b1600106137f5cccc58f887c927682094 Mon Sep 17 00:00:00 2001 From: Ryohei Ueda Date: Sun, 2 Nov 2014 22:41:13 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=AD=E3=83=BC=E3=83=9C=E3=83=BC=E3=83=89?= =?UTF-8?q?=E3=82=B7=E3=83=A7=E3=83=BC=E3=83=88=E3=82=AB=E3=83=83=E3=83=88?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0=20*=20=E3=82=B9=E3=83=9A=E3=83=BC?= =?UTF-8?q?=E3=82=B9:=20Next=20*=20s:=20Skip=20*=20r:=20Reset?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/js/mine.js | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/static/js/mine.js b/static/js/mine.js index f8e4fd5..1881ba9 100644 --- a/static/js/mine.js +++ b/static/js/mine.js @@ -1,3 +1,4 @@ +var always_only_one_sample = false; // 一つの画像に高々一つしか正解データがないときtrueにする var coords = new Array(); var curcrd; var canvas; @@ -17,7 +18,23 @@ onload = function(){ $('.bar').css({'width': count*100/imgnum + '%'}); }; +function keypressed(e) { + if (e.keyCode == 32) { // space + if (!released_flag) { + released(); + } + nextajax(skip=0); + } + else if (e.keyCode == 83) { // s + nextajax(skip=1); + } + else if (e.keyCode == 82) { // r + resetstatus(); + } +} + function draw(){ + released_flag = false; var image = new Image(); image.src = imgsrc; image.onload = function(){ @@ -34,10 +51,13 @@ function draw(){ context.drawImage(image, 0, 0); $(function(){ $('#cnvs').Jcrop({ - onSelect: selected, - onRelease: released, + onSelect: selected, + onRelease: released, + keySupport: true }); + $('.jcrop-keymgr').keydown(keypressed); }); + document.onkeydown = keypressed; } } @@ -51,6 +71,7 @@ function released(c){ context.lineWidth = 3; context.strokeStyle = 'rgba(238, 26, 26, 1)'; context.strokeRect(curcrd[0], curcrd[1], curcrd[2], curcrd[3]); + released_flag = true; } function resetstatus(){ @@ -62,9 +83,9 @@ function nextajax(skip){ console.log('座標:'+coords); coords = JSON.stringify(coords); $.ajax({ - type: 'GET', + type: 'GET', dataType: "json", - data: {'coords': coords, 'skip': skip}, + data: {'coords': coords, 'skip': skip}, url: "/_next", success: function (data) { imgsrc = data.imgsrc; @@ -72,7 +93,7 @@ function nextajax(skip){ var finished = data.finished; $('.bar').css({'width': count*100/imgnum + '%'}); console.log(count + '/' + imgnum); - + if (finished){ w = $('.head-wrapper').width() $('.main-wrapper').css({'width': w, 'minWidth': w});