<commit_before>import { AnimeNotifier } from "../AnimeNotifier"

// Load more
export function loadMore(arn: AnimeNotifier, button: HTMLButtonElement) {
	// Prevent firing this event multiple times
	if(arn.isLoading || button.disabled || button.classList.contains("hidden")) {
		return
	}

	arn.loading(true)
	button.disabled = true

	let target = arn.app.find("load-more-target")
	let index = button.dataset.index

	fetch("/_" + arn.app.currentPath + "/from/" + index)
	.then(response => {
		let newIndex = response.headers.get("X-LoadMore-Index")

		// End of data?
		if(newIndex === "-1") {
			button.disabled = true
			button.classList.add("hidden")
		} else {
			button.dataset.index = newIndex
		}

		return response
	})
	.then(response => response.text())<commit_msg>Fixed scrolling<commit_after>import { AnimeNotifier } from "../AnimeNotifier"

// Load more
export function loadMore(arn: AnimeNotifier, button: HTMLButtonElement) {
	// Prevent firing this event multiple times
	if(arn.isLoading || button.disabled || button.classList.contains("hidden")) {
		return
	}

	arn.loading(true)
	button.disabled = true

	let target = arn.app.find("load-more-target")
	let index = button.dataset.index

	fetch("/_" + arn.app.currentPath + "/from/" + index, {
		credentials: "same-origin"
	})
	.then(response => {
		let newIndex = response.headers.get("X-LoadMore-Index")

		// End of data?
		if(newIndex === "-1") {
			button.disabled = true
			button.classList.add("hidden")
		} else {
			button.dataset.index = newIndex
		}

		return response
	})
	.then(response => response.text())
{'fraction_non_alphanumeric': 0.15224257738471256, 'fraction_numerical': 0.0012634238787113076, 'mean_word_length': 3.8, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4114931', 'n_tokens_mistral': 548, 'n_tokens_neox': 509, 'n_words': 110}