From 527c914a426def8680cbb3c97dcc3c7bc551aaf5 Mon Sep 17 00:00:00 2001 From: "R. Aidan Campbell" Date: Sat, 12 Mar 2016 19:25:25 -0500 Subject: [PATCH] now with nice resume/run text changes. This closes #20 --- static/js/index.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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