Mercurial > hg > mood-conductor
comparison 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 |
comparison
equal
deleted
inserted
replaced
8:f9d621228bd9 | 9:180274c3b48a |
---|---|
114 }, | 114 }, |
115 | 115 |
116 onMouseUp: function(event) { | 116 onMouseUp: function(event) { |
117 this.mouseDown = false; | 117 this.mouseDown = false; |
118 this.setMarker(event.pageX, event.pageY); | 118 this.setMarker(event.pageX, event.pageY); |
119 this.sendPosition(event.pageX, event.pageY); | |
120 }, | |
121 | |
122 sendPosition: function(pageX, pageY) { | |
123 var x = pageX / 320; | |
124 var y = 1 - pageY / 320; | |
125 this.request("/mood?x=" + x + "&y=" + y); | |
119 }, | 126 }, |
120 | 127 |
121 setMarker: function(pageX, pageY) { | 128 setMarker: function(pageX, pageY) { |
122 this.background(); | 129 this.background(); |
123 this.drawMarker(pageX, pageY); | 130 this.drawMarker(pageX, pageY); |
125 var x = pageX / 320; | 132 var x = pageX / 320; |
126 var y = 1 - pageY / 320; | 133 var y = 1 - pageY / 320; |
127 | 134 |
128 var mood = this.findMood(x, y); | 135 var mood = this.findMood(x, y); |
129 | 136 |
130 if (mood != this.mood) { | 137 this.label.innerHTML = mood.label; |
131 this.label.innerHTML = mood.label; | 138 this.mood = mood; |
132 this.mood = mood; | |
133 this.request("/mood?x=" + x + "&y=" + y); | |
134 } | |
135 }, | 139 }, |
136 | 140 |
137 drawMarker: function(x, y) { | 141 drawMarker: function(x, y) { |
138 var ctx = this.canvas.getContext("2d"); | 142 var ctx = this.canvas.getContext("2d"); |
139 ctx.fillStyle = "rgba(0, 0, 0, 0.5)"; | 143 ctx.fillStyle = "rgba(0, 0, 0, 0.5)"; |