Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions lab/login/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ <h1>Login</h1>
</style>

<h2 id="feed-heading">
Feed <button id="refresh-sign" class="secondary span">Refreshing...</button>
</h2>
Feed <button id="refresh-sign" class="secondary span">Refreshing...</button> <button id="manual-refresh-button" class="secondary-span">↻</button></h2>
<span
id="loading-feed"
style="position: fixed; top: 10px; left: 10px"
Expand All @@ -61,6 +60,7 @@ <h2 id="feed-heading">
<main></main>

<script type="module">
const manualRefreshButton = document.querySelector("#manual-refresh-button");
const refreshSign = document.querySelector("#refresh-sign");
const loadingFeed = document.querySelector("#loading-feed");
const usernameInput = document.querySelector("#username");
Expand Down Expand Up @@ -257,6 +257,7 @@ <h2 id="feed-heading">
usernameInput.addEventListener("keydown", handleInputKeyDown);
passwordInput.addEventListener("keydown", handleInputKeyDown);
refreshSign.addEventListener("click", toggleRefresh);
manualRefreshButton.addEventListener("click", handleManualRefresh);

let nameSet = new Set();

Expand Down Expand Up @@ -364,6 +365,26 @@ <h2 id="feed-heading">
setRefreshStatus(false);
}

// Is this a bad place to declare a variable? Sorry, new to this language :P - Rosy
let cooldownIntervalID;

function handleManualRefresh() {
manualRefreshButton.disabled = true;
manualRefreshButton.style.setProperty('--manual-refresh-button-opacity', 0);
pullUserStatuses()
cooldownIntervalID = setInterval(handleManualRefreshCooldown, 10);
}

function handleManualRefreshCooldown() {
let css = getComputedStyle(manualRefreshButton);
let newOpacity = parseFloat(css.getPropertyValue('--manual-refresh-button-opacity')) + 0.01;
manualRefreshButton.style.setProperty('--manual-refresh-button-opacity', newOpacity);
if (newOpacity >= 1.0) {
manualRefreshButton.disabled = false;
clearInterval(cooldownIntervalID);
}
}

function renderUserStatuses(entries) {
const currentHash = window.location.hash;
const main = document.querySelector("main");
Expand Down
26 changes: 26 additions & 0 deletions lab/login/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ input[type="checkbox"] {
font-size: 16px;
float: right;
flex-shrink: 0;
margin-left: auto;
margin-right: 0;
}

#refresh-sign:hover {
Expand All @@ -75,6 +77,30 @@ input[type="checkbox"] {
outline: 2px solid var(--best-colour);
}

#manual-refresh-button {
color: var(--best-colour);
cursor: pointer;
user-select: none;
background: none;
border: none;
padding: 0;
font-size: 16px;
float: right;
flex-shrink: 0;
opacity: var(--manual-refresh-button-opacity);
}

#manual-refresh-button:hover:enabled {
background-color: var(--best-colour);
color: var(--shade-3);
outline: 2px solid var(--best-colour);
}

#manual-refresh-button:disabled {
color: var(--red);
cursor: not-allowed;
}

.post-title {
all: unset;
}
Expand Down