184
edits
m (JP, pls fix. Adding this broke tooltips) |
(ok epyon, this should have fixed it) |
||
Line 29: | Line 29: | ||
// Hide the stupid empty newlines after crafting grids | // Hide the stupid empty newlines after crafting grids | ||
$('.crafting + p br:only-child').parent().hide(); | $('.crafting + p br:only-child').parent().hide(); | ||
let active = $('.pageactive'); | |||
active.each((_, page) => { | |||
setupPage($(page)) | |||
}); | |||
$('.book_leftarrow').click(function() { | |||
let active = $(this).siblings('.pageactive'); | |||
active.removeClass('pageactive'); | |||
active = active.prev() | |||
setupPage(active); | |||
}); | |||
$('.book_rightarrow').click(function() { | |||
let active = $(this).siblings('.pageactive'); | |||
active.removeClass('pageactive'); | |||
active = active.next() | |||
setupPage(active); | |||
}); | |||
}); | }); | ||
Line 51: | Line 71: | ||
} | } | ||
return res + "</span>".repeat(spans); | return res + "</span>".repeat(spans); | ||
} | |||
function setupPage(active) { | |||
active.addClass('pageactive'); | |||
let index = active.index(); | |||
let length = (active.siblings().length - 2); | |||
active.siblings('.book_pagenum').text('Page ' + index + ' of ' + length); | |||
active.siblings('.book_leftarrow, .book_rightarrow').show() | |||
if (index == 1) { | |||
active.siblings('.book_leftarrow').hide() | |||
} | |||
if (index == length) { | |||
active.siblings('.book_rightarrow').hide() | |||
} | |||
} | } |