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