From: Ian Jackson Date: Fri, 26 Jun 2020 21:14:34 +0000 (+0100) Subject: initial move - jerky X-Git-Tag: otter-0.2.0~1550 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=a85a49c15667e2067d786408bca642516b5fd84b;p=otter.git initial move - jerky --- diff --git a/src/bin/server.rs b/src/bin/server.rs index 3c0df0f3..d2736c78 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs @@ -114,10 +114,22 @@ struct ApiGrab { t : String, p : VisiblePieceId, } - #[post("/_/api/grab", format="json", data="
")] #[throws(RE)] -fn api(form : Json) -> impl response::Responder<'static> { +fn api_grab(form : Json) -> 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="")] +#[throws(RE)] +fn api_move(form : Json) -> impl response::Responder<'static> { eprintln!("API {:?}", &form); "" } @@ -193,7 +205,8 @@ fn main() { session, resource, updates, - api, + api_grab, + api_move, ]) .launch(); } diff --git a/templates/script.js b/templates/script.js index 17d3b381..6f0f123e 100644 --- a/templates/script.js +++ b/templates/script.js @@ -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(){}); } }