paste indent correction - JS
You copy some javascript code from a website and paste it into vim, it does not look good!
Start file
function AlbumCtrl($scope, $http) { $scope.url = 'http://onehungrymind.com/angular-album/images.json'; $scope.images = []; $scope.imageCategories = []; $scope.currentImage = {}; function handleImagesLoaded(data, status) { $scope.images = data; $scope.currentImage = _.first($scope.images); $scope.imageCategories = _.uniq(_.pluck($scope.images, 'category')); } $scope.fetch = function () { $http.get($scope.url).success($scope.handleImagesLoaded); } $scope.setCurrentImage = function (image) { $scope.currentImage = image; }; $scope.fetch(); }
End file
function AlbumCtrl($scope, $http) { $scope.url = 'http://onehungrymind.com/angular-album/images.json'; $scope.images = []; $scope.imageCategories = []; $scope.currentImage = {}; function handleImagesLoaded(data, status) { $scope.images = data; $scope.currentImage = _.first($scope.images); $scope.imageCategories = _.uniq(_.pluck($scope.images, 'category')); } $scope.fetch = function () { $http.get($scope.url).success($scope.handleImagesLoaded); } $scope.setCurrentImage = function (image) { $scope.currentImage = image; }; $scope.fetch(); }
View Diff
2,5c2,5 < $scope.url = 'http://onehungrymind.com/angular-album/images.json'; < $scope.images = []; < $scope.imageCategories = []; < $scope.currentImage = {}; --- > $scope.url = 'http://onehungrymind.com/angular-album/images.json'; > $scope.images = []; > $scope.imageCategories = []; > $scope.currentImage = {}; 7,11c7,11 < function handleImagesLoaded(data, status) { < $scope.images = data; < $scope.currentImage = _.first($scope.images); < $scope.imageCategories = _.uniq(_.pluck($scope.images, 'category')); < } --- > function handleImagesLoaded(data, status) { > $scope.images = data; > $scope.currentImage = _.first($scope.images); > $scope.imageCategories = _.uniq(_.pluck($scope.images, 'category')); > } 13,15c13,15 < $scope.fetch = function () { < $http.get($scope.url).success($scope.handleImagesLoaded); < } --- > $scope.fetch = function () { > $http.get($scope.url).success($scope.handleImagesLoaded); > } 17,19c17,19 < $scope.setCurrentImage = function (image) { < $scope.currentImage = image; < }; --- > $scope.setCurrentImage = function (image) { > $scope.currentImage = image; > }; 21c21 < $scope.fetch(); --- > $scope.fetch();
Solutions by @charlieoconor:
Unlock 1 remaining solutions by signing in and submitting your own entry