adds first and last to control section
This commit is contained in:
10
src/main.js
10
src/main.js
@ -219,7 +219,7 @@ http.createServer((req, res) => {
|
||||
});
|
||||
}
|
||||
else if(Number.isInteger(parseInt(url))) { // itempage
|
||||
sql.query("select * from `f0ck`.`items` where `id` = ? limit 1; select `id` from `f0ck`.`items` where `id` = (select min(`id`) from `f0ck`.`items` where `id` > ?); select `id` from `f0ck`.`items` where `id` = (select max(`id`) from `f0ck`.`items` where `id` < ?)", [url, url, url], (err, rows, fields) => {
|
||||
sql.query("select * from `f0ck`.`items` where `id` = ? limit 1; select `id` from `f0ck`.`items` where `id` = (select min(`id`) from `f0ck`.`items` where `id` > ?); select `id` from `f0ck`.`items` where `id` = (select max(`id`) from `f0ck`.`items` where `id` < ?); select `id` from `f0ck`.`items` order by `id` asc limit 1; select `id` from `f0ck`.`items` order by `id` desc limit 1", [url, url, url], (err, rows, fields) => {
|
||||
var tpl = swig.compile(templates.item);
|
||||
var data = {
|
||||
id: '',
|
||||
@ -232,7 +232,9 @@ http.createServer((req, res) => {
|
||||
userchannel: '',
|
||||
usernetwork: '',
|
||||
next: null,
|
||||
prev: null
|
||||
prev: null,
|
||||
first: null,
|
||||
last: null
|
||||
};
|
||||
if(rows[0].length) {
|
||||
var e = rows[0][0];
|
||||
@ -264,6 +266,10 @@ http.createServer((req, res) => {
|
||||
data.next = rows[1][0].id;
|
||||
if(rows[2].length)
|
||||
data.prev = rows[2][0].id;
|
||||
if(rows[3].length)
|
||||
data.first = rows[3][0].id;
|
||||
if(rows[4].length)
|
||||
data.first = rows[4][0].id;
|
||||
}
|
||||
res.writeHead(200, { 'Content-Type': 'text/html' });
|
||||
res.end(tpl(data), 'utf-8');
|
||||
|
Reference in New Issue
Block a user