-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added service for birdwalk; added detail page
- Loading branch information
Mark Cottman-Fields
committed
Nov 15, 2013
1 parent
3b46dd1
commit 0e46cc1
Showing
6 changed files
with
73 additions
and
59 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div class="row" data-ng-controller="BirdWalkCtrl"> | ||
{{params}} | ||
<div class="col-sm-6 col-md-3" data-ng-repeat="(name, walkSpec) in spec.birdWalkSpec.walks"> | ||
|
||
</div> | ||
|
||
{{spec.walks}} | ||
</div> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,24 @@ | ||
angular.module('bawApp.birdWalks', []) | ||
.controller( | ||
'BirdWalkCtrl', | ||
['$scope', '$resource', '$routeParams','$route', '$http', | ||
function BirdWalkCtrl($scope, $resource, $routeParams, $route, $http) { | ||
// set up results | ||
$scope.results = { | ||
allowContact: true, | ||
consented: false, | ||
ethicsStatementViewed: false, | ||
pageHit: (new Date()).toISOString() | ||
}; | ||
|
||
$scope.spec = {}; | ||
|
||
$scope.imagesPath = '/assets/bird_walk/images/'; | ||
|
||
// download bird walk specification | ||
downloadResources('/assets/bird_walk/bird_walk_spec.json', 'birdWalkSpec'); | ||
|
||
function downloadResources(primaryResource, primaryStoreProperty) { | ||
var maxAttempts = 5; | ||
|
||
function downloadRecursive(attemptsLeft, resource, storeProperty) { | ||
if (attemptsLeft > 0) { | ||
$http.get(resource + "?antiCache=" + Date.now().toString()) | ||
.success(function (data, status, headers, config) { | ||
$scope.spec[storeProperty] = data; | ||
|
||
console.info("Downloading resource " + resource + " succeeded.", data); | ||
|
||
if (data.additionalResources) { | ||
angular.forEach(data.additionalResources, function (value, key) { | ||
downloadRecursive(maxAttempts, value, key); | ||
}); | ||
} | ||
}) | ||
.error(function (data, status, headers, config) { | ||
console.error("Downloading resource " + resource + " failed. Attempt " + (maxAttempts - attemptsLeft) + " of " + maxAttempts); | ||
|
||
downloadRecursive(attemptsLeft--, resource, storeProperty); | ||
}); | ||
} | ||
else { | ||
console.error("Downloading resource " + resource + " failed after " + maxAttempts + "attempts"); | ||
} | ||
} | ||
|
||
downloadRecursive(maxAttempts, primaryResource, primaryStoreProperty); | ||
|
||
|
||
} | ||
} | ||
]); | ||
.controller('BirdWalksCtrl', ['$scope', '$resource', '$routeParams', '$route', '$http', 'BirdWalkService', 'conf.paths', | ||
function BirdWalksCtrl($scope, $resource, $routeParams, $route, $http, BirdWalkService, paths) { | ||
// set up results | ||
$scope.results = { | ||
allowContact: true, | ||
consented: false, | ||
ethicsStatementViewed: false, | ||
pageHit: (new Date()).toISOString() | ||
}; | ||
|
||
$scope.imagesPath = paths.site.files.birdWalk.images; | ||
|
||
// download bird walk specification | ||
BirdWalkService.getUrl(paths.site.files.birdWalk.spec, 'birdWalkSpec', $scope); | ||
}]) | ||
.controller('BirdWalkCtrl', ['$scope', '$resource', '$routeParams', '$route', '$http', 'BirdWalkService', 'conf.paths', | ||
function BirdWalkCtrl($scope, $resource, $routeParams, $route, $http, BirdWalkService, paths) { | ||
$scope.imagesPath = paths.site.files.birdWalk.images; | ||
BirdWalkService.getUrl(paths.site.files.birdWalk.spec, 'birdWalkSpec', $scope); | ||
$scope.params = $routeParams; | ||
|
||
//$scope.spec.birdWalkSpec.walks | ||
}]); |
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
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
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