-
Notifications
You must be signed in to change notification settings - Fork 1
/
js hack source_io
55 lines (49 loc) · 1.28 KB
/
js hack source_io
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
document.addEventListener("keydown", keyDownTextField, false);
function keyDownTextField(e) {
var keyCode = e.keyCode;
if(keyCode==17) {
get_img();
}
}
function get_img() {
var img = $('#tool-type').children().attr("src").substr(2);
var json = '{' +
' "requests": [ ' +
' { ' +
' "image": { ' +
' "source": {'+
' "imageUri":' + ' "http://s0urce.io' + img +'"' +
' }'+
' },'+
' "features": ['+
' {'+
'"type": "TEXT_DETECTION"'+
'}'+
' ],'+
'"imageContext": {'+
'"languageHints": ['+
'"en"'+
']'+
'}'+
'}'+
']'+
'}'
$.ajax({
type: 'POST',
url: "https://vision.googleapis.com/v1/images:annotate?key=" + 'AIzaSyByn5SDjUfbHPFziaDhRAmGVC1wWiATezM',
dataType: 'json',
data: json,
headers: {
"Content-Type": "application/json",
},
success: function(data, textStatus, jqXHR) {
console.log(data);
console.log(data.responses[0]["textAnnotations"][1]["description"]);
document.getElementById('tool-type-word').value = data.responses[0]["textAnnotations"][1]["description"];
//$('#tool-type-form').submit();
},
error: function(jqXHR, textStatus, errorThrown) {
console.log('ERRORS: ' + textStatus + ' ' + errorThrown);
}
});
}