Skip to content

Commit

Permalink
Account creation shows but doesnt save
Browse files Browse the repository at this point in the history
  • Loading branch information
MTSyntho committed Sep 9, 2024
1 parent 0faa1fb commit de44bf8
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 43 deletions.
22 changes: 0 additions & 22 deletions .zdkrimson/accounts.json

This file was deleted.

16 changes: 0 additions & 16 deletions .zdkrimson/settings.json

This file was deleted.

1 change: 1 addition & 0 deletions help.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
</div>
<body>
<p>Documentation will be worked on <i>eventually</i></p>
<p>haha yes XD<br>Why do you just so happen to be on this specfic build(s) of zdkrimson?</p>
</body>
</html>
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,10 @@ window.addEventListener('message', function(event) {
if (event.data == 'offlinelogin') {
pywebview.api.offline_account(localStorage.getItem('offlineusername') , localStorage.getItem('offlineuuid'));
}

if (event.data == 'accountchange') {
var lastuser = document.getElementById('lastuser');
lastuser.textContent = "Logged in as: " + localStorage.getItem('current-username');
// i will figure out how to save last account, soon...
};
});
6 changes: 6 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ def get_username(self, uuid):
if uuid == 'recent':
return lastaccount

def save_account_change(self, name, uuid):
print('Saving Details for Logged In Account.')
print('Account Name: ' + name)
print('Account UUID: ' + uuid)
# my brain hurt

def get_recentinstance(self):
print("Last Instance:", lastinstance)
return lastinstance
Expand Down
31 changes: 31 additions & 0 deletions settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -428,4 +428,35 @@ button:active {

.smallgap {
gap: 5px;
}

.account {
border: 2px solid #ffffff10;
border-radius: 10px;
padding: 12px;
display: inline-flex;
flex-direction: column;
align-items: left;
/*justify-content: center;*/
box-shadow: 0px 0px 20px #00000070;
transition-duration: 0.2s
}

.account:hover {
scale: 1.02;
background-color: #ffffff07; /*i like the number 7.*/
}

.account:active {
scale: 0.98;
background-color: #00000050;
}

.small-text {
font-size: 10px;
opacity: 0.5;
}

.big-gap {
gap: 10px;
}
5 changes: 1 addition & 4 deletions settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,8 @@ <h1>Accounts</h1>
<button>Remove Account</button>
</div>
<br>
<div class='section smallgap'>
<div id=account-section class='section big-gap'>
<p id=accountload>Loading....</p>
<input type='text' id=loginofflinename placeholder='Username (Offline Mode Only)'>
<button>Login</button>
<p id=loginstatus>Status: </p>
</div>
</div>
<div id=themes class=content>
Expand Down
40 changes: 39 additions & 1 deletion settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,48 @@ function login(method) {
localStorage.setItem('offlineuuid', document.getElementById('offlineuuid').value);
// document.createElement('div'); (i'll get this workin soon)
window.parent.postMessage('offlinelogin', '*');
displayAccount(document.getElementById('offlinename').value, document.getElementById('offlineuuid').value);
closeOfflineAccount();
}

if (method == 'microsoft') {
console.log('Not Implemented (Microsoft Login)');
}
}
}

function selectAccount(name, uuid) {
localStorage.setItem('current-username', name);
localStorage.setItem('current-uuid', uuid);
window.parent.postMessage('accountchange', '*');
}

function displayAccount(name, uuid, linkUrl) {
const accountDiv = document.createElement('div');
accountDiv.className = 'account';

const linkElement = document.createElement('a');
linkElement.className = 'account-link';

const usernameP = document.createElement('p');
usernameP.textContent = `Username: ${name}`;

const uuidP = document.createElement('p');
uuidP.className = 'small-text';

if (!uuid || !uuid.trim()) {
uuidP.textContent = 'UUID: Unset';
} else {
uuidP.textContent = `UUID: ${uuid}`;
}

linkElement.appendChild(usernameP);
linkElement.appendChild(uuidP);

accountDiv.appendChild(linkElement);

const accountsSection = document.getElementById('account-section');

accountsSection.appendChild(accountDiv);

linkElement.addEventListener('click', (event) => { selectAccount(name, uuid); });
}

0 comments on commit de44bf8

Please sign in to comment.