chiark / gitweb /
initial move - jerky
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 26 Jun 2020 21:14:34 +0000 (22:14 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 26 Jun 2020 21:14:34 +0000 (22:14 +0100)
src/bin/server.rs
templates/script.js

index 3c0df0f3a8974a08be164c559d843cf5dc0f9903..d2736c78967a1701bc32802aa9f8d42768f2ac59 100644 (file)
@@ -114,10 +114,22 @@ struct ApiGrab {
   t : String,
   p : VisiblePieceId,
 }
-
 #[post("/_/api/grab", format="json", data="<form>")]
 #[throws(RE)]
-fn api(form : Json<ApiGrab>) -> impl response::Responder<'static> {
+fn api_grab(form : Json<ApiGrab>) -> impl response::Responder<'static> {
+  eprintln!("API {:?}", &form);
+  ""
+}
+
+#[derive(Debug,Serialize,Deserialize)]
+struct ApiMove {
+  t : String,
+  p : VisiblePieceId,
+  l : Pos,
+}
+#[post("/_/api/m", format="json", data="<form>")]
+#[throws(RE)]
+fn api_move(form : Json<ApiMove>) -> impl response::Responder<'static> {
   eprintln!("API {:?}", &form);
   ""
 }
@@ -193,7 +205,8 @@ fn main() {
       session,
       resource,
       updates,
-      api,
+      api_grab,
+      api_move,
     ])
     .launch();
 }
index 17d3b3813abd02109f3731af69398817f557d712..6f0f123e9594a8afbabce51d4853063481252e38 100644 (file)
@@ -69,6 +69,11 @@ function drag_mousemove(e) {
     delt.setAttributeNS(null, "x", x);
     delt.setAttributeNS(null, "y", y);
     console.log(delt);
+    xhr_post_then('/_/api/m',JSON.stringify({
+      t : token,
+      p : delt.dataset.p,
+      l : [Math.round(x),Math.round(y)],
+    }), function(){});
   }
 }