diff --git a/index.html b/index.html index 9f8232f..d4a34eb 100644 --- a/index.html +++ b/index.html @@ -8,6 +8,7 @@ +
@@ -49,6 +50,40 @@ load(); } +function loadFollowing() { + var username = $('#username').val(); // Utilize jQuery to get the input value + var page = 1; + loading = true; // Set loading flag to true + + // Clear old followers before loading new ones + $('#result').empty(); + + function load() { + if (!stopLoadingFlag) { // Check if loading process should continue + $.get("https://scratch.mit.edu/users/" + username + "/following/?page=" + page, loaded); + } + } + + function loaded(data) { + var users = $(data).find('span.title > a'); // Use jQuery to find users directly + var $out = $('#result'); + + users.each(function() { + var user = $(this).text().trim(); // Use $(this) to reference the current user + $out.append(user + '
'); + }); + + page++; + if (!stopLoadingFlag) { // Check if loading process should continue + load(); // Call load function recursively + } else { + loading = false; // Set loading flag to false when loading stops + } + } + + load(); +} + function stopLoading() { stopLoadingFlag = true; // Set the flag to stop loading }