-
Notifications
You must be signed in to change notification settings - Fork 0
/
call_picture_from_amazon.html
49 lines (44 loc) · 1.31 KB
/
call_picture_from_amazon.html
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
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<title>call_picture_from_amazon</title>
<script>
$(function(){
searchWord = function(){
var searchKeyword = encodeURI($(this).val());
if(searchKeyword.length === 0) return;
$.getJSON("http://kuje.kousakusyo.info/tools/iphone/anichecker/test/php2/call_picture_from_amazon.php?SearchIndex=All&Keyword=" + searchKeyword + "&SearchIndex=All").then(
function(json) {
if(json.Items.Item === undefined || json.Items.Item.length === undefined) {
setItem("noimage.png", "nodata");
} else {
if(json.Items.Item[0].LargeImage !== undefined) {
setItem(json.Items.Item[0].LargeImage.URL, json.Items.Item[0].ItemAttributes.Title);
} else {
setItem("noimage.png", json.Items.Item[0].ItemAttributes.Title);
}
}
}
);
}
$("#search").on("input", searchWord);
});
/**
* Set an image and title.
*
* @import image's url
* @import image's title
*/
function setItem(url, title) {
$("img#title").attr("src", url);
$("span#title").text(title);
}
</script>
</head>
<body>
<p>Keyword: <input type="text" id="search"></p>
<img src="noimage.png" id="title" /><br />
<p>Title: <span id="title">nodata</span></p>
</body>
</html>