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 39c837c commit db29806
Showing 1 changed file with 33 additions and 50 deletions.
83 changes: 33 additions & 50 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,7 @@
<html>
<head>
<title>Scratch Followers</title>
<style>
body {
font-family: Arial, sans-serif;
}

button {
padding: 8px 16px;
border: none;
border-radius: 4px;
background-color: #007bff;
color: #fff;
cursor: pointer;
}

button:hover {
background-color: #0056b3;
}
</style>
<script src="https://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>

Expand All @@ -28,49 +11,49 @@
<button onclick="stopLoading()">Stop</button>
<div id="result"></div>

<script src="https://code.jquery.com/jquery-latest.min.js"></script>
<script>
var loading = false; // Flag to track if loading is in progress
var stopLoadingFlag = false; // Flag to track if the loading process should be stopped
var loading = false; // Flag to track if loading is in progress
var stopLoadingFlag = false; // Flag to track if the loading process should be stopped

function loadFollowers() {
var username = document.getElementById("username").value;
var page = 1;
loading = true; // Set loading flag to true
function loadFollowers() {
var username = document.getElementById("username").value;
var page = 1;
loading = true; // Set loading flag to true

// Clear old followers before loading new ones
$('#result').empty();
// 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 + "/followers/?page=" + page, loaded);
}
function load() {
if (!stopLoadingFlag) { // Check if loading process should continue
$.get("https://scratch.mit.edu/users/" + username + "/followers/?page=" + page, loaded);
}
}

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

for (var i = 0; i < $users.length; i++) {
var user = $($users[i]).text().trim();
$out.append(user + '<br>');
}
function loaded(data) {
var $dom = $(data);
var $users = $dom.find('span.title > a');
var $out = $('#result');

page++;
if (!stopLoadingFlag) { // Check if loading process should continue
$.get("https://scratch.mit.edu/users/" + username + "/followers/?page=" + page, loaded);
} else {
loading = false; // Set loading flag to false when loading stops
}
for (var i = 0; i < $users.length; i++) {
var user = $($users[i]).text().trim();
$out.append(user + '<br>');
}

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

function stopLoading() {
stopLoadingFlag = true; // Set the flag to stop loading
}
load();
}

function stopLoading() {
stopLoadingFlag = true; // Set the flag to stop loading
}

</script>

</body>
Expand Down

0 comments on commit db29806

Please sign in to comment.