Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
Ce dépôt a été archivé le 2022-05-07. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
nyaa-pantsu/js/main.js
akuma06 11b22c82dd Rearranged static Files and add number of item per page
No CSS and Javascript in the index.html, more easy to maintain the design and the code.
Added a select for the number of item to show and added the new parameter to the SQL query.
Total number of item determined by the SQL query and not fixed.
2017-05-03 19:45:18 +02:00

30 lignes
Pas d'EOL
843 o
JavaScript

var pathArray = window.location.pathname.split( '/' );
var query = window.location.search;
var page = parseInt(pathArray[2]);
var pageString = "/page/";
var next = page + 1;
var prev = page - 1;
if (prev < 1) {
prev = 1;
}
if (isNaN(page)) {
next = 2;
prev = 1;
}
if (query != "") {
pageString = "/search/";
}
var maxId = 5;
for (var i = 0; i < maxId; i++) {
var el = document.getElementById('page-' + i), n = next + i;
el.href = pageString + n + query;
el.innerHTML = n;
}
document.getElementById('page-next').href = pageString + next + query;
document.getElementById('page-prev').href = pageString + prev + query;