|
|
|
@ -159,65 +159,65 @@ server_selection_button.onclick = (e) => {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update Mojang Status Color
|
|
|
|
|
const refreshMojangStatuses = async function(){
|
|
|
|
|
loggerLanding.log('Refreshing Mojang Statuses..')
|
|
|
|
|
// const refreshMojangStatuses = async function(){
|
|
|
|
|
// loggerLanding.log('Refreshing Mojang Statuses..')
|
|
|
|
|
|
|
|
|
|
let status = 'grey'
|
|
|
|
|
let tooltipEssentialHTML = ''
|
|
|
|
|
let tooltipNonEssentialHTML = ''
|
|
|
|
|
// let status = 'grey'
|
|
|
|
|
// let tooltipEssentialHTML = ''
|
|
|
|
|
// let tooltipNonEssentialHTML = ''
|
|
|
|
|
|
|
|
|
|
const response = await MojangRestAPI.status()
|
|
|
|
|
let statuses
|
|
|
|
|
if(response.responseStatus === RestResponseStatus.SUCCESS) {
|
|
|
|
|
statuses = response.data
|
|
|
|
|
} else {
|
|
|
|
|
loggerLanding.warn('Unable to refresh Mojang service status.')
|
|
|
|
|
statuses = MojangRestAPI.getDefaultStatuses()
|
|
|
|
|
}
|
|
|
|
|
// const response = await MojangRestAPI.status()
|
|
|
|
|
// let statuses
|
|
|
|
|
// if(response.responseStatus === RestResponseStatus.SUCCESS) {
|
|
|
|
|
// statuses = response.data
|
|
|
|
|
// } else {
|
|
|
|
|
// loggerLanding.warn('Unable to refresh Mojang service status.')
|
|
|
|
|
// statuses = MojangRestAPI.getDefaultStatuses()
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
greenCount = 0
|
|
|
|
|
greyCount = 0
|
|
|
|
|
// greenCount = 0
|
|
|
|
|
// greyCount = 0
|
|
|
|
|
|
|
|
|
|
for(let i=0; i<statuses.length; i++){
|
|
|
|
|
const service = statuses[i]
|
|
|
|
|
// for(let i=0; i<statuses.length; i++){
|
|
|
|
|
// const service = statuses[i]
|
|
|
|
|
|
|
|
|
|
if(service.essential){
|
|
|
|
|
tooltipEssentialHTML += `<div class="mojangStatusContainer">
|
|
|
|
|
<span class="mojangStatusIcon" style="color: ${MojangRestAPI.statusToHex(service.status)};">•</span>
|
|
|
|
|
<span class="mojangStatusName">${service.name}</span>
|
|
|
|
|
</div>`
|
|
|
|
|
} else {
|
|
|
|
|
tooltipNonEssentialHTML += `<div class="mojangStatusContainer">
|
|
|
|
|
<span class="mojangStatusIcon" style="color: ${MojangRestAPI.statusToHex(service.status)};">•</span>
|
|
|
|
|
<span class="mojangStatusName">${service.name}</span>
|
|
|
|
|
</div>`
|
|
|
|
|
}
|
|
|
|
|
// if(service.essential){
|
|
|
|
|
// tooltipEssentialHTML += `<div class="mojangStatusContainer">
|
|
|
|
|
// <span class="mojangStatusIcon" style="color: ${MojangRestAPI.statusToHex(service.status)};">•</span>
|
|
|
|
|
// <span class="mojangStatusName">${service.name}</span>
|
|
|
|
|
// </div>`
|
|
|
|
|
// } else {
|
|
|
|
|
// tooltipNonEssentialHTML += `<div class="mojangStatusContainer">
|
|
|
|
|
// <span class="mojangStatusIcon" style="color: ${MojangRestAPI.statusToHex(service.status)};">•</span>
|
|
|
|
|
// <span class="mojangStatusName">${service.name}</span>
|
|
|
|
|
// </div>`
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
if(service.status === 'yellow' && status !== 'red'){
|
|
|
|
|
status = 'yellow'
|
|
|
|
|
} else if(service.status === 'red'){
|
|
|
|
|
status = 'red'
|
|
|
|
|
} else {
|
|
|
|
|
if(service.status === 'grey'){
|
|
|
|
|
++greyCount
|
|
|
|
|
}
|
|
|
|
|
++greenCount
|
|
|
|
|
}
|
|
|
|
|
// if(service.status === 'yellow' && status !== 'red'){
|
|
|
|
|
// status = 'yellow'
|
|
|
|
|
// } else if(service.status === 'red'){
|
|
|
|
|
// status = 'red'
|
|
|
|
|
// } else {
|
|
|
|
|
// if(service.status === 'grey'){
|
|
|
|
|
// ++greyCount
|
|
|
|
|
// }
|
|
|
|
|
// ++greenCount
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
if(greenCount === statuses.length){
|
|
|
|
|
if(greyCount === statuses.length){
|
|
|
|
|
status = 'grey'
|
|
|
|
|
} else {
|
|
|
|
|
status = 'green'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// if(greenCount === statuses.length){
|
|
|
|
|
// if(greyCount === statuses.length){
|
|
|
|
|
// status = 'grey'
|
|
|
|
|
// } else {
|
|
|
|
|
// status = 'green'
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
document.getElementById('mojangStatusEssentialContainer').innerHTML = tooltipEssentialHTML
|
|
|
|
|
document.getElementById('mojangStatusNonEssentialContainer').innerHTML = tooltipNonEssentialHTML
|
|
|
|
|
document.getElementById('mojang_status_icon').style.color = MojangRestAPI.statusToHex(status)
|
|
|
|
|
}
|
|
|
|
|
// document.getElementById('mojangStatusEssentialContainer').innerHTML = tooltipEssentialHTML
|
|
|
|
|
// document.getElementById('mojangStatusNonEssentialContainer').innerHTML = tooltipNonEssentialHTML
|
|
|
|
|
// document.getElementById('mojang_status_icon').style.color = MojangRestAPI.statusToHex(status)
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
const refreshServerStatus = async function(fade = false){
|
|
|
|
|
loggerLanding.log('Refreshing Server Status')
|
|
|
|
@ -251,12 +251,12 @@ const refreshServerStatus = async function(fade = false){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
refreshMojangStatuses()
|
|
|
|
|
//refreshMojangStatuses()
|
|
|
|
|
// Server Status is refreshed in uibinder.js on distributionIndexDone.
|
|
|
|
|
|
|
|
|
|
// Set refresh rate to once every 5 minutes.
|
|
|
|
|
let mojangStatusListener = setInterval(() => refreshMojangStatuses(true), 300000)
|
|
|
|
|
let serverStatusListener = setInterval(() => refreshServerStatus(true), 300000)
|
|
|
|
|
//let mojangStatusListener = setInterval(() => refreshMojangStatuses(true), 300000)
|
|
|
|
|
//let serverStatusListener = setInterval(() => refreshServerStatus(true), 300000)
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Shows an error overlay, toggles off the launch area.
|
|
|
|
@ -868,42 +868,42 @@ let newsLoadingListener = null
|
|
|
|
|
*
|
|
|
|
|
* @param {boolean} val True to set loading animation, otherwise false.
|
|
|
|
|
*/
|
|
|
|
|
function setNewsLoading(val){
|
|
|
|
|
if(val){
|
|
|
|
|
const nLStr = 'Checking for News'
|
|
|
|
|
let dotStr = '..'
|
|
|
|
|
nELoadSpan.innerHTML = nLStr + dotStr
|
|
|
|
|
newsLoadingListener = setInterval(() => {
|
|
|
|
|
if(dotStr.length >= 3){
|
|
|
|
|
dotStr = ''
|
|
|
|
|
} else {
|
|
|
|
|
dotStr += '.'
|
|
|
|
|
}
|
|
|
|
|
nELoadSpan.innerHTML = nLStr + dotStr
|
|
|
|
|
}, 750)
|
|
|
|
|
} else {
|
|
|
|
|
if(newsLoadingListener != null){
|
|
|
|
|
clearInterval(newsLoadingListener)
|
|
|
|
|
newsLoadingListener = null
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// function setNewsLoading(val){
|
|
|
|
|
// if(val){
|
|
|
|
|
// const nLStr = 'Checking for News'
|
|
|
|
|
// let dotStr = '..'
|
|
|
|
|
// nELoadSpan.innerHTML = nLStr + dotStr
|
|
|
|
|
// newsLoadingListener = setInterval(() => {
|
|
|
|
|
// if(dotStr.length >= 3){
|
|
|
|
|
// dotStr = ''
|
|
|
|
|
// } else {
|
|
|
|
|
// dotStr += '.'
|
|
|
|
|
// }
|
|
|
|
|
// nELoadSpan.innerHTML = nLStr + dotStr
|
|
|
|
|
// }, 750)
|
|
|
|
|
// } else {
|
|
|
|
|
// if(newsLoadingListener != null){
|
|
|
|
|
// clearInterval(newsLoadingListener)
|
|
|
|
|
// newsLoadingListener = null
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// Bind retry button.
|
|
|
|
|
newsErrorRetry.onclick = () => {
|
|
|
|
|
$('#newsErrorFailed').fadeOut(250, () => {
|
|
|
|
|
initNews()
|
|
|
|
|
$('#newsErrorLoading').fadeIn(250)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// newsErrorRetry.onclick = () => {
|
|
|
|
|
// $('#newsErrorFailed').fadeOut(250, () => {
|
|
|
|
|
// initNews()
|
|
|
|
|
// $('#newsErrorLoading').fadeIn(250)
|
|
|
|
|
// })
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
newsArticleContentScrollable.onscroll = (e) => {
|
|
|
|
|
if(e.target.scrollTop > Number.parseFloat($('.newsArticleSpacerTop').css('height'))){
|
|
|
|
|
newsContent.setAttribute('scrolled', '')
|
|
|
|
|
} else {
|
|
|
|
|
newsContent.removeAttribute('scrolled')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// newsArticleContentScrollable.onscroll = (e) => {
|
|
|
|
|
// if(e.target.scrollTop > Number.parseFloat($('.newsArticleSpacerTop').css('height'))){
|
|
|
|
|
// newsContent.setAttribute('scrolled', '')
|
|
|
|
|
// } else {
|
|
|
|
|
// newsContent.removeAttribute('scrolled')
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Reload the news without restarting.
|
|
|
|
@ -939,107 +939,107 @@ function showNewsAlert(){
|
|
|
|
|
* @returns {Promise.<void>} A promise which resolves when the news
|
|
|
|
|
* content has finished loading and transitioning.
|
|
|
|
|
*/
|
|
|
|
|
function initNews(){
|
|
|
|
|
// function initNews(){
|
|
|
|
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
setNewsLoading(true)
|
|
|
|
|
// return new Promise((resolve, reject) => {
|
|
|
|
|
// setNewsLoading(true)
|
|
|
|
|
|
|
|
|
|
let news = {}
|
|
|
|
|
loadNews().then(news => {
|
|
|
|
|
// let news = {}
|
|
|
|
|
// loadNews().then(news => {
|
|
|
|
|
|
|
|
|
|
newsArr = news.articles || null
|
|
|
|
|
// newsArr = news.articles || null
|
|
|
|
|
|
|
|
|
|
if(newsArr == null){
|
|
|
|
|
// News Loading Failed
|
|
|
|
|
setNewsLoading(false)
|
|
|
|
|
// if(newsArr == null){
|
|
|
|
|
// // News Loading Failed
|
|
|
|
|
// setNewsLoading(false)
|
|
|
|
|
|
|
|
|
|
$('#newsErrorLoading').fadeOut(250, () => {
|
|
|
|
|
$('#newsErrorFailed').fadeIn(250, () => {
|
|
|
|
|
resolve()
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
} else if(newsArr.length === 0) {
|
|
|
|
|
// No News Articles
|
|
|
|
|
setNewsLoading(false)
|
|
|
|
|
// $('#newsErrorLoading').fadeOut(250, () => {
|
|
|
|
|
// $('#newsErrorFailed').fadeIn(250, () => {
|
|
|
|
|
// resolve()
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
// } else if(newsArr.length === 0) {
|
|
|
|
|
// // No News Articles
|
|
|
|
|
// setNewsLoading(false)
|
|
|
|
|
|
|
|
|
|
ConfigManager.setNewsCache({
|
|
|
|
|
date: null,
|
|
|
|
|
content: null,
|
|
|
|
|
dismissed: false
|
|
|
|
|
})
|
|
|
|
|
ConfigManager.save()
|
|
|
|
|
// ConfigManager.setNewsCache({
|
|
|
|
|
// date: null,
|
|
|
|
|
// content: null,
|
|
|
|
|
// dismissed: false
|
|
|
|
|
// })
|
|
|
|
|
// ConfigManager.save()
|
|
|
|
|
|
|
|
|
|
$('#newsErrorLoading').fadeOut(250, () => {
|
|
|
|
|
$('#newsErrorNone').fadeIn(250, () => {
|
|
|
|
|
resolve()
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
// Success
|
|
|
|
|
setNewsLoading(false)
|
|
|
|
|
// $('#newsErrorLoading').fadeOut(250, () => {
|
|
|
|
|
// $('#newsErrorNone').fadeIn(250, () => {
|
|
|
|
|
// resolve()
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
// } else {
|
|
|
|
|
// // Success
|
|
|
|
|
// setNewsLoading(false)
|
|
|
|
|
|
|
|
|
|
const lN = newsArr[0]
|
|
|
|
|
const cached = ConfigManager.getNewsCache()
|
|
|
|
|
let newHash = crypto.createHash('sha1').update(lN.content).digest('hex')
|
|
|
|
|
let newDate = new Date(lN.date)
|
|
|
|
|
let isNew = false
|
|
|
|
|
// const lN = newsArr[0]
|
|
|
|
|
// const cached = ConfigManager.getNewsCache()
|
|
|
|
|
// let newHash = crypto.createHash('sha1').update(lN.content).digest('hex')
|
|
|
|
|
// let newDate = new Date(lN.date)
|
|
|
|
|
// let isNew = false
|
|
|
|
|
|
|
|
|
|
if(cached.date != null && cached.content != null){
|
|
|
|
|
// if(cached.date != null && cached.content != null){
|
|
|
|
|
|
|
|
|
|
if(new Date(cached.date) >= newDate){
|
|
|
|
|
// if(new Date(cached.date) >= newDate){
|
|
|
|
|
|
|
|
|
|
// Compare Content
|
|
|
|
|
if(cached.content !== newHash){
|
|
|
|
|
isNew = true
|
|
|
|
|
showNewsAlert()
|
|
|
|
|
} else {
|
|
|
|
|
if(!cached.dismissed){
|
|
|
|
|
isNew = true
|
|
|
|
|
showNewsAlert()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// // Compare Content
|
|
|
|
|
// if(cached.content !== newHash){
|
|
|
|
|
// isNew = true
|
|
|
|
|
// showNewsAlert()
|
|
|
|
|
// } else {
|
|
|
|
|
// if(!cached.dismissed){
|
|
|
|
|
// isNew = true
|
|
|
|
|
// showNewsAlert()
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
isNew = true
|
|
|
|
|
showNewsAlert()
|
|
|
|
|
}
|
|
|
|
|
// } else {
|
|
|
|
|
// isNew = true
|
|
|
|
|
// showNewsAlert()
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
isNew = true
|
|
|
|
|
showNewsAlert()
|
|
|
|
|
}
|
|
|
|
|
// } else {
|
|
|
|
|
// isNew = true
|
|
|
|
|
// showNewsAlert()
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
if(isNew){
|
|
|
|
|
ConfigManager.setNewsCache({
|
|
|
|
|
date: newDate.getTime(),
|
|
|
|
|
content: newHash,
|
|
|
|
|
dismissed: false
|
|
|
|
|
})
|
|
|
|
|
ConfigManager.save()
|
|
|
|
|
}
|
|
|
|
|
// if(isNew){
|
|
|
|
|
// ConfigManager.setNewsCache({
|
|
|
|
|
// date: newDate.getTime(),
|
|
|
|
|
// content: newHash,
|
|
|
|
|
// dismissed: false
|
|
|
|
|
// })
|
|
|
|
|
// ConfigManager.save()
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
const switchHandler = (forward) => {
|
|
|
|
|
let cArt = parseInt(newsContent.getAttribute('article'))
|
|
|
|
|
let nxtArt = forward ? (cArt >= newsArr.length-1 ? 0 : cArt + 1) : (cArt <= 0 ? newsArr.length-1 : cArt - 1)
|
|
|
|
|
// const switchHandler = (forward) => {
|
|
|
|
|
// let cArt = parseInt(newsContent.getAttribute('article'))
|
|
|
|
|
// let nxtArt = forward ? (cArt >= newsArr.length-1 ? 0 : cArt + 1) : (cArt <= 0 ? newsArr.length-1 : cArt - 1)
|
|
|
|
|
|
|
|
|
|
displayArticle(newsArr[nxtArt], nxtArt+1)
|
|
|
|
|
}
|
|
|
|
|
// displayArticle(newsArr[nxtArt], nxtArt+1)
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
document.getElementById('newsNavigateRight').onclick = () => { switchHandler(true) }
|
|
|
|
|
document.getElementById('newsNavigateLeft').onclick = () => { switchHandler(false) }
|
|
|
|
|
// document.getElementById('newsNavigateRight').onclick = () => { switchHandler(true) }
|
|
|
|
|
// document.getElementById('newsNavigateLeft').onclick = () => { switchHandler(false) }
|
|
|
|
|
|
|
|
|
|
$('#newsErrorContainer').fadeOut(250, () => {
|
|
|
|
|
displayArticle(newsArr[0], 1)
|
|
|
|
|
$('#newsContent').fadeIn(250, () => {
|
|
|
|
|
resolve()
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// $('#newsErrorContainer').fadeOut(250, () => {
|
|
|
|
|
// displayArticle(newsArr[0], 1)
|
|
|
|
|
// $('#newsContent').fadeIn(250, () => {
|
|
|
|
|
// resolve()
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// })
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add keyboard controls to the news UI. Left and right arrows toggle
|
|
|
|
|