diff --git a/static/js/index.js b/static/js/index.js index bbbc25c..79eb05e 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -14,6 +14,7 @@ function attachListeners() { $('#bitrateSlider').on('change', saveBitrate); // change occurs once the mouse lets go. $('#startGameButton').on('click', startSelectedGame); $('#quitGameButton').on('click', stopGame); + $('#selectGame').on('change', gameSelectUpdated); $(window).resize(fullscreenNaclModule); } @@ -70,7 +71,7 @@ function hideAllWorkflowDivs() { $('#streamSettings').css('display', 'inline-block'); $('#hostSettings').css('display', 'inline-block'); $('#gameSelection').css('display', 'none'); - // common.hideModule(); // do NOT hide the nacl module. you can't interact with it then + // do NOT hide the nacl module. you can't interact with it then } // pair button was pushed. pass what the user entered into the GFEHostIPField. @@ -140,6 +141,7 @@ function showAppsPushed() { $('#selectGame')[0].appendChild(opt); } if (api.currentGame != 0) $('#selectGame')[0].value = api.currentGame; + gameSelectUpdated(); // default the button to 'Resume Game' if one is running. }); }); showAppsMode(); @@ -154,6 +156,20 @@ function showAppsMode() { $("body").css('backgroundColor', 'white'); } +// every time the user selects an app from the select menu, +// we want to check if that's the currently running app +// and if it is, we want the "run" button to change to "resume" +function gameSelectUpdated() { + var currentApp = $("#selectGame").val(); + api.refreshServerInfo().then(function (ret) { + if(api.currentGame == parseInt(currentApp)) { + $("#startGameButton")[0].innerHTML = 'Resume Game' + } else { + $("#startGameButton")[0].innerHTML = 'Run Game' + } + }); +} + function startSelectedGame() { // do NOT update the target. // we're just grabbing the currently selected option from #selectGame, and feeding it into NvHTTP