Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
douban-api-proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
douban-api-proxy
Commits
2f1fdab9
Commit
2f1fdab9
authored
Feb 24, 2017
by
idalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
delete douban_meta.js in master.(This is for Chinese user only)
parent
41a20fe3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
87 deletions
+0
-87
douban_meta.js
cps/static/js/douban_meta.js
+0
-87
No files found.
cps/static/js/douban_meta.js
deleted
100644 → 0
View file @
41a20fe3
/*
* Get Metadata from Douban api
* Created by idalin<dalin.lin@gmail.com>
*/
$
(
document
).
ready
(
function
()
{
var
get_meta_btn
=
'<li>'
+
'<a href="#" id="get_meta" data-toggle="modal" data-target="#metaModal">'
+
'获取Meta</a></li>'
;
$
(
'#main-nav'
).
prepend
(
get_meta_btn
);
var
douban
=
'https://api.douban.com'
;
var
search
=
'/v2/book/search'
;
var
get_info
=
'/v2/book/'
;
var
get_info_by_isbn
=
'/v2/book/isbn/ '
;
$
.
ajaxSetup
({
type
:
"GET"
,
dataType
:
"jsonp"
,
jsonp
:
'callback'
,
async
:
false
});
get_meta
=
function
(
id
)
{
var
url
=
douban
+
get_info
+
id
;
console
.
log
(
'getting book meta:'
+
id
);
$
.
ajax
({
url
:
url
,
success
:
function
(
meta
)
{
console
.
log
(
meta
);
//$('#metaModal').modal('hide');
$
(
'#description'
).
val
(
meta
.
summary
);
$
(
'#bookAuthor'
).
val
(
meta
.
author
.
join
(
' & '
));
$
(
'#book_title'
).
val
(
meta
.
title
);
var
tags
=
''
;
for
(
var
i
=
0
;
i
<
meta
.
tags
.
length
;
i
++
)
{
tags
=
tags
+
meta
.
tags
[
i
].
title
+
','
;
}
$
(
'#tags'
).
val
(
tags
);
$
(
'#rating'
).
val
(
Math
.
round
(
meta
.
rating
.
average
/
4
));
}
});
}
get_meta_by_isbn
=
function
(
isbn
)
{
var
url
=
douban
+
get_info_by_isbn
+
isbn
;
}
search_book
=
function
(
title
)
{
var
url
=
douban
+
search
+
'?q='
+
title
+
'&fields=id,title,author,publisher,isbn13,image,summary'
;
$
.
ajax
({
url
:
url
,
success
:
function
(
data
)
{
if
(
data
.
books
.
length
<
1
)
{
$
(
'#meta-info'
).
html
(
'<p class="text-danger">搜索不到对应的书籍</p>'
);
}
else
{
$
(
'#meta-info'
).
html
(
'<ul id="book-list" class="media-list"></ul>'
);
for
(
var
i
=
0
;
i
<
data
.
books
.
length
;
i
++
)
{
var
book
=
'<li class="media">'
+
'<img class="pull-left img-responsive" data-toggle="modal" data-target="#metaModal" src="'
+
data
.
books
[
i
].
image
+
'" alt="Cover" onclick="javascript:get_meta('
+
data
.
books
[
i
].
id
+
')">'
+
'<div class="media-body">'
+
'<h4 class="media-heading"><a href="https://book.douban.com/subject/'
+
data
.
books
[
i
].
id
+
'" target="_blank">'
+
data
.
books
[
i
].
title
+
'</a></h4>'
+
'<p>作者:'
+
data
.
books
[
i
].
author
+
'</p>'
+
'<p>出版社:'
+
data
.
books
[
i
].
publisher
+
'</p>'
+
'<p>简介:'
+
data
.
books
[
i
].
summary
+
'</p>'
+
'</div>'
+
'</li>'
;
$
(
"#book-list"
).
append
(
book
);
}
}
},
error
:
function
()
{
$
(
'#meta-info'
).
html
(
'<p class="text-danger">搜索出错</p>'
);
}
});
}
$
(
'#get_meta'
).
click
(
function
()
{
var
book_title
=
$
(
'#book_title'
).
val
();
if
(
book_title
)
{
// console.log(book_title);
search_book
(
book_title
);
}
});
});
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment