Update some of the javascripts methods to use a PHP name to ease server side rendering.

This commit is contained in:
Sébastien Lucas 2013-08-22 15:12:04 +02:00
parent 9236bc301d
commit 9ff4bd2476
3 changed files with 15 additions and 15 deletions

View file

@ -15,24 +15,24 @@
<br /> <br />
{{~}} {{~}}
</h2> </h2>
<h1><a title="{{=it.const.i18n.permalinkAlt}}" rel="bookmark" href="{{=strformat (it.const.url.detailUrl, it.book.id, it.databaseId)}}"><i class="icon-link"></i></a>{{=htmlEscape (it.title)}}</h1> <h1><a title="{{=it.const.i18n.permalinkAlt}}" rel="bookmark" href="{{=str_format (it.const.url.detailUrl, it.book.id, it.databaseId)}}"><i class="icon-link"></i></a>{{=htmlspecialchars (it.title)}}</h1>
<p class="popupless"> <p class="popupless">
<h3>{{=it.const.i18n.authorsTitle}}: </h3> <h3>{{=it.const.i18n.authorsTitle}}: </h3>
{{~it.book.authors:author:i}} {{~it.book.authors:author:i}}
{{? i > 0}}, {{?}}<a href="{{=author.url}}">{{=htmlEscape (author.name)}}</a> {{? i > 0}}, {{?}}<a href="{{=author.url}}">{{=htmlspecialchars (author.name)}}</a>
{{~}} {{~}}
</p> </p>
{{? it.book.tagsName != ""}} {{? it.book.tagsName != ""}}
<p class="popupless"> <p class="popupless">
<h3>{{=it.const.i18n.tagsTitle}}: </h3> <h3>{{=it.const.i18n.tagsTitle}}: </h3>
{{~it.book.tags:tag:i}} {{~it.book.tags:tag:i}}
{{? i > 0}}, {{?}}<a href="{{=tag.url}}">{{=htmlEscape (tag.name)}}</a> {{? i > 0}}, {{?}}<a href="{{=tag.url}}">{{=htmlspecialchars (tag.name)}}</a>
{{~}} {{~}}
</p> </p>
{{?}} {{?}}
{{? it.book.seriesName != ""}} {{? it.book.seriesName != ""}}
<p class="popupless"> <p class="popupless">
<h3><a href="{{=it.book.seriesurl}}">{{=it.const.i18n.seriesTitle}}</a> : </h3>{{=htmlEscape (it.book.seriesCompleteName)}} <h3><a href="{{=it.book.seriesurl}}">{{=it.const.i18n.seriesTitle}}</a> : </h3>{{=htmlspecialchars (it.book.seriesCompleteName)}}
</p> </p>
{{?}} {{?}}
{{? it.book.pubDate != ""}} {{? it.book.pubDate != ""}}

View file

@ -11,7 +11,7 @@
<article> <article>
<div class="frontpage"> <div class="frontpage">
{{? entry.navlink != "#"}}<a href="{{=entry.navlink}}">{{?}} {{? entry.navlink != "#"}}<a href="{{=entry.navlink}}">{{?}}
<h2>{{=htmlEscape (entry.title)}}</h2> <h2>{{=htmlspecialchars (entry.title)}}</h2>
<h4>{{=entry.content}}</h4> <h4>{{=entry.content}}</h4>
{{? entry.navlink != "#"}}</a>{{?}} {{? entry.navlink != "#"}}</a>{{?}}
</div> </div>
@ -20,8 +20,8 @@
<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="{{=strformat (it.const.url.coverUrl, entry.book.id, it.databaseId)}}"> <a data-fancybox-group="group" class="fancycover" href="{{=str_format (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}}" /> <img src="{{=str_format (it.const.url.thumbnailUrl, entry.book.id, it.databaseId)}}" alt="{{=it.const.i18n.coverAlt}}" />
</a> </a>
{{?}} {{?}}
</span> </span>
@ -30,15 +30,15 @@
<a href="{{=data.url}}">{{=data.name}}</a><br /> <a href="{{=data.url}}">{{=data.name}}</a><br />
{{~}} {{~}}
</h2> </h2>
<a class="fancydetail" href="{{=strformat (it.const.url.detailUrl, entry.book.id, it.databaseId)}}"> <a class="fancydetail" href="{{=str_format (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">{{=htmlspecialchars (entry.title)}}</span>
{{? entry.book.pubDate != ""}}<span class="sp">({{=entry.book.pubDate}})</span>{{?}} {{? entry.book.pubDate != ""}}<span class="sp">({{=entry.book.pubDate}})</span>{{?}}
{{? entry.book.rating != ""}}<span class="sr">{{=entry.book.rating}}</span>{{?}} {{? entry.book.rating != ""}}<span class="sr">{{=entry.book.rating}}</span>{{?}}
</h2> </h2>
<h4>{{=it.const.i18n.authorsTitle}} : </h4><span class="sa">{{=htmlEscape (entry.book.authorsName)}}</span><br /> <h4>{{=it.const.i18n.authorsTitle}} : </h4><span class="sa">{{=htmlspecialchars (entry.book.authorsName)}}</span><br />
{{? entry.book.tagsName != ""}}<h4>{{=it.const.i18n.tagsTitle}} : </h4><span class="se">{{=htmlEscape (entry.book.tagsName)}}</span><br />{{?}} {{? entry.book.tagsName != ""}}<h4>{{=it.const.i18n.tagsTitle}} : </h4><span class="se">{{=htmlspecialchars (entry.book.tagsName)}}</span><br />{{?}}
{{? entry.book.seriesName != ""}}<h4>{{=it.const.i18n.seriesTitle}} : </h4><span class="ss">{{=htmlEscape (entry.book.seriesName)}} ({{=entry.book.seriesIndex}})</span><br />{{?}} {{? entry.book.seriesName != ""}}<h4>{{=it.const.i18n.seriesTitle}} : </h4><span class="ss">{{=htmlspecialchars (entry.book.seriesName)}} ({{=entry.book.seriesIndex}})</span><br />{{?}}
</div></a> </div></a>
</article> </article>
{{?}} {{?}}

View file

@ -69,7 +69,7 @@ function sendToMailAddress (component, dataid) {
$.ajax ({'url': url, 'type': 'post', 'data': { 'data': dataid, 'email': email }, 'success': retourMail}); $.ajax ({'url': url, 'type': 'post', 'data': { 'data': dataid, 'email': email }, 'success': retourMail});
} }
function strformat () { function str_format () {
var s = arguments[0]; var s = arguments[0];
for (var i = 0; i < arguments.length - 1; i++) { for (var i = 0; i < arguments.length - 1; i++) {
var reg = new RegExp("\\{" + i + "\\}", "gm"); var reg = new RegExp("\\{" + i + "\\}", "gm");
@ -92,7 +92,7 @@ function getCurrentOption (option) {
return $.cookie (option); return $.cookie (option);
} }
function htmlEscape(str) { function htmlspecialchars(str) {
return String(str) return String(str)
.replace(/&/g, '&amp;') .replace(/&/g, '&amp;')
.replace(/"/g, '&quot;') .replace(/"/g, '&quot;')
@ -346,7 +346,7 @@ function search_Submitted (event) {
return; return;
} }
event.preventDefault(); event.preventDefault();
var url = strformat ("index.php?page=9&current={0}&query={1}&db={2}", currentData.page, $("input[name=query]").val (), currentData.databaseId); var url = str_format ("index.php?page=9&current={0}&query={1}&db={2}", currentData.page, $("input[name=query]").val (), currentData.databaseId);
navigateTo (url); navigateTo (url);
} }