forked from hail2u/jquery.query-yql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
54 lines (46 loc) · 1.9 KB
/
test.html
File metadata and controls
54 lines (46 loc) · 1.9 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test page for Query YQL</title>
<link rel="stylesheet" href="http://hail2u.github.io/css/natural.css">
<!--[if lt IE 9]><script src="http://hail2u.github.io/js/html5shiv.min.js"></script><![endif]-->
</head>
<body>
<h1>Test page for Query YQL</h1>
<div id="content"></div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="jquery.query-yql.min.js"></script>
<script type="text/javascript">
$(function () {
var t = $('#content').empty();
var statement = 'select * from feed where url="http://hail2u.net/blog/feed"';
$.queryYQL(statement, function (data) {
$('<h2/>').text('Test: select * from feed').appendTo(t);
var r = data.query.results;
var ul = $('<ul/>');
$.each(r.item, function () {
$('<li/>').append(this.title).appendTo(ul);
});
ul.appendTo(t);
});
statement = 'select * from html where url="http://b.hatena.ne.jp/h2u/" and xpath="//h3[@class=\'entry-title\']/a[@class=\'entry-link\']"';
$.queryYQL(statement, 'xml', function (data) {
$('<h2/>').text('Test: select * from html').appendTo(t);
var ul = $('<ul/>');
$.each(data.results, function () {
$('<li/>').append($(this.toString()).text()).appendTo(ul);
});
ul.appendTo(t);
});
statement = 'select * from google.translate where q="This is a test." and target="ja"';
$.queryYQL(statement, 'all', function (data) {
$('<h2/>').text('Test: select * from google.translate').appendTo(t);
var p = $('<p/>');
var res = data.query.results.json.json[0].json.json;
p.append(res[1]).append(' -> ').append(res[0]).appendTo(t);
});
});
</script>
</body>
</html>