Sha256: 9f20afa39dad1254b30a7aef33130cf015791339f67fcc57c070536c22914644
Contents?: true
Size: 1.99 KB
Versions: 2
Compression:
Stored size: 1.99 KB
Contents
var app; var app = angular.module('yopass', ['ngRoute']); app.controller('createController', function($scope, $http, $location) { $scope.save = function(s) { $http.post('/v1/secret', {secret: s.secret, lifetime: s.lifetime}) .success(function(data, status, headers, config) { $scope.error = false; var base_url = window.location.protocol+"//"+window.location.host+"/#/s/"; $scope.full_url = base_url+data.key+"/"+data.decryption_key; $scope.secret = null; //clear secret on success $scope.short_url = base_url+data.key; $scope.decryption_key = data.decryption_key; }) .error(function(data, status, headers, config) { $scope.error = data.message }); }; }); app.controller('ViewController', function($scope, $routeParams, $http) { function getSecret($key, $decryption_key) { $http.get('/v1/secret/'+$routeParams.key+'/'+$decryption_key) .success(function(data, status, headers, config) { $scope.error = false; $scope.invalidPassword = false; $scope.secret = data.secret }) .error(function(data, status, headers, config) { if(status == 401) { $scope.invalidPassword = true; return; } $scope.invalidPassword = false; $scope.error = data.message }); }; if ($routeParams.decryption_key) { getSecret($routeParams.key,$routeParams.decryption_key); } else { $scope.display_form = true; $scope.view = function(form) { getSecret($routeParams.key, form.decryption_key); }; }; }); app.config(function($routeProvider, $locationProvider) { $routeProvider .when('/s/:key/:decryption_key', { templateUrl: 'display-secret.html', controller: 'ViewController', }) .when('/s/:key', { templateUrl: 'display-secret.html', controller: 'ViewController', }) .when('/create', { templateUrl: 'create-secret.html', controller: 'createController' }) .otherwise({ redirectTo: '/create' }); });
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
yopass-3.0.1 | lib/public/js/app.js |
yopass-3.0.0 | lib/public/js/app.js |