Skip to content

Instantly share code, notes, and snippets.

@dsjoerg
Last active December 23, 2015 04:49
Show Gist options
  • Save dsjoerg/564063cd8fcd96d1c6b3 to your computer and use it in GitHub Desktop.
Save dsjoerg/564063cd8fcd96d1c6b3 to your computer and use it in GitHub Desktop.
gg.directive('army', function() {
return {
restrict: 'E',
template: JST['angular/templates/army'](),
transclude: true,
replace: true,
scope: {
match: '=',
entity: '=',
frame: '='
},
controller: ['$scope', function($scope) {
armyUpdate = function(v) {
if(v) { $scope.army = $scope.match.entityArmyAt($scope.entity, v); }
};
$scope.$watch('frame', armyUpdate);
}]
}
});
function updateObserverUI() {
youtube_seconds = window.theGGYTplayer.getCurrentTime();
s2_seconds = compute_s2_time(youtube_seconds);
// starcraft frames are 16ths of a second.
s2_frames = Math.floor(s2_seconds * 16.0);
// tell the angular widgets what starcraft time it is.
matchScope = angular.element($('#match')).scope();
matchScope.$apply(function() {
matchScope.current_frame = s2_frames;
});
}
function onPlayerReady(event) {
event.target.playVideo();
window.setInterval(updateObserverUI, 250);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment