forked from ossforumjp-app-IoT/rubyiot_server
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclassify_image.haml
More file actions
39 lines (39 loc) · 1.3 KB
/
Copy pathclassify_image.haml
File metadata and controls
39 lines (39 loc) · 1.3 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
!!!
%haml{:lang => "ja"}
%head
%meta{:content => "width=device-width, initial-scale=1.0", :name => "viewport"}
%script{:type => "text/javascript", :src => "/js/jquery-1.11.1.min.js"}
:javascript
$(document).ready(function() {
var timestamp = 0;
var imageUpdate = function() {
$.ajax({
type: 'GET',
url : '/api/classify_image',
success: function(res) {
// 成功の場合の処理
var json = JSON.parse(res);
if (json.timestamp > timestamp) {
$("#image-panel img").attr("src", "/images/classify_image.jpg?t=" + Date.now())
$("#image_label").text(json.label);
$("#image_score").text(json.score);
timestamp = json.timestamp;
}
},
error: function (xhr, status, err) {
// 失敗の場合の処理
//alert(status);
}
});
setTimeout(imageUpdate, 1000);
};
imageUpdate();
});
%body
%h1 画像認識
%div{:id => "image-panel"}
%div{:class => "panel-title"}
%div{:class => "panel-body"}
%img{:src => "/images/classify_image.jpg"}
%div{:id => "image_label"}
%div{:id => "image_score"}