8 changed files with 68 additions and 68 deletions
@ -1,35 +1,69 @@ |
|||||
<book> |
<book> |
||||
<div class="text-clip toast" if={ opts.title && opts.author }> |
<div class="text-clip toast"> |
||||
<p> |
<p> |
||||
<dt class="book-title text-center"> |
<dt class="book-title text-center"> |
||||
<button onclick={ makeResourceGetter(this) } class="btn btn-link"> |
<button onclick={getresources} class="btn btn-link"> |
||||
{ opts.title } |
{ title } |
||||
</button> |
</button> |
||||
</dt> |
</dt> |
||||
<dd> |
<dd> |
||||
<div if={ loading } class="loading"> |
<div if={ loading } class="loading"> |
||||
</div> |
</div> |
||||
<p if={ iarchive }> |
<p if={ this.iarchive }> |
||||
<a target="_blank" href="{ iarchive }"> |
<a target="_blank" href="{ iarchive }"> |
||||
<button class="centered btn btn-link"> |
<button class="centered btn btn-link"> |
||||
Internet Archive Result |
Internet Archive Result |
||||
</button> |
</button> |
||||
</a> |
</a> |
||||
</p> |
</p> |
||||
<p if={ openlib }> |
<p if={ this.openlib }> |
||||
<a target="_blank" href="{ openlib }"> |
<a target="_blank" href="{ openlib }"> |
||||
<button class="centered btn btn-link"> |
<button class="centered btn btn-link"> |
||||
Open Library Result |
Open Library Result |
||||
</button> |
</button> |
||||
</a> |
</a> |
||||
</p> |
</p> |
||||
<p class="centered wraptext" if={ noResources }> |
<p class="centered wraptext" if={ noresources }> |
||||
Couldn't find anything, sorry :( |
Couldn't find anything, sorry :( |
||||
</p> |
</p> |
||||
</dd> |
</dd> |
||||
</p> |
</p> |
||||
</div> |
</div> |
||||
|
<script> |
||||
this.iarchive = false; |
this.iarchive = false; |
||||
this.openlib = false; |
this.openlib = false; |
||||
this.noResources = false; |
this.noresources = false; |
||||
|
|
||||
|
var self = this; |
||||
|
|
||||
|
getresources() { |
||||
|
self.loading = true; |
||||
|
self.update(); |
||||
|
var params = { |
||||
|
"title" : this.booktitle, |
||||
|
"author" : this.bookauthor |
||||
|
}; |
||||
|
var url = "/search/resources"; |
||||
|
|
||||
|
$.getJSON(url, { |
||||
|
data : encodeURIComponent(JSON.stringify(params)) |
||||
|
}).done(function(results) { |
||||
|
if (results.iarchive) { |
||||
|
self.iarchive = results.iarchive[0]; |
||||
|
} |
||||
|
|
||||
|
if (results.openlib) { |
||||
|
self.openlib = results.openlib[0]; |
||||
|
} |
||||
|
|
||||
|
if (!(results.openlib && results.iarchive)) { |
||||
|
self.noresources = true; |
||||
|
} |
||||
|
|
||||
|
self.update({"loading" : false}); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
</script> |
||||
</book> |
</book> |
||||
|
Loading…
Reference in new issue