Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
hcr5 authored Feb 17, 2024
1 parent db29806 commit 2ac0591
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
var stopLoadingFlag = false; // Flag to track if the loading process should be stopped

function loadFollowers() {
var username = document.getElementById("username").value;
var username = $('#username').val(); // Utilize jQuery to get the input value
var page = 1;
loading = true; // Set loading flag to true

Expand All @@ -30,18 +30,17 @@
}

function loaded(data) {
var $dom = $(data);
var $users = $dom.find('span.title > a');
var users = $(data).find('span.title > a'); // Use jQuery to find users directly
var $out = $('#result');

for (var i = 0; i < $users.length; i++) {
var user = $($users[i]).text().trim();
users.each(function() {
var user = $(this).text().trim(); // Use $(this) to reference the current user
$out.append(user + '<br>');
}
});

page++;
if (!stopLoadingFlag) { // Check if loading process should continue
$.get("https://scratch.mit.edu/users/" + username + "/followers/?page=" + page, loaded);
load(); // Call load function recursively
} else {
loading = false; // Set loading flag to false when loading stops
}
Expand Down

0 comments on commit 2ac0591

Please sign in to comment.