You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.4 KiB

  1. 'use strict';
  2. angular.module('app.id', ['ngRoute'])
  3. .config(['$routeProvider', function($routeProvider) {
  4. $routeProvider.when('/id/:keyid', {
  5. templateUrl: 'views/id/id.html',
  6. controller: 'IdCtrl'
  7. });
  8. }])
  9. .controller('IdCtrl', function($scope, $rootScope, $http, $routeParams) {
  10. $scope.keyid = $routeParams.keyid;
  11. $scope.decryptData = {
  12. m:"",
  13. c:""
  14. };
  15. $scope.encryptData = {
  16. m:"",
  17. c:""
  18. };
  19. $rootScope.server = JSON.parse(localStorage.getItem("old_darkID_server"));
  20. $scope.id = {};
  21. $scope.clientApp = function(route, param) {
  22. $http.get(clientapi + route + '/' + param)
  23. .then(function(data) {
  24. console.log('data success');
  25. console.log(data);
  26. $scope.id = data.data;
  27. }, function(data) {
  28. console.log('data error');
  29. });
  30. };
  31. $scope.clientApp('id', $routeParams.keyid);
  32. $scope.decrypt = function() {
  33. $http({
  34. url: clientapi + 'decrypt/' + $routeParams.keyid,
  35. method: "POST",
  36. headers: {
  37. "Content-Type": undefined
  38. },
  39. data: $scope.decryptData
  40. })
  41. .then(function(data) {
  42. console.log("data: ");
  43. console.log(data.data);
  44. $scope.decryptData = data.data;
  45. },
  46. function(data) {
  47. console.log(data);
  48. });
  49. };
  50. $scope.encrypt = function() {
  51. $http({
  52. url: clientapi + 'encrypt/' + $routeParams.keyid,
  53. method: "POST",
  54. headers: {
  55. "Content-Type": undefined
  56. },
  57. data: $scope.encryptData
  58. })
  59. .then(function(data) {
  60. console.log("data: ");
  61. console.log(data.data);
  62. $scope.encryptData = data.data;
  63. },
  64. function(data) {
  65. console.log(data);
  66. });
  67. };
  68. });