Merge remote-tracking branch 'mp3_csrf/save-mp3-position'

This commit is contained in:
Ozzie Isaacs 2022-12-25 10:34:01 +01:00
commit 66e0a81d23
2 changed files with 12 additions and 3 deletions

View File

@ -177,6 +177,9 @@
whileplaying: function () {
// get csrf_token
let csrf_token = $("input[name='csrf_token']").val();
//This sends a bookmark update to calibreweb every 30 seconds.
if (this.progressBuffer == undefined) {
@ -187,7 +190,10 @@
$.ajax(calibre.bookmarkUrl, {
method: "post",
data: { bookmark: this.position }
data: {
csrf_token: csrf_token,
bookmark: this.position
}
}).fail(function (xhr, status, error) {
console.error(error);
});
@ -313,14 +319,14 @@
},
onstop: function () {
$.ajax(calibre.bookmarkUrl, {
method: "post",
data: { bookmark: this.position }
}).fail(function (xhr, status, error) {
console.error(error);
});
utils.css.remove(dom.o, 'playing');
},

View File

@ -319,6 +319,8 @@
</div>
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<script>
soundManager.setup({
useHTML5Audio: true,
@ -342,6 +344,7 @@ window.calibre = {
bookmarkUrl: "{{ url_for('web.set_bookmark', book_id=mp3file, book_format=audioformat.upper()) }}",
bookmark: "{{ bookmark.bookmark_key if bookmark != None }}",
useBookmarks: "{{ g.user.is_authenticated | tojson }}"
};
</script>
</body>