2016-08-29 00:13:12 +02:00
|
|
|
# Reworked version of the underscorejs debounce
|
|
|
|
debounce = (func, wait, initial = () -> ) ->
|
|
|
|
timeout = false
|
|
|
|
() ->
|
|
|
|
context = this
|
|
|
|
args = arguments
|
|
|
|
later = () ->
|
|
|
|
timeout = null
|
|
|
|
func.apply context, args
|
|
|
|
callNow = !timeout
|
|
|
|
clearTimeout timeout
|
|
|
|
timeout = setTimeout later, wait
|
|
|
|
initial.apply context, args if callNow
|
|
|
|
|
2016-08-29 00:43:21 +02:00
|
|
|
# Display controls when moving mouse
|
2016-08-29 15:10:08 +02:00
|
|
|
$ "#cammie-ctrls"
|
2016-08-29 00:13:12 +02:00
|
|
|
.mousemove debounce () ->
|
|
|
|
$ this
|
|
|
|
.removeClass 'display'
|
|
|
|
, 3000, () ->
|
|
|
|
$ this
|
2016-08-29 00:43:21 +02:00
|
|
|
.addClass 'display'
|
|
|
|
|
|
|
|
# Cammie controls
|
|
|
|
$ '.ctrl'
|
|
|
|
.click ->
|
|
|
|
$context = $ this
|
|
|
|
$.ajax "//kelder.zeus.ugent.be/webcam/cgi/ptdc.cgi",
|
|
|
|
data:
|
|
|
|
command: 'set_relative_pos'
|
|
|
|
posX: $context.data 'x'
|
|
|
|
posY: $context.data 'y'
|