1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| function updatePhoto(user,indexPhoto,publicCount){
var chain;
let imagePerPage = 50;
let position = (indexPhoto - 1) % (imagePerPage * 10);
let page = Math.trunc((indexPhoto - 1) / imagePerPage) + 1;
let pageMin = Math.trunc((page - 1) / 10) * 10 + 1;
let file2Load = "pages_" + pageMin + "_" + (pageMin + 9) + ".txt";
//console.log(file2Load);
let pageMax = Math.trunc((publicCount - 1) / imagePerPage) + 1;
if (pageMax <= (pageMin + 9) && pageMax >= pageMin && publicCount > (10 * imagePerPage))
{
var file2LoadMore = "pages_" + (pageMin - 10) + "_" + (pageMin - 1) + ".txt";
}
if (pageMin == 1 && publicCount > (10 * imagePerPage))
{
var file2LoadMore = "pages_" + (pageMin + 10) + "_" + (pageMin + 19) + ".txt";
}
if (pageMin > 1 && position < 250)
{
var file2LoadMore = "pages_" + (pageMin - 10) + "_" + (pageMin - 1) + ".txt";
}
if (pageMin > 1 && position >= 250)
{
var file2LoadMore = "pages_" + (pageMin + 10) + "_" + (pageMin + 19) + ".txt";
}
console.log(file2Load);
let result = getFile(file2Load);
console.log(result);
}
function getFile(file2Load) {
let url = "http://127.0.0.1/wp-content/data/upload_date/" + file2Load;
let xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200)
{
chain = (this.responseText);
return chain;
}
}
xhttp.open("GET", url, true);
xhttp.send();
} |
Partager