mirror of
https://github.com/hkalexling/Mango.git
synced 2026-05-01 00:00:55 -04:00
- option to resume/start from beginning at the title view
- option to toggle read/unread status at the title view - move all embeded JS to public/
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
function showModal(title, zipPath, pages, percentage, title, entry) {
|
||||
$('#modal button, #modal a').each(function(){
|
||||
$(this).removeAttr('hidden');
|
||||
});
|
||||
if (percentage === 0) {
|
||||
$('#continue-btn').attr('hidden', '');
|
||||
$('#unread-btn').attr('hidden', '');
|
||||
}
|
||||
else {
|
||||
$('#continue-btn').text('Continue from ' + percentage + '%');
|
||||
}
|
||||
if (percentage === 100) {
|
||||
$('#read-btn').attr('hidden', '');
|
||||
}
|
||||
$('#modal-title').text(title);
|
||||
$('#path-text').text(zipPath);
|
||||
$('#pages-text').text(pages + ' pages');
|
||||
|
||||
$('#beginning-btn').attr('href', '/reader/' + title + '/' + entry + '/1');
|
||||
$('#continue-btn').attr('href', '/reader/' + title + '/' + entry);
|
||||
|
||||
$('#read-btn').click(function(){
|
||||
updateProgress(title, entry, pages);
|
||||
});
|
||||
$('#unread-btn').click(function(){
|
||||
updateProgress(title, entry, 0);
|
||||
});
|
||||
|
||||
UIkit.modal($('#modal')).show();
|
||||
}
|
||||
function updateProgress(title, entry, page) {
|
||||
$.post('/api/progress/' + title + '/' + entry + '/' + page, function(data) {
|
||||
if (data.success) {
|
||||
location.reload();
|
||||
}
|
||||
else {
|
||||
error = data.error;
|
||||
alert('danger', error);
|
||||
}
|
||||
});
|
||||
}
|
||||
function alert(level, text) {
|
||||
hideAlert();
|
||||
var html = '<div class="uk-alert-' + level + '" uk-alert><a class="uk-alert-close" uk-close></a><p>' + text + '</p></div>';
|
||||
$('#alert').append(html);
|
||||
}
|
||||
function hideAlert() {
|
||||
$('#alert').empty();
|
||||
}
|
||||
Reference in New Issue
Block a user