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 c9194d8 commit 6139387
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@
<title>Scratch Followers Page</title>
<script src="https://code.jquery.com/jquery-latest.min.js"></script>
<script>
var username = "cIoudo";
var page = 1;

function load() {
function loadFollowers() {
var username = document.getElementById('username').value.trim();
if (username === '') {
alert('Please enter a username.');
return;
}

$.ajax({
url: "https://scratch.mit.edu/users/" + username + "/followers/?page=" + page,
type: "GET",
Expand All @@ -27,18 +32,22 @@
var $users = $dom.find('span.title').children();
var $out = $('#result');

$out.empty(); // Clear previous results

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

page++;
load();
}
</script>
</head>
<body onload="load()">
<body>
<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 6139387

Please sign in to comment.