Simplify a little the JSON, a little more to do. re # 73

This commit is contained in:
Sébastien Lucas 2013-06-17 22:23:58 +02:00
parent 23267e37fa
commit 2029ab7d01
5 changed files with 37 additions and 24 deletions

View file

@ -311,8 +311,6 @@ class EntryBook extends Entry
public function getContentArray () { public function getContentArray () {
$entry = array ( "title" => $this->title); $entry = array ( "title" => $this->title);
$entry ["coverurl"] = $this->getCover ();
$entry ["thumbnailurl"] = $this->getCoverThumbnail ();
$entry ["book"] = $this->book->getContentArray (); $entry ["book"] = $this->book->getContentArray ();
return $entry; return $entry;
} }

View file

@ -126,9 +126,9 @@ class Book extends Base {
$su = $link->hrefXhtml (); $su = $link->hrefXhtml ();
} }
return array ("hasCover" => $this->hasCover, return array ("id" => $this->id,
"hasCover" => $this->hasCover,
"preferedData" => $preferedData, "preferedData" => $preferedData,
"detailUrl" => $this->getDetailUrl (),
"rating" => $this->getRating (), "rating" => $this->getRating (),
"pubDate" => $this->getPubDate (), "pubDate" => $this->getPubDate (),
"languagesName" => $this->getLanguages (), "languagesName" => $this->getLanguages (),

View file

@ -73,7 +73,11 @@
"languagesTitle" => localize("language.title"), "languagesTitle" => localize("language.title"),
"contentTitle" => localize("content.summary"), "contentTitle" => localize("content.summary"),
"sortorderAsc" => localize("search.sortorder.asc"), "sortorderAsc" => localize("search.sortorder.asc"),
"sortorderDesc" => localize("search.sortorder.desc"))); "sortorderDesc" => localize("search.sortorder.desc")),
"url" => array (
"detailUrl" => "index.php?page=13&id={0}&db={1}",
"coverUrl" => "fetch.php?id={0}&db={1}",
"thumbnailUrl" => "fetch.php?height=70&id={0}&db={1}"));
} }
$out ["containsBook"] = 0; $out ["containsBook"] = 0;

View file

@ -16,7 +16,9 @@
<article class="books"> <article class="books">
<span class="cover"> <span class="cover">
{{? entry.book.hasCover == 1}} {{? entry.book.hasCover == 1}}
<a data-fancybox-group="group" class="fancycover" href="{{=entry.coverurl}}"><img src="{{=entry.thumbnailurl}}" alt="{{=it.const.i18n.coverAlt}}" /></a> <a data-fancybox-group="group" class="fancycover" href="{{=strformat (it.const.url.coverUrl, entry.book.id, it.databaseId)}}">
<img src="{{=strformat (it.const.url.thumbnailUrl, entry.book.id, it.databaseId)}}" alt="{{=it.const.i18n.coverAlt}}" />
</a>
{{?}} {{?}}
</span> </span>
<h2 class="download"> <h2 class="download">
@ -24,7 +26,7 @@
<a href="{{=data.url}}">{{=data.name}}</a><br /> <a href="{{=data.url}}">{{=data.name}}</a><br />
{{~}} {{~}}
</h2> </h2>
<a class="fancydetail" href="{{=entry.book.detailUrl}}"> <a class="fancydetail" href="{{=strformat (it.const.url.detailUrl, entry.book.id, it.databaseId)}}">
<div class="fullclickpopup"> <div class="fullclickpopup">
<h2><span class="st">{{=htmlEscape (entry.title)}}</span> <h2><span class="st">{{=htmlEscape (entry.title)}}</span>
{{? entry.book.pubDate != ""}}<span class="sp">({{=entry.book.pubDate}})</span>{{?}} {{? entry.book.pubDate != ""}}<span class="sp">({{=entry.book.pubDate}})</span>{{?}}

View file

@ -14,6 +14,15 @@ function fancyBoxObject (title, type) {
return out; return out;
} }
function strformat () {
var s = arguments[0];
for (var i = 0; i < arguments.length - 1; i++) {
var reg = new RegExp("\\{" + i + "\\}", "gm");
s = s.replace(reg, arguments[i + 1]);
}
return s;
}
function getCurrentOption (option) { function getCurrentOption (option) {
return $.cookie (option); return $.cookie (option);
} }