Revision 237174 of Template:autoPreviousNext

  • Revision slug: Template:autoPreviousNext
  • Revision title: Template:autoPreviousNext
  • Revision id: 237174
  • Created:
  • Creator: lmorchard
  • Is current revision? No
  • Comment
Tags: 

Revision Content

<%
var prevStr = {
  "en-US": "Previous",
  de: "zurück",
  es: "Anterior",
  fr: "Précédent",
  ja: "前",
  ko: "이전",
  pl: "Poprzedni",
  ru: "Предыдущая статья",
  "zh-TW": "前頁",
  "zh-CN": "上一页",
  cn: "上一页"
};
var nextStr = {
  "en-US": "Next",
  de: "weiter",
  es: "Siguiente",
  fr: "Suivant",
  ja: "次",
  ko: "다음",
  pl: "Następny",
  ru: "Следующая статья",
  "zh-TW": "次頁",
  "zh-CN": "下一页",
  cn: "下一页"
};
var chapterList = string.deserialize(template($0));
var i = typeof $1 === 'string' ?
    list.indexOf(chapterList, xml.text(getRelativeURL($1))) :
    list.indexOf(chapterList, xml.text(getRelativeURL(page.uri)));

if (i != -1){
  var html;
  switch (i){
    case 0:
      html = '

'+ web.link(chapterList[1], mdn.localString(nextStr) + " »", wiki.getPage(chapterList[1]).title) +'

';       break;     case chapterList.length - 1:       html = '

'+ web.link(chapterList[(chapterList.length) - 2], "« " + mdn.localString(prevStr), wiki.getPage(chapterList[(chapterList.length) - 2]).title) +'

';       break;     default: /* This should be done like

PreviousNext

but Internet Explorer 8 doesn't render it properly */       html = '

'+       web.link(chapterList[i - 1], "« " + localString(prevStr), wiki.getPage(chapterList[i - 1]).title)+       ''+       web.link(chapterList[i + 1], localString(nextStr) + " »", wiki.getPage(chapterList[i + 1]).title)+       '

';   } } %> <%- html %>

Revision Source

<div> <pre class="script" style="font-size: 16px; clear: both;">
<%
var prevStr = {
  "en-US": "Previous",
  de: "zurück",
  es: "Anterior",
  fr: "Précédent",
  ja: "前",
  ko: "이전",
  pl: "Poprzedni",
  ru: "Предыдущая статья",
  "zh-TW": "前頁",
  "zh-CN": "上一页",
  cn: "上一页"
};
var nextStr = {
  "en-US": "Next",
  de: "weiter",
  es: "Siguiente",
  fr: "Suivant",
  ja: "次",
  ko: "다음",
  pl: "Następny",
  ru: "Следующая статья",
  "zh-TW": "次頁",
  "zh-CN": "下一页",
  cn: "下一页"
};
var chapterList = string.deserialize(template($0));
var i = typeof $1 === 'string' ?
    list.indexOf(chapterList, xml.text(getRelativeURL($1))) :
    list.indexOf(chapterList, xml.text(getRelativeURL(page.uri)));

if (i != -1){
  var html;
  switch (i){
    case 0:
      html = '<p style="text-align: right;">'+ web.link(chapterList[1], mdn.localString(nextStr) + " »", wiki.getPage(chapterList[1]).title) +'</p>';
      break;
    case chapterList.length - 1:
      html = '<p>'+ web.link(chapterList[(chapterList.length) - 2], "« " + mdn.localString(prevStr), wiki.getPage(chapterList[(chapterList.length) - 2]).title) +'</p>';
      break;
    default:
      /* This should be done like <p>Previous<span style="float: right;">Next</span></p>
         but Internet Explorer 8 doesn't render it properly */
      html = '<p style="text-align: right;"><span style="float: left;">'+
        web.link(chapterList[i - 1], "« " + localString(prevStr), wiki.getPage(chapterList[i - 1]).title)+
        '</span>'+
        web.link(chapterList[i + 1], localString(nextStr) + " »", wiki.getPage(chapterList[i + 1]).title)+
        '</p>';
  }
}
%>
<%- html %>
</pre>
</div>