urlparams: rewrite

This commit is contained in:
louis f 2018-12-29 12:45:27 -05:00
parent 01245c4477
commit 9ca49d25cc
2 changed files with 11 additions and 6 deletions

View File

@ -54,6 +54,7 @@ function onBodyLoaded() {
(function checkIsLoaded() { (function checkIsLoaded() {
if(bodyLoaded) { if(bodyLoaded) {
document.getElementById('loading-font').style.cssText = "display: none;"; document.getElementById('loading-font').style.cssText = "display: none;";
loadQueryParameters();
loadLocalStorage(); loadLocalStorage();
} }
if(utageLoaded && languagesLoaded) { if(utageLoaded && languagesLoaded) {
@ -77,15 +78,11 @@ function onAllLoaded(success) {
document.getElementById('parent-container').style.cssText = "opacity: 1;"; document.getElementById('parent-container').style.cssText = "opacity: 1;";
onWindowResize(); onWindowResize();
window.addEventListener("resize", onWindowResize); window.addEventListener("resize", onWindowResize);
if(urlParams['mstid'] && urlParams['id'] && utage.groupedMissions[urlParams['mstid']] && utage.groupedMissions[urlParams['mstid']].Missions[urlParams['id']]) {
document.getElementById('play-from-query').style.cssText = "position: fixed; z-index: 15; text-align: center; top: 50%; left: 50%; display: block;";
}
}, 0); }, 0);
} }
function loadLocalStorage() { function loadLocalStorage() {
try { try {
urlParams = commonFunctions.readQueryParameters();
//audio //audio
volume = localStorage.getItem('volume') || 0.5; volume = localStorage.getItem('volume') || 0.5;
volume = Number(volume); volume = Number(volume);
@ -156,6 +153,14 @@ function buildLanguageList() {
selectBox.value = selectedLang; selectBox.value = selectedLang;
} }
function loadQueryParameters() {
urlParams = commonFunctions.readQueryParameters();
if(urlParams['mstid'] && urlParams['id'] && utage.groupedMissions[urlParams['mstid']] && utage.groupedMissions[urlParams['mstid']].Missions[urlParams['id']]) {
document.getElementById('play-from-query').style.cssText = "position: fixed; z-index: 15; text-align: center; top: 50%; left: 50%; display: block;";
}
}
function playFromQuery(event) { function playFromQuery(event) {
missionChanged(urlParams['mstid'], urlParams['id']); missionChanged(urlParams['mstid'], urlParams['id']);
document.getElementById('play-from-query').style.cssText = "display: none;"; document.getElementById('play-from-query').style.cssText = "display: none;";

View File

@ -18,7 +18,7 @@
<script src="Js/Player.js"></script> <script src="Js/Player.js"></script>
<script src="Js/Main.js"></script> --> <script src="Js/Main.js"></script> -->
<script src="Js/XduPlayer.min.js"></script> <script src="Js/XduPlayer.min.js"></script>
<div id="loading-container" class="centered"> <div id="loading-container" class="centered" style="z-index: 20;">
<h2 id="loading-utage">Loading Utage Data...</h2> <h2 id="loading-utage">Loading Utage Data...</h2>
<h2 id="loading-font">Loading Page Data...</h2> <h2 id="loading-font">Loading Page Data...</h2>
</div> </div>
@ -78,4 +78,4 @@
<span style="font-family: 'SourceCodePro-Regular'">test</span> --> <span style="font-family: 'SourceCodePro-Regular'">test</span> -->
</div> </div>
</body> </body>
</html> </html>