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 2dc818e commit c9194d8
Showing 1 changed file with 23 additions and 30 deletions.
53 changes: 23 additions & 30 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,39 @@
<title>Scratch Followers Page</title>
<script src="https://code.jquery.com/jquery-latest.min.js"></script>
<script>
function loadFollowers() {
var username = document.getElementById('username').value.trim();
if (username === '') {
alert('Please enter a username.');
return;
}
var page = 1;

function load() {
$.get("https://scratch.mit.edu/users/" + username + "/followers/?page=" + page, loaded);
}

function loaded(data) {
var $dom = $(data);
var $users = $dom.find('span.title').children();
var $out = $('#result');
var username = "cIoudo";
var page = 1;

for (var i = 0; i < $users.length; i++) {
var user = $users[i].text.trim();
$out.append(user + '<br>');
function load() {
$.ajax({
url: "https://scratch.mit.edu/users/" + username + "/followers/?page=" + page,
type: "GET",
success: function(data) {
loaded(data);
},
error: function(xhr, status, error) {
console.error("Error loading data:", error);
}
});
}

page++;
if ($users.length > 0) {
load();
}
function loaded(data) {
var $dom = $(data);
var $users = $dom.find('span.title').children();
var $out = $('#result');

for (var i = 0; i < $users.length; i++) {
var user = $users[i].text.trim();
$out.prepend(user + '<br>');
}

$('#result').empty(); // Clear previous results
page++;
load();
}
</script>
</head>
<body>
<body onload="load()">
<h1>Scratch Followers Page</h1>
<div>
<label for="username">Enter Scratch Username:</label>
<input type="text" id="username" name="username">
<button onclick="loadFollowers()">Fetch Followers</button>
</div>
<div id="result"></div>
</body>
</html>

0 comments on commit c9194d8

Please sign in to comment.