Merge pull request #305 from ZeusWPI/feature/cammie-error
Feature/cammie error
This commit is contained in:
commit
65ffabbd2a
4 changed files with 305 additions and 33 deletions
258
content/assets/images/cammie_down.svg
Normal file
258
content/assets/images/cammie_down.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 93 KiB |
|
@ -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'
|
46
content/assets/scripts/cammie.js
Normal file
46
content/assets/scripts/cammie.js
Normal 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')
|
||||
}
|
||||
});
|
||||
});
|
|
@ -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">
|
||||
|
|
Loading…
Reference in a new issue