-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
52 lines (46 loc) · 2.02 KB
/
app.js
File metadata and controls
52 lines (46 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
(function() {
var app = angular.module('caesar', ['chart.js']);
app.controller('CryptController', ['$http', function($http) {
var tmp=this;
tmp.shift='';
tmp.result='';
tmp.guessresult='';
tmp.frequency =[];
tmp.labels=[];
this.encrypt=function(newValue){ //Фунция шифровки сообщения
$http.post("/encrypt.php", newValue,{'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'}).success(function (data, status, headers, config) {
tmp.result=data.result;
})
.error(function (data, status, header, config) {
alert("error");
});
};
this.decrypt=function(newValue){ //Фунция расшифровки сообщения
$http.post("/decrypt.php", newValue,{'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'}).success(function (data, status, headers, config) {
tmp.result=data.result;
})
.error(function (data, status, header, config) {
alert("error");
});
};
this.chart=function(newValue){ //Фунция считающаяя вхождения каждого символа
tmp.frequency=[[]];
$http.post("/frequency.php", newValue,{'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'}).success(function (data, status, headers, config) {
tmp.frequency[0]=data.frequency;
tmp.labels=data.labels;
})
.error(function (data, status, header, config) {
alert("error");
});
};
this.guess=function(newValue){ //Фунция определяющая сдвиг и на его основе расшифровывает сообщение
$http.post("/guess.php", newValue,{'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'}).success(function (data, status, headers, config) {
tmp.guessresult=data.result;
tmp.guessShift=data.shift;
})
.error(function (data, status, header, config) {
alert("error");
});
};
}]);
})();