Last active
August 29, 2015 14:09
-
-
Save lkysow/7b3c7850050761c27673 to your computer and use it in GitHub Desktop.
Browser code for our LeapSnap Hackathon Project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function () { | |
var coverflow_index = 0; | |
var socket = new WebSocket("ws://192.168.5.33:8088/"); | |
socket.onmessage = function (event) { | |
var data = event.data; | |
console.log('received: ' + data); | |
runGesture(data); | |
}; | |
var runGesture = _.debounce(function (data) { | |
console.log("*********************************" + data); | |
switch (data) { | |
case "swipeleft": | |
if ($('#coverflow').coverflow('prev')) { | |
coverflow_index--; | |
} | |
break; | |
case "swiperight": | |
if ($('#coverflow').coverflow('next')) { | |
coverflow_index++; | |
} | |
break; | |
case "screenTap": | |
var currElem = $('#coverflow').children().eq(coverflow_index); | |
var videoLink = currElem[0].getAttribute("data-videolink"); | |
var videoPlayer = document.getElementById("really-cool-video_html5_api"); | |
videoPlayer.src = "" + videoLink + ""; | |
$('.videos').show(); | |
$('#coverflow').hide(); | |
break; | |
case "keyTap": | |
$('.videos').hide(); | |
$('#coverflow').show(); | |
break; | |
} | |
}, 150, true); | |
$.ajax({ | |
url: 'http://192.168.5.148:9999', type: 'GET', cache: false, complete: function () {}, | |
success: function (data) { | |
var imageHtml = ""; | |
var obj; | |
var luke_server = "http://192.168.5.148:9999"; | |
for (var key in data) { | |
obj = data[key]; | |
console.log(obj); | |
imageHtml += '<img class="thumbnail-preview" src="' + luke_server + '/' + obj.thumbnailUrl + '" data-videolink="' + luke_server + '/' + obj.videoUrl + '" />'; | |
} | |
$('#coverflow').html(imageHtml); | |
// and kick off | |
$('#coverflow').coverflow(); | |
}, | |
error: function () { | |
console.log('Something went wrong!'); | |
}, | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment