소스 검색

keyboard friendly

schtonn 2 년 전
부모
커밋
79ca2f284b
2개의 변경된 파일15개의 추가작업 그리고 8개의 파일을 삭제
  1. 14 7
      js/paint.js
  2. 1 1
      paint/index.html

+ 14 - 7
js/paint.js

@@ -79,9 +79,11 @@ var curVer = 0, maxVer = -1, stopVer = 1000, stopped = false, working = false;
 var maxResult = {};
 
 function getMap() {
-    if (working) return;
+    if (working) {
+        console.log("Too frequent!");
+        return;
+    }
     working = true;
-    console.log('g' + working)
     if (curVer != 0) document.getElementById('upload').classList.add('disabled')
     else document.getElementById('upload').classList.remove('disabled')
     if (curVer >= stopVer) {
@@ -139,23 +141,28 @@ function reset() {
 }
 
 function prevVer() {
-    console.log(working)
-    if (working) return;
+    if (working) {
+        console.log("Too frequent!");
+        return;
+    }
     curVer++, getMap();
 }
 
 function nextVer() {
-    if (working) return;
+    if (working) {
+        console.log("Too frequent!");
+        return;
+    }
     curVer == 0 ? true : (curVer--, getMap());
 }
 
 document.onkeydown = function (event) {
     var e = event || window.event || arguments.callee.caller.arguments[0];
     if (e) {
-        if (e.key == "ArrowLeft") {
+        if (e.key == "a") {
             prevVer()
         }
-        else if (e.key == "ArrowRight") {
+        else if (e.key == "d") {
             nextVer()
         }
     }

+ 1 - 1
paint/index.html

@@ -204,7 +204,7 @@
     </div>
     <div id="controls">
         <button class="btn btn-default noshadow" id="help"
-            onclick="alert('说明:左键绘制,右键擦除。\n左右方向键可浏览历史版本,鼠标悬停于版本上可查看时间。\n点击上传后,同一设备一天内的编辑将会保存在一个版本中,并对所有人可见。')"><span
+            onclick="alert('说明:左键绘制,右键擦除。\n键盘AD键或屏幕下方按键可浏览历史版本,鼠标悬停于版本上可查看时间。\n点击上传后,同一设备一天内的编辑将会保存在一个版本中,并对所有人可见。')"><span
                 class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></button>
         <button class="btn btn-default noshadow" id="zoom"><span class="glyphicon glyphicon-zoom-in"
                 aria-hidden="true"></span></button>