forked from sarunyou/ProjectSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontroller.js
More file actions
51 lines (44 loc) · 1.5 KB
/
controller.js
File metadata and controls
51 lines (44 loc) · 1.5 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
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http) {
$scope.message = "";
var webSerLink = "http://52.221.229.107:8080/search?q=";
$scope.hover = function(index, notEmpty) {
if (notEmpty) {
$scope.selectedIndex = index;
}
}
$scope.leave = function() {
$scope.selectedIndex = -1;
}
$scope.addExample = function() {
$scope.message += "PART ONE\nHello World, !!!\nred, or a glistening apparition of black showed where the unintended\nGood morning, John.\n";
}
$scope.tryAgain = function() {
window.location.reload();
}
$scope.search = function() {
$scope.loading = true;
var res = encodeURI($scope.message);
// var res = encodeURI("s\nLanguage: english\nLanguage: English");
res = res.replace(/%0A/g, "%5Cn");
$http({
method: "GET",
url: webSerLink + res,
dataType: 'jsonp',
crossDomain: true
}).then(function mySucces(response) {
$scope.loading = false;
console.log("looking for " + $scope.message + " with " + webSerLink + res);
$scope.result = response.data;
$scope.done = true;
}, function myError(response) {
$scope.result = response.statusText;
});
}
});
app.filter('startFrom', function() {
return function(input, start) {
start = +start; //parse to int
return input.slice(start);
}
});