2016-07-19 11:31:12 +02:00
|
|
|
# All the cammie controls
|
|
|
|
commands =
|
|
|
|
up:
|
|
|
|
command: 'set_relative_pos'
|
|
|
|
posX: 0
|
|
|
|
posY: 10
|
|
|
|
down:
|
|
|
|
command: 'set_relative_pos'
|
|
|
|
posX: 0
|
|
|
|
posY: -10
|
|
|
|
left:
|
|
|
|
command: 'set_relative_pos'
|
|
|
|
posX: -10
|
|
|
|
posY: 0
|
|
|
|
right:
|
|
|
|
command: 'set_relative_pos'
|
|
|
|
posX: 10
|
|
|
|
posY: 0
|
|
|
|
|
|
|
|
# Initially hide all the controls
|
|
|
|
$('.ctrl').hide()
|
|
|
|
|
2016-07-18 09:24:24 +02:00
|
|
|
$('.ctrl').click ->
|
|
|
|
$.ajax "//kelder.zeus.ugent.be/webcam/cgi/ptdc.cgi",
|
2016-07-19 11:31:12 +02:00
|
|
|
data: commands[$(this).attr('id')]
|
2016-07-18 12:07:15 +02:00
|
|
|
|
2016-07-19 11:31:12 +02:00
|
|
|
timer = undefined
|
|
|
|
fade_buffer = false
|
|
|
|
blocking = false
|
|
|
|
|
|
|
|
clear_timer = () ->
|
|
|
|
clearTimeout timer
|
|
|
|
timer = 0
|
2016-07-18 12:07:15 +02:00
|
|
|
|
2016-07-19 11:31:12 +02:00
|
|
|
set_timer = () ->
|
|
|
|
timer = setTimeout((->
|
|
|
|
ctrl_hide()
|
|
|
|
fade_buffer = true
|
|
|
|
), 3000)
|
2016-07-18 12:07:15 +02:00
|
|
|
|
2016-07-19 11:31:12 +02:00
|
|
|
ctrl_show = () ->
|
2016-07-18 12:07:15 +02:00
|
|
|
$('.ctrl').fadeIn()
|
2016-07-19 11:31:12 +02:00
|
|
|
|
|
|
|
ctrl_hide = () ->
|
|
|
|
$('.ctrl').fadeOut()
|
|
|
|
|
|
|
|
block_hide = () ->
|
|
|
|
clear_timer()
|
|
|
|
blocking = true
|
|
|
|
|
|
|
|
unblock_hide = () ->
|
|
|
|
set_timer()
|
|
|
|
blocking = false
|
|
|
|
|
|
|
|
$(document).mousemove ->
|
|
|
|
if !blocking
|
|
|
|
if !fade_buffer
|
|
|
|
clear_timer() if timer
|
|
|
|
else
|
|
|
|
fade_buffer = false
|
|
|
|
|
|
|
|
ctrl_show()
|
|
|
|
set_timer()
|
|
|
|
|
|
|
|
$('.ctrl').mouseover(block_hide)
|
|
|
|
|
|
|
|
# Timeout when we leave the window
|
|
|
|
$(document).mouseleave(unblock_hide)
|