Skip to content

Commit 9f7906c

Browse files
committed
Add loading to onepage option
1 parent 792b864 commit 9f7906c

File tree

1 file changed

+43
-44
lines changed

1 file changed

+43
-44
lines changed

backend/templates/songs/index.html

+43-44
Original file line numberDiff line numberDiff line change
@@ -184,40 +184,8 @@ <h6 class="d-inline" ><%:author%></h6>
184184
$.fn.DataTable.ext.pager.numbers_length = 5;
185185
$.templates("song", "#songTemplate")
186186

187-
document.addEventListener('DOMContentLoaded', function () {
188-
const back_to_top = $('#back-to-top')
189-
$(window).scroll(function () {
190-
if ($(this).scrollTop() > 50) {
191-
back_to_top.fadeIn();
192-
} else {
193-
back_to_top.fadeOut();
194-
}
195-
});
196-
// scroll body to 0px on click
197-
198-
back_to_top.click(function () {
199-
$('body,html').animate({
200-
scrollTop: 0
201-
}, 800);
202-
return false;
203-
});
204-
205-
$( "#scroll-down" ).click(function() {
206-
betterScrollDown()
207-
});
208-
209-
let hidden = false
210-
function hideChords(value) {
211-
hidden = value
212-
if (value) {
213-
$(".chord").hide()
214-
} else {
215-
$(".chord").show()
216-
}
217-
}
218-
219-
let wakelock;
220-
async function preventSleep(value) {
187+
let wakelock;
188+
async function preventSleep(value) {
221189
if(!canWakeLock()) return;
222190
if (value) {
223191
try {
@@ -233,27 +201,58 @@ <h6 class="d-inline" ><%:author%></h6>
233201
if(wakelock) wakelock.release();
234202
wakelock = null;
235203
}
204+
}
205+
let hidden = false
206+
function hideChords(value) {
207+
hidden = value
208+
if (value) {
209+
$(".chord").hide()
210+
} else {
211+
$(".chord").show()
236212
}
237-
238-
const config = new Map([
213+
}
214+
const config = new Map([
239215
["hide_chords", new BooleanOption(document.getElementById("hideChords"), hideChords, false)],
240216
["prevent_sleep", new BooleanOption(document.getElementById("preventSleep"), function(value) {
241217
preventSleep(value).then()
242218
}, false)],
243219
["one_page", new BooleanOption(document.getElementById("onePage"), function(value) {
244-
if (table)
220+
if (table) {
245221
table.destroy()
222+
document.getElementById("content").classList.add("d-none");
223+
document.getElementById("spinner").classList.remove("d-none");
224+
}
246225
table = createDatatable(!value)
247226
}, false)],
248227
])
249-
const options = new Options(config)
228+
const options = new Options(config)
229+
if (!canWakeLock()) {
230+
options.set("prevent_sleep", false)
231+
options.elements("prevent_sleep").forEach(function (element) {
232+
element.disabled = true
233+
})
234+
}
235+
document.addEventListener('DOMContentLoaded', function () {
236+
const back_to_top = $('#back-to-top')
237+
$(window).scroll(function () {
238+
if ($(this).scrollTop() > 50) {
239+
back_to_top.fadeIn();
240+
} else {
241+
back_to_top.fadeOut();
242+
}
243+
});
244+
// scroll body to 0px on click
250245

251-
if (!canWakeLock()) {
252-
options.set("prevent_sleep", false)
253-
options.elements("prevent_sleep").forEach(function (element) {
254-
element.disabled = true
255-
})
256-
}
246+
back_to_top.click(function () {
247+
$('body,html').animate({
248+
scrollTop: 0
249+
}, 800);
250+
return false;
251+
});
252+
253+
$( "#scroll-down" ).click(function() {
254+
betterScrollDown()
255+
});
257256

258257
table.on( 'draw', function () {
259258
if (hidden) {

0 commit comments

Comments
 (0)