zeus.ugent.be/content/assets/scripts/cammie.coffee

33 lines
788 B
CoffeeScript
Raw Normal View History

# 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-28 22:43:21 +00:00
# Display controls when moving mouse
2016-08-29 13:10:08 +00:00
$ "#cammie-ctrls"
.mousemove debounce () ->
$ this
.removeClass 'display'
, 3000, () ->
$ this
2016-08-28 22:43:21 +00:00
.addClass 'display'
# Cammie controls
$ '.ctrl'
.click ->
$context = $ this
2016-10-03 13:15:48 +00:00
$.ajax "https://kelder.zeus.ugent.be/webcam/cgi/ptdc.cgi",
2016-08-28 22:43:21 +00:00
data:
2016-08-30 16:28:14 +00:00
command: $context.data 'command'
2016-08-28 22:43:21 +00:00
posX: $context.data 'x'
2016-10-03 13:15:48 +00:00
posY: $context.data 'y'