mirror of
https://github.com/dscalzi/HeliosLauncher.git
synced 2024-12-22 19:52:14 -08:00
Compare commits
1 Commits
a36a172033
...
0f2777226d
Author | SHA1 | Date | |
---|---|---|---|
|
0f2777226d |
@ -25,13 +25,9 @@ let accountSelectContent = document.getElementById('accountSelectContent')
|
|||||||
*/
|
*/
|
||||||
function overlayKeyHandler (e){
|
function overlayKeyHandler (e){
|
||||||
if(e.key === 'Enter' || e.key === 'Escape'){
|
if(e.key === 'Enter' || e.key === 'Escape'){
|
||||||
if (overlayContainer.hasAttribute('popup')) {
|
|
||||||
toggleOverlay(false)
|
|
||||||
} else {
|
|
||||||
document.getElementById(overlayHandlerContent).getElementsByClassName('overlayKeybindEnter')[0].click()
|
document.getElementById(overlayHandlerContent).getElementsByClassName('overlayKeybindEnter')[0].click()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Overlay keydown handler for a dismissable overlay.
|
* Overlay keydown handler for a dismissable overlay.
|
||||||
*
|
*
|
||||||
@ -71,9 +67,8 @@ function bindOverlayKeys(state, content, dismissable){
|
|||||||
* @param {boolean} toggleState True to display, false to hide.
|
* @param {boolean} toggleState True to display, false to hide.
|
||||||
* @param {boolean} dismissable Optional. True to show the dismiss option, otherwise false.
|
* @param {boolean} dismissable Optional. True to show the dismiss option, otherwise false.
|
||||||
* @param {string} content Optional. The content div to be shown.
|
* @param {string} content Optional. The content div to be shown.
|
||||||
* @param {boolean} popup Optional. True to show the overlay as a popup that is easily dismissable and interactible.
|
|
||||||
*/
|
*/
|
||||||
function toggleOverlay(toggleState, dismissable = false, content = 'overlayContent', popup = false){
|
function toggleOverlay(toggleState, dismissable = false, content = 'overlayContent'){
|
||||||
if(toggleState == null){
|
if(toggleState == null){
|
||||||
toggleState = !document.getElementById('main').hasAttribute('overlay')
|
toggleState = !document.getElementById('main').hasAttribute('overlay')
|
||||||
}
|
}
|
||||||
@ -85,7 +80,6 @@ function toggleOverlay(toggleState, dismissable = false, content = 'overlayConte
|
|||||||
if(toggleState){
|
if(toggleState){
|
||||||
document.getElementById('main').setAttribute('overlay', true)
|
document.getElementById('main').setAttribute('overlay', true)
|
||||||
overlayContainer.setAttribute('content', content)
|
overlayContainer.setAttribute('content', content)
|
||||||
overlayContainer.setAttribute('popup', popup)
|
|
||||||
|
|
||||||
// Make things untabbable.
|
// Make things untabbable.
|
||||||
$('#main *').attr('tabindex', '-1')
|
$('#main *').attr('tabindex', '-1')
|
||||||
@ -132,21 +126,23 @@ function toggleOverlay(toggleState, dismissable = false, content = 'overlayConte
|
|||||||
|
|
||||||
async function toggleServerSelection(toggleState){
|
async function toggleServerSelection(toggleState){
|
||||||
await prepareServerSelectionList()
|
await prepareServerSelectionList()
|
||||||
toggleOverlay(toggleState, false, 'serverSelectContent', true)
|
toggleOverlay(toggleState, true, 'serverSelectContent')
|
||||||
}
|
}
|
||||||
|
|
||||||
async function toggleAccountSelection(toggleState, popup = false){
|
async function toggleAccountSelection(toggleState, popup = false){
|
||||||
if (popup) {
|
if (popup) {
|
||||||
// set the accountSelectActions div to display: none to avoid colliding with the validateSelectedAccount function
|
// set the popup=true attribute to the accountSelectContent div and set the accountSelectActions div to display: none to avoid colliding with the validateSelectedAccount function
|
||||||
|
accountSelectContent.setAttribute('popup', 'true')
|
||||||
document.getElementById('accountSelectActions').style.display = 'none'
|
document.getElementById('accountSelectActions').style.display = 'none'
|
||||||
} else {
|
} else {
|
||||||
// set the overlayContainer div to display: block, this is not done while closing the overlay because of the fadeOut effect
|
// remove the popup attribute and set the accountSelectActions div to display: block, this is not done while closing the overlay because of the fadeOut effect
|
||||||
|
accountSelectContent.removeAttribute('popup')
|
||||||
document.getElementById('accountSelectActions').style.display = 'block'
|
document.getElementById('accountSelectActions').style.display = 'block'
|
||||||
}
|
}
|
||||||
|
|
||||||
// show the overlay
|
// show the overlay
|
||||||
await prepareAccountSelectionList()
|
await prepareAccountSelectionList()
|
||||||
toggleOverlay(toggleState, false, 'accountSelectContent', popup)
|
toggleOverlay(toggleState, true, 'accountSelectContent')
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -246,8 +242,10 @@ document.getElementById('accountSelectManage').addEventListener('click', async (
|
|||||||
// Make the Server Selection background clickable to close the overlay.
|
// Make the Server Selection background clickable to close the overlay.
|
||||||
overlayContainer.addEventListener('click', e => {
|
overlayContainer.addEventListener('click', e => {
|
||||||
if (e.target === overlayContainer) {
|
if (e.target === overlayContainer) {
|
||||||
// This function only works if the overlay is a popup
|
// This function only works for the server selection overlay or if the account selection is a popup
|
||||||
if(overlayContainer.hasAttribute('popup')) {
|
if(overlayContainer.getAttribute('content') === 'serverSelectContent') {
|
||||||
|
toggleOverlay(false)
|
||||||
|
} else if(overlayContainer.getAttribute('content') === 'accountSelectContent' && accountSelectContent.hasAttribute('popup')) {
|
||||||
toggleOverlay(false)
|
toggleOverlay(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -270,7 +268,7 @@ async function setAccountListingHandlers(){
|
|||||||
listings.map(async (val) => {
|
listings.map(async (val) => {
|
||||||
val.onclick = async e => {
|
val.onclick = async e => {
|
||||||
// popup mode
|
// popup mode
|
||||||
if(overlayContainer.hasAttribute('popup')){
|
if(accountSelectContent.hasAttribute('popup')){
|
||||||
const authAcc = ConfigManager.setSelectedAccount(val.getAttribute('uuid'))
|
const authAcc = ConfigManager.setSelectedAccount(val.getAttribute('uuid'))
|
||||||
ConfigManager.save()
|
ConfigManager.save()
|
||||||
updateSelectedAccount(authAcc)
|
updateSelectedAccount(authAcc)
|
||||||
@ -334,7 +332,7 @@ function populateAccountListings(){
|
|||||||
const accounts = Array.from(Object.keys(accountsObj), v=>accountsObj[v])
|
const accounts = Array.from(Object.keys(accountsObj), v=>accountsObj[v])
|
||||||
let htmlString = ''
|
let htmlString = ''
|
||||||
for(let i=0; i<accounts.length; i++){
|
for(let i=0; i<accounts.length; i++){
|
||||||
htmlString += `<button class="accountListing" uuid="${accounts[i].uuid}" ${!i && !overlayContainer.hasAttribute("popup") ? 'selected' : ''}>
|
htmlString += `<button class="accountListing" uuid="${accounts[i].uuid}" ${!i && !accountSelectContent.hasAttribute("popup") ? 'selected' : ''}>
|
||||||
<img src="https://mc-heads.net/head/${accounts[i].uuid}/40">
|
<img src="https://mc-heads.net/head/${accounts[i].uuid}/40">
|
||||||
<div class="accountListingName">${accounts[i].displayName}</div>
|
<div class="accountListingName">${accounts[i].displayName}</div>
|
||||||
</button>`
|
</button>`
|
||||||
|
Loading…
Reference in New Issue
Block a user