From: Ian Jackson Date: Fri, 26 Jun 2020 21:25:18 +0000 (+0100) Subject: queue dragging X-Git-Tag: otter-0.2.0~1549 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=f37ad91f854c460b700f24185cdf400abda18b99;p=otter.git queue dragging --- diff --git a/templates/script.js b/templates/script.js index 6f0f123e..96293241 100644 --- a/templates/script.js +++ b/templates/script.js @@ -5,6 +5,7 @@ general_timeout = 10000; messages = Object(); var our_dnd_type = "text/puvnex-game-server-dummy"; +drag_posting = false; function xhr_post_then(url,data,good) { var xhr = new XMLHttpRequest(); @@ -69,11 +70,28 @@ function drag_mousemove(e) { delt.setAttributeNS(null, "x", x); delt.setAttributeNS(null, "y", y); console.log(delt); + var l = [Math.round(x),Math.round(y)]; + if (!drag_posting) { + drag_posting = l; + drag_posted(); + } else { + drag_posting = l; + } + } +} + +function drag_posted() { + if (!dragging) { + drag_posting = false; + } else if (drag_posting == true) { + drag_posting = false; + } else { xhr_post_then('/_/api/m',JSON.stringify({ t : token, p : delt.dataset.p, - l : [Math.round(x),Math.round(y)], - }), function(){}); + l : drag_posting, + }), drag_posted); + drag_posting = true; } }