-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
79 lines (62 loc) · 2.26 KB
/
app.js
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
(function () {
'use strict';
angular
.module('inputform', ['ngMaterial'])
.controller('DemoCtrl', DemoCtrl);
function DemoCtrl ($timeout, $q, $log, $http) {
var self = this;
self.simulateQuery = false;
self.isDisabled = false;
self.querySearch = querySearch;
self.selectedItemChange = selectedItemChange;
self.searchTextChange = searchTextChange;
self.focus = focus;
function querySearch (query) {
if(query.trim() === '') return;
var deferred = $q.defer();
$.ajax({
type : 'GET',
url : 'http://127.0.0.1:8081/autocomplete/'+ $("#getquote input").val(),
success :function(data){
console.log("autocomplete return result is: "+data);
data = data.map(function (t) {
return t["Symbol"] + " - " + t["Name"] + " (" + t["Exchange"] + ")";
})
deferred.resolve(data);
}
})
return deferred.promise;
$http.get(url)
.then(function (res) {
var data = res.data;
data = data.map(function (t) {
return t["Symbol"] + " - " + t["Name"] + " (" + t["Exchange"] + ")";
})
deferred.resolve(data);
})
// return deferred.promise;
}
function searchTextChange(text) {
$log.info('Text changed to ' + text);
if(text.trim() !== '') {
$('#submitb').prop('disabled', false);
$('#hint').css("visibility", "hidden");
$('md-autocomplete-wrap').css('border', '');
}
else {
$('#submitb').prop('disabled', true);
$('#hint').css("visibility", "visible");
$('md-autocomplete-wrap').css('border', '2px solid blue');
}
}
function selectedItemChange(item) {
$log.info('Item changed to ' + item);
$log.info(item.split('-')[0].trim());
$('#getquote input').val(item.split('-')[0].trim());
}
function focus() {
console.log("is focused");
$('md-autocomplete-wrap').css('border', '2px solid blue');
}
}
})();