(function () { 'use strict'; let Congratulations = function ($scope, userService, streamService, $location, $routeParams) { $scope.storylineId = $routeParams.storylineId; $scope.name = 'Hey,'; userService.getUser() .then(function (data) { $scope.name = data.userName; }); $scope.callback = function () { if ($scope.storylineId) { $location.url(`/storylines/${$scope.storylineId}/invitations/first`); } else { $location.url('question/first'); } }; $scope.zoom = function (img) { $scope.bigImage = img; }; $scope.hideImage = function () { $scope.bigImage = false; }; $scope.dropUploading = streamService.isUploading(finishedUpload); $scope.uploading = []; if ($scope.dropUploading) { $scope.uploading.push(true); }; function finishedUpload() { $scope.uploading.pop(); let indexOf = $scope.stream.findIndex(s => s.drop = $scope.dropUploading); if (indexOf >= 0) { streamService.getMemory($scope.dropUploading).then(memory => $scope.stream[indexOf] = memory); } }; $scope.load = function () { if ($routeParams.dropId) { streamService.getMemory($routeParams.dropId).then(memory => { $scope.stream = [memory]; $scope.moment = $scope.stream[0]; $('.waiting').hide(); }); } }; $scope.load(); $scope.edit = function (moment) { moment.edit = !moment.edit; } $scope.updateExistingDrop = function (moment) { if (moment.editable) { var date = new Date(moment.date); $scope.crud = {}; $scope.crud.content = moment.content; $scope.crud.drop = moment.drop; $scope.crud.dateType = moment.dateType; $scope.crud.date = timeService.getDate(date); $scope.crud.complete = moment.complete; $scope.crud.images = moment.images; } }; }; Congratulations.$inject = ['$scope', 'userService', 'streamService', '$location', '$routeParams']; angular.module('streamApp').controller('congratulationsController', Congratulations); })();