Merge pull request #305 from ZeusWPI/feature/cammie-error

Feature/cammie error
This commit is contained in:
Rien 2018-12-14 01:57:51 +01:00 committed by GitHub
commit 65ffabbd2a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 305 additions and 33 deletions

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 93 KiB

View file

@ -1,32 +0,0 @@
# 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
# Display controls when moving mouse
$ "#cammie-ctrls"
.mousemove debounce () ->
$ this
.removeClass 'display'
, 3000, () ->
$ this
.addClass 'display'
# Cammie controls
$ '.ctrl'
.click ->
$context = $ this
$.ajax "https://kelder.zeus.ugent.be/webcam/cgi/ptdc.cgi",
data:
command: $context.data 'command'
posX: $context.data 'x'
posY: $context.data 'y'

View file

@ -0,0 +1,46 @@
var debounce;
debounce = function(func, wait, initial) {
var timeout;
if (initial == null) {
initial = function() {};
}
timeout = false;
return function() {
var args, callNow, context, later;
context = this;
args = arguments;
later = function() {
timeout = null;
return func.apply(context, args);
};
callNow = !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) {
return initial.apply(context, args);
}
};
};
function cammie_error() {
$("#cammie-feed").attr("src","/assets/images/cammie_down.svg")
}
$("#cammie-ctrls").mousemove(debounce(function() {
return $(this).removeClass('display');
}, 3000, function() {
return $(this).addClass('display');
}));
$('.ctrl').click(function() {
var $context;
$context = $(this);
return $.ajax("https://kelder.zeus.ugent.be/webcam/cgi/ptdc.cgi", {
data: {
command: $context.data('command'),
posX: $context.data('x'),
posY: $context.data('y')
}
});
});

View file

@ -11,7 +11,7 @@ title: Cammie
<section id="cammie-section">
<div id="cammie-body">
<figure class="image is-16by9">
<img id="cammie-feed" alt="cammie" src="https://kelder.zeus.ugent.be/webcam/video/mjpg.cgi?profileid=2">
<img id="cammie-feed" alt="cammie" src="https://kelder.zeus.ugent.be/webcam/video/mjpg.cgi?profileid=2" onerror="cammie_error()">
</figure>
<div id="cammie-ctrls">
<div class="columns is-mobile">