Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Commit faead4e

Browse files
committed
Initial commit
0 parents  commit faead4e

File tree

5 files changed

+764
-0
lines changed

5 files changed

+764
-0
lines changed

js/apps.js

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
define(["jquery","mustache"], function($,mustache) {
2+
var url_base = "http://reader.livedoor.com";
3+
var auth_url = url_base + "/apps/authorize";
4+
var conn = new LDR.Connect(auth_url);
5+
6+
$("#authorize_button").click(function(){
7+
if (conn.authorized()){
8+
console.log("You've authorized.");
9+
} else {
10+
conn.authorize({
11+
client_id: location.href,
12+
name: "api test",
13+
expires_in: 3600 * 3
14+
});
15+
}
16+
});
17+
18+
$("#clear_button").click(function(){
19+
conn.token = null;
20+
conn.token_store.clear();
21+
});
22+
23+
var compiledTemplate = mustache.compile($('#tpl').html());
24+
$("article.api").each(function(){
25+
var api_url = $(this).find("h3").text();
26+
// api definition
27+
var params = $(this).find(".parameters");
28+
if (params) {
29+
var definition = '{"params":' + params.text() + '}';
30+
$(this).append(compiledTemplate($.parseJSON(definition.replace(/"/ig,'"'))));
31+
var api_name = api_url.replace(/\//ig,'_');
32+
$(this).attr("name", api_name);
33+
// api post
34+
var apiForm = $(this).find('form[name="apiForm"]');
35+
$(this).find('input[name="post"]').click(function(){
36+
var callback = function(res){
37+
$('article.api[name="' + api_name + '"]').find(".result").html("<pre>"+JSON.stringify(res, null, 4) + "</pre>");
38+
};
39+
var errback = callback;
40+
conn.request("POST", api_url + "?" + $(apiForm).serialize(), {}, callback, errback);
41+
});
42+
}
43+
});
44+
});

js/libs/jquery-1.9.1.min.js

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)