This repository was archived by the owner on Feb 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathload_more.js
More file actions
62 lines (55 loc) · 1.66 KB
/
load_more.js
File metadata and controls
62 lines (55 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
function buttonAjax(buttonElem, options, failOnly) {
if (failOnly === undefined) {
failOnly = false;
}
// Get original html and click events
var html = buttonElem.html();
// Disable button
buttonElem
.prop('disabled', true)
.css('pointer-events', 'none')
.css('cursor', 'not-allowed');
// Prepend spinner
buttonElem.html('<i class="fas fa-spinner fa-spin"></i> ' + html);
var disableFunc = function () {
// Reset original html
buttonElem.html(html);
// Enable button
buttonElem
.css('pointer-events', '')
.prop('disabled', false)
.css('cursor', '');
};
// Send AJAX
if (failOnly === true) {
return $.ajax(options).always(fail);
} else {
return $.ajax(options).always(disableFunc);
}
}
$(function () {
$("#get_more").one("click", function (e) {
//Prepare the url with the proper query strings
let urlParams = new URLSearchParams(window.location.search);
let speaker = urlParams.get('speaker');
let submitter = urlParams.get('submitter');
let urlStr = `/additional`;
if(speaker){
urlStr+=`?speaker=${speaker}`;
}
if(submitter){
urlStr+=`?submitter=${submitter}`;
}
buttonAjax($(this), {
url: urlStr,
method: 'GET',
success: function (data, textStatus, jqXHR) {
$("#moreQuotes").html(data)
.collapse("show");
},
error: function (error) {
console.log(error);
}
});
});
});