-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,63 @@ | ||
document.addEventListener("DOMContentLoaded", function(event) { | ||
function paginate() { | ||
const $pager = $('.pager'); | ||
|
||
$pager.find('.next a').one('click', function (e) { | ||
e.preventDefault(); | ||
const url = new URL(this.href); | ||
const retrieve = `${location.pathname}${url.search}` | ||
|
||
$.ajax({ | ||
url: retrieve, | ||
type: "GET", | ||
cache: false, | ||
success: function (html) { | ||
$pager.after(html); | ||
$pager.remove(); | ||
paginate(); | ||
} | ||
}); | ||
let $pager; | ||
let loading = false; | ||
let button; | ||
let noMore = false; | ||
|
||
const nextCommitListItem = () => { | ||
|
||
if (loading === true) { | ||
return; | ||
} | ||
loading = true; | ||
const href = button.attr('href'); | ||
//console.log(href); | ||
if (href === undefined) { | ||
loading = false; | ||
if (!noMore) { | ||
$.snackbar({ | ||
htmlAllowed: true, | ||
content: `There are no more commits.` | ||
}); | ||
noMore = true; | ||
} | ||
return | ||
} | ||
noMore = false; | ||
const retrieve = `${location.pathname}${href}` | ||
|
||
$.ajax({ | ||
url: retrieve, | ||
async: true, | ||
type: "GET", | ||
}).then(function(html) { | ||
$pager.after(html); | ||
$pager.remove(); | ||
loading = false; | ||
paginate(); | ||
}); | ||
} | ||
|
||
|
||
$pager.find('.previous').remove(); | ||
|
||
function paginate() { | ||
$pager = $('.pager'); | ||
button = $pager.find('.next a'); | ||
button.one('click', function (e) { | ||
e.preventDefault(); | ||
nextCommitListItem() | ||
return false; | ||
}); | ||
} | ||
paginate(); | ||
|
||
if (button.length > 0) { | ||
$(window).scroll(function () { | ||
if ($(window).scrollTop() >= $(document).height() - $(window).height() - 10) { | ||
nextCommitListItem(); | ||
} | ||
}); | ||
} | ||
|
||
}) |