mirror of
https://github.com/dscalzi/HeliosLauncher.git
synced 2024-12-22 03:32:12 -08:00
🧭 Fluid server selection
Removed the select and cancel buttons and made the buttons directly select the server
This commit is contained in:
parent
eb683f89ec
commit
abc4690949
@ -3688,10 +3688,6 @@ input:checked + .toggleSwitchSlider:before {
|
|||||||
position: relative;
|
position: relative;
|
||||||
background: rgba(131, 131, 131, 0.25);
|
background: rgba(131, 131, 131, 0.25);
|
||||||
}
|
}
|
||||||
.serverListing[selected] {
|
|
||||||
cursor: default;
|
|
||||||
opacity: 1.0;
|
|
||||||
}
|
|
||||||
.serverListing:hover,
|
.serverListing:hover,
|
||||||
.serverListing:focus {
|
.serverListing:focus {
|
||||||
outline: none;
|
outline: none;
|
||||||
|
@ -169,26 +169,7 @@ function setDismissHandler(handler){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Server Select View */
|
/* Account Select View */
|
||||||
|
|
||||||
document.getElementById('serverSelectConfirm').addEventListener('click', async () => {
|
|
||||||
const listings = document.getElementsByClassName('serverListing')
|
|
||||||
for(let i=0; i<listings.length; i++){
|
|
||||||
if(listings[i].hasAttribute('selected')){
|
|
||||||
const serv = (await DistroAPI.getDistribution()).getServerById(listings[i].getAttribute('servid'))
|
|
||||||
updateSelectedServer(serv)
|
|
||||||
refreshServerStatus(true)
|
|
||||||
toggleOverlay(false)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// None are selected? Not possible right? Meh, handle it.
|
|
||||||
if(listings.length > 0){
|
|
||||||
const serv = (await DistroAPI.getDistribution()).getServerById(listings[i].getAttribute('servid'))
|
|
||||||
updateSelectedServer(serv)
|
|
||||||
toggleOverlay(false)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
document.getElementById('accountSelectConfirm').addEventListener('click', async () => {
|
document.getElementById('accountSelectConfirm').addEventListener('click', async () => {
|
||||||
const listings = document.getElementsByClassName('accountListing')
|
const listings = document.getElementsByClassName('accountListing')
|
||||||
@ -218,10 +199,7 @@ document.getElementById('accountSelectConfirm').addEventListener('click', async
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// Bind server select cancel button.
|
// Bind account select cancel button.
|
||||||
document.getElementById('serverSelectCancel').addEventListener('click', () => {
|
|
||||||
toggleOverlay(false)
|
|
||||||
})
|
|
||||||
|
|
||||||
document.getElementById('accountSelectCancel').addEventListener('click', () => {
|
document.getElementById('accountSelectCancel').addEventListener('click', () => {
|
||||||
$('#accountSelectContent').fadeOut(250, () => {
|
$('#accountSelectContent').fadeOut(250, () => {
|
||||||
@ -229,21 +207,23 @@ document.getElementById('accountSelectCancel').addEventListener('click', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
function setServerListingHandlers(){
|
// Make the Server Selection background clickable to close the overlay.
|
||||||
|
let overlayContainer = document.getElementById('overlayContainer')
|
||||||
|
overlayContainer.addEventListener('click', e => {
|
||||||
|
if(e.target === overlayContainer){
|
||||||
|
toggleOverlay(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
async function setServerListingHandlers(){
|
||||||
const listings = Array.from(document.getElementsByClassName('serverListing'))
|
const listings = Array.from(document.getElementsByClassName('serverListing'))
|
||||||
listings.map((val) => {
|
listings.map(async (val) => {
|
||||||
val.onclick = e => {
|
val.onclick = async e => {
|
||||||
if(val.hasAttribute('selected')){
|
console.log(e)
|
||||||
return
|
const serv = (await DistroAPI.getDistribution()).getServerById(val.getAttribute('servid'))
|
||||||
}
|
updateSelectedServer(serv)
|
||||||
const cListings = document.getElementsByClassName('serverListing')
|
refreshServerStatus(true)
|
||||||
for(let i=0; i<cListings.length; i++){
|
toggleOverlay(false)
|
||||||
if(cListings[i].hasAttribute('selected')){
|
|
||||||
cListings[i].removeAttribute('selected')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val.setAttribute('selected', '')
|
|
||||||
document.activeElement.blur()
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -315,7 +295,7 @@ function populateAccountListings(){
|
|||||||
|
|
||||||
async function prepareServerSelectionList(){
|
async function prepareServerSelectionList(){
|
||||||
await populateServerListings()
|
await populateServerListings()
|
||||||
setServerListingHandlers()
|
await setServerListingHandlers()
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepareAccountSelectionList(){
|
function prepareAccountSelectionList(){
|
||||||
|
@ -42,8 +42,6 @@ cancelButton = "Cancel"
|
|||||||
|
|
||||||
[ejs.overlay]
|
[ejs.overlay]
|
||||||
serverSelectHeader = "Available Servers"
|
serverSelectHeader = "Available Servers"
|
||||||
serverSelectConfirm = "Select"
|
|
||||||
serverSelectCancel = "Cancel"
|
|
||||||
accountSelectHeader = "Select an Account"
|
accountSelectHeader = "Select an Account"
|
||||||
accountSelectConfirm = "Select"
|
accountSelectConfirm = "Select"
|
||||||
accountSelectCancel = "Cancel"
|
accountSelectCancel = "Cancel"
|
||||||
|
@ -6,12 +6,6 @@
|
|||||||
<!-- Server listings populated here. -->
|
<!-- Server listings populated here. -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="serverSelectActions">
|
|
||||||
<button id="serverSelectConfirm" class="overlayKeybindEnter" type="submit"><%- lang('overlay.serverSelectConfirm') %></button>
|
|
||||||
<div id="serverSelectCancelWrapper">
|
|
||||||
<button id="serverSelectCancel" class="overlayKeybindEsc"><%- lang('overlay.serverSelectCancel') %></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div id="accountSelectContent" style="display: none;">
|
<div id="accountSelectContent" style="display: none;">
|
||||||
<span id="accountSelectHeader"><%- lang('overlay.accountSelectHeader') %></span>
|
<span id="accountSelectHeader"><%- lang('overlay.accountSelectHeader') %></span>
|
||||||
|
Loading…
Reference in New Issue
Block a user