-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.js
34 lines (28 loc) · 799 Bytes
/
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
const agent = require('./ClarifaiAPI.js');
$input = $('<div>').addClass('input');
$output = $('<div>').addClass('output');
$img = $('<img>').addClass('image');
$file = $('<input>').attr('type', 'file');
$('body').append($input);
$('body').append($output);
$input.append($img);
$input.append($file);
$file.on('change', (event) => {
var file = event.target.files[0];
var reader = new FileReader();
reader.onload = () => {
$img.attr('src', reader.result);
}
reader.readAsDataURL(file);
agent.getBase64(file)
.then(data => {
console.log('data', data);
$output.empty();
data.forEach(info => tag(info));
});
});
var tag = (obj) => {
var newTag = $('<div>').addClass('tag');
newTag.text(`${obj.name}: ${obj.value}`);
$output.append(newTag);
};