mirror of
https://github.com/donl/screenspook.git
synced 2026-05-27 06:13:06 -06:00
46 lines
1.5 KiB
JavaScript
46 lines
1.5 KiB
JavaScript
$(document).ready(function() {
|
|
|
|
var pendingShotsTemplateSrc = $("#pending-shots-template").html();
|
|
var pendingShotsTemplate = Handlebars.compile(pendingShotsTemplateSrc);
|
|
|
|
var acceptedShotsTemplateSrc = $("#accepted-shots-template").html();
|
|
var acceptedShotsTemplate = Handlebars.compile(acceptedShotsTemplateSrc);
|
|
|
|
var setupAcceptShot = function() {
|
|
$('.acceptShot').bind('click', function(event) {
|
|
var shotId = event.currentTarget.dataset.shotid;
|
|
console.log('accept' , shotId);
|
|
|
|
var el = event.currentTarget;
|
|
|
|
$.ajax({
|
|
url: '/accept/' + shotId,
|
|
success: function(data, textStatus, jqXHR) {
|
|
if (data.ok) {
|
|
// hide the complete shot.
|
|
console.log('accepted');
|
|
$(el).parent().parent().fadeOut(500, reload);
|
|
}
|
|
},
|
|
dataType: 'json'
|
|
});
|
|
});
|
|
};
|
|
|
|
var reload = function() {
|
|
$.ajax({
|
|
url : '/overview',
|
|
success: function(data) {
|
|
$('#pendingShots').html(pendingShotsTemplate({items:data.pendingShots}));
|
|
$('#acceptedShots').html(acceptedShotsTemplate({items:data.acceptedShots}));
|
|
setupAcceptShot();
|
|
$('.shot').fancybox();
|
|
}
|
|
});
|
|
};
|
|
|
|
$('.reloadButton').bind('click', reload);
|
|
|
|
reload();
|
|
|
|
});
|