Skip to content

Commit

Permalink
get_following
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuowei committed Feb 9, 2021
1 parent 2f6602d commit e8961f0
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 0 deletions.
21 changes: 21 additions & 0 deletions get_following.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="bootstrap.min.css">
</head>
<body>
<div>
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
<div class="container">
<span class="navbar-text" id="user-title">Following</span>
</div>
</nav>
<div class="container">
<div id="users-container"></div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/uuid/8.1.0/uuidv4.min.js"></script>
<script src="common.js"></script>
<script src="get_following.js"></script>
</body>
</html>
22 changes: 22 additions & 0 deletions get_following.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
async function loadHandler() {
if (await doRedirect()) {
return;
}
const userId = parseInt(location.search.substring(1));
const response = await apiPost('get_following', {user_id: userId});
const usersContainer = document.getElementById('users-container');
for (const user of response.users) {
const userLink = document.createElement('a');
userLink.href = '/user.html?' + user.user_id;
userLink.innerText = user.username;
const userDiv1 = document.createElement('div');
userDiv1.appendChild(userLink);
const userDiv = document.createElement('div');
userDiv.appendChild(userDiv1);
const userBio = document.createElement('div');
userBio.textContent = user.bio;
userDiv.appendChild(userBio);
usersContainer.appendChild(userDiv);
}
}
window.onload = loadHandler;
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<div><a href="/update_username.html" class="btn btn-primary" id="set-username">Set username</a></div>
<div><a href="/get_all_topics.html" class="btn btn-primary">All topics</a></div>
<div><a href="/get_channels.html" class="btn btn-primary">Current rooms</a></div>
<div><a href="#" id="yourprofile" class="btn btn-primary">Your profile</a></div>
<div><a href="#" onclick="logOut()" class="btn btn-secondary">Log out</a></div>
<footer>
hipster.house: a terrible Clubhouse client by <a href="https://twitter.com/zhuowei">@zhuowei.</a> <a href="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/zhuowei/hipster.house">Fork on Github</a>
Expand Down
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ async function loadHandler() {
document.getElementById('set-username').style.display = 'none';
document.getElementById('waitlist-username').style.display = 'none';
}
document.getElementById('yourprofile').href =
'/user.html?' + getConfig().user.user_profile.user_id;
}
window.onload = loadHandler;
2 changes: 2 additions & 0 deletions user.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="bootstrap.min.css">
</head>
<body>
Expand All @@ -10,6 +11,7 @@
<div class="container">
<div><img id="user-img" width="64"></div>
<div id="user-name"></div>
<div><a href="#" id="user-following">following</a></div>
<div id="user-bio"></div>
<div>Clubs:</div>
<div id="user-clubs"></div>
Expand Down
4 changes: 4 additions & 0 deletions user.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ async function loadHandler() {
document.getElementById('user-name').textContent = p.name;
document.getElementById('user-bio').textContent = p.bio;
document.getElementById('user-img').src = p.photo_url;
document.getElementById('user-following').href =
'/get_following.html?' + userId;
document.getElementById('user-following').textContent =
p.num_following + ' following';
const clubsContainer = document.getElementById('user-clubs');
for (const club of p.clubs) {
const clubLink = document.createElement('a');
Expand Down

0 comments on commit e8961f0

Please sign in to comment.