diff mcserver/static/app.js @ 9:180274c3b48a

send on mouse release
author mgeorgi
date Fri, 22 Jun 2012 10:36:35 +0100
parents 9d2f4e6a3f36
children 2c3fe4b24640
line wrap: on
line diff
--- a/mcserver/static/app.js	Fri Jun 22 10:34:48 2012 +0100
+++ b/mcserver/static/app.js	Fri Jun 22 10:36:35 2012 +0100
@@ -116,6 +116,13 @@
   onMouseUp: function(event) {
     this.mouseDown = false;
     this.setMarker(event.pageX, event.pageY);
+    this.sendPosition(event.pageX, event.pageY);
+  },
+
+  sendPosition: function(pageX, pageY) {
+    var x = pageX / 320;
+    var y = 1 - pageY / 320;
+    this.request("/mood?x=" + x + "&y=" + y);
   },
 
   setMarker: function(pageX, pageY) {
@@ -127,11 +134,8 @@
     
     var mood = this.findMood(x, y);
 
-    if (mood != this.mood) {
-      this.label.innerHTML = mood.label;
-      this.mood = mood;
-      this.request("/mood?x=" + x + "&y=" + y);
-    }
+    this.label.innerHTML = mood.label;
+    this.mood = mood;
   },
   
   drawMarker: function(x, y) {