-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cais UI updates #1631
Cais UI updates #1631
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
const eventClick = "click"; | ||
const eventDomLoaded = "DOMContentLoaded"; | ||
const idJoin = "join"; | ||
const idMoreInfo = "moreInfo"; | ||
const idRevokeUserID = "revokeUserID"; | ||
const idStatus = "status"; | ||
const idAccountsTable = "accountsTable"; | ||
const idTableBody = "tableBody"; | ||
const idInformation = "information"; | ||
const idInformation2 = "information2"; | ||
const idWelcome = "welcome"; | ||
const idRequestTokens = "requestTokens"; | ||
const idBegin = "begin-box"; | ||
const idSpinner = "spinner"; | ||
const obscuroGatewayVersion = "v1"; | ||
Comment on lines
1
to
15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The constants are well defined and follow a consistent naming convention. However, consider grouping related constants into an object or enum for better organization and readability. |
||
|
@@ -244,7 +247,13 @@ async function populateAccountsTable(document, tableBody, userID) { | |
|
||
const statusCell = document.createElement('td'); | ||
|
||
statusCell.textContent = await accountIsAuthenticated(account, userID); // Status is empty for now | ||
let x = await accountIsAuthenticated(account, userID); // Status is empty for now | ||
if (x == true) { | ||
statusCell.textContent = "\u2705"; | ||
} else { | ||
statusCell.textContent = "\u274C"; | ||
} | ||
|
||
row.appendChild(statusCell); | ||
|
||
tableBody.appendChild(row); | ||
Comment on lines
247
to
259
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The use of Unicode characters for checkmark and cross symbols is a good approach for visual representation of status. However, consider adding a comment explaining what these Unicode characters represent for better readability. |
||
|
@@ -271,10 +280,13 @@ async function switchToObscuroNetwork() { | |
|
||
const initialize = async () => { | ||
const joinButton = document.getElementById(idJoin); | ||
const moreInfoButton = document.getElementById(idMoreInfo); | ||
const revokeUserIDButton = document.getElementById(idRevokeUserID); | ||
const statusArea = document.getElementById(idStatus); | ||
const informationArea = document.getElementById(idInformation); | ||
const informationArea2 = document.getElementById(idInformation2); | ||
const welcome = document.getElementById(idWelcome); | ||
const requestTokens = document.getElementById(idRequestTokens); | ||
const beginBox = document.getElementById(idBegin); | ||
const spinner = document.getElementById(idSpinner); | ||
|
||
|
@@ -285,23 +297,29 @@ const initialize = async () => { | |
let userID = await getUserID() | ||
|
||
function displayOnlyJoin() { | ||
joinButton.style.display = "block" | ||
revokeUserIDButton.style.display = "none" | ||
accountsTable.style.display = "none" | ||
informationArea.style.display = "block" | ||
informationArea2.style.display = "none" | ||
joinButton.style.display = "block"; | ||
moreInfoButton.style.display = "block"; | ||
revokeUserIDButton.style.display = "none"; | ||
requestTokens.style.display = "none"; | ||
accountsTable.style.display = "none"; | ||
informationArea.style.display = "block"; | ||
informationArea2.style.display = "none"; | ||
welcome.style.display = "block"; | ||
|
||
beginBox.style.visibility = "visible"; | ||
spinner.style.visibility = "hidden"; | ||
} | ||
|
||
async function displayConnectedAndJoinedSuccessfully() { | ||
joinButton.style.display = "none" | ||
informationArea.style.display = "none" | ||
informationArea2.style.display = "block" | ||
revokeUserIDButton.style.display = "block" | ||
accountsTable.style.display = "block" | ||
|
||
joinButton.style.display = "none"; | ||
moreInfoButton.style.display = "none"; | ||
informationArea.style.display = "none"; | ||
informationArea2.style.display = "block"; | ||
revokeUserIDButton.style.display = "block"; | ||
accountsTable.style.display = "block"; | ||
welcome.style.display = "none"; | ||
requestTokens.style.display = "block"; | ||
|
||
await populateAccountsTable(document, tableBody, userID) | ||
} | ||
|
||
Comment on lines
297
to
325
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The functions |
||
|
@@ -405,9 +423,44 @@ const initialize = async () => { | |
statusArea.innerText = "Revoking UserID failed"; | ||
} | ||
}) | ||
Comment on lines
423
to
425
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The error message "Revoking UserID failed" is a bit vague. Consider providing a more detailed error message or handling different error scenarios separately to give the user a better understanding of what went wrong. |
||
|
||
beginBox.style.visibility = "visible"; | ||
spinner.style.visibility = "hidden"; | ||
} | ||
|
||
window.addEventListener(eventDomLoaded, checkIfMetamaskIsLoaded); | ||
$('#moreInfo').click(function(){ | ||
var buttonId = 'four'; | ||
$('#modal-container').removeAttr('class').addClass(buttonId); | ||
$('body').addClass('modal-active'); | ||
}) | ||
|
||
$('#modal-container').click(function(){ | ||
$(this).addClass('out'); | ||
$(this).addClass('disappear'); | ||
$('body').removeClass('modal-active'); | ||
}); | ||
Comment on lines
+431
to
+441
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The modal opening and closing logic is well implemented. However, consider adding some error handling or checks to ensure that the elements exist and the operations are successful. |
||
|
||
const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+;:'|?/><~"; | ||
|
||
const randomChar = () => chars[Math.floor(Math.random() * (chars.length - 1))], | ||
randomString = length => Array.from(Array(length)).map(randomChar).join(""); | ||
|
||
const card = document.querySelector(".card"), | ||
letters = card.querySelector(".card-letters"); | ||
|
||
const handleOnMove = e => { | ||
const rect = card.getBoundingClientRect(), | ||
x = e.clientX - rect.left, | ||
y = e.clientY - rect.top; | ||
|
||
letters.style.setProperty("--x", `${x}px`); | ||
letters.style.setProperty("--y", `${y}px`); | ||
|
||
letters.innerText = randomString(1700); | ||
} | ||
|
||
card.onmousemove = e => handleOnMove(e); | ||
|
||
card.ontouchmove = e => handleOnMove(e.touches[0]); | ||
|
||
window.addEventListener(eventDomLoaded, checkIfMetamaskIsLoaded); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
onclick
attribute is used to open a new window with a Discord link. This is an old-fashioned way of attaching event handlers and it mixes JavaScript code with HTML markup. Consider moving this logic tojavascript.js
and useaddEventListener
to attach the event handler.In
javascript.js
:Commitable suggestion (Beta)
In
javascript.js
: