o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1374682063.094389: @value"À {I" class:EFI"ProcessedAsset;FI"logical_path;FI"Bcollection_json_browser/angular/controllers/api_controller.js;TI" pathname;FI"ƒ/Users/weilu/workspace/collection-json-browser/app/assets/javascripts/collection_json_browser/angular/controllers/api_controller.js;TI"content_type;FI"application/javascript;FI" mtime;FI"2013-07-25T00:07:40+08:00;FI" length;FiÞI" digest;F"%07882d2db3c0fb086fee0e408dd29bbbI" source;FI"Þ'use strict'; function ApiController($scope, $http, $location) { $scope.rootUrl = '/api' $scope.goTo = function(url, fromRel) { $scope.fromRel = fromRel $location.url(url) } $scope.submit = function() { $scope.fromRel === 'edit-form' ? put() : post() } $scope.$watch(function() { return $location.url() }, function(url, oldUrl) { if(url !== oldUrl) { get(url) } }) get($scope.rootUrl) // helpers function get(url) { $scope.loading = true $http.get(url).success(responseHandler).error(function(){ $scope.loading = false }) } function post() { $scope.loading = true $http.post($scope.collection.href, formData()). success(responseHandler). error(responseHandler) } function put() { $scope.loading = true $http.put($scope.collection.href, formData()). success(responseHandler). error(responseHandler) } function formData() { var data = {}; $scope.collection.template.data.forEach(function(f){ data[f.name] = f.value }) return data } function responseHandler(data, status) { $scope.collection = data.collection; $scope.raw = JSON.stringify(data, undefined, 2) $scope.status = status $scope.loading = false var collectionHref = $scope.collection.href if(collectionHref !== $location.path() && collectionHref.match(/^http/) === null) { $location.url(collectionHref) } } } ApiController.$inject = ['$scope', '$http', '$location']; ;FI"dependency_digest;F"%467e10bd389a015183fcb2c646a5bb7fI"required_paths;F[I"ƒ/Users/weilu/workspace/collection-json-browser/app/assets/javascripts/collection_json_browser/angular/controllers/api_controller.js;TI"dependency_paths;F[{I" path;FI"ƒ/Users/weilu/workspace/collection-json-browser/app/assets/javascripts/collection_json_browser/angular/controllers/api_controller.js;TI" mtime;FI"2013-07-25T00:07:40+08:00;FI" digest;F"%07882d2db3c0fb086fee0e408dd29bbbI" _version;F"%6776f581a4329e299531e1d52aa59832