diff --git a/html5/index.html b/html5/index.html index 7f9cde7..790760c 100644 --- a/html5/index.html +++ b/html5/index.html @@ -115,26 +115,41 @@
-
+ +
- +
- +

KubeInvaders

- +
-
-
- + + @@ -148,21 +163,34 @@ Latest Replicas State Delay:  0 sec 
-
- + +
+
+
+ + +
+
-
-
+
@@ -211,6 +239,29 @@ } } + /* TODO: Improve this function... */ + function startGameMode() { + var game_buttons = document.getElementById("game-buttons"); + var game_screen = document.getElementById("game-screen"); + + if (game_mode_switch) { + game_mode_switch = false; + } else { + game_mode_switch = true; + } + + if (game_buttons.style.display === "none") { + game_buttons.style.display = "block"; + } else { + game_buttons.style.display = "none"; + } + if (game_screen.style.display === "none") { + game_screen.style.display = "block"; + } else { + game_screen.style.display = "none"; + } + } + function showSpecialKeys() { $('#showSpecialKeysModal').modal('show'); modal_opened = true; diff --git a/html5/kubeinvaders.js b/html5/kubeinvaders.js index f866b8e..6b9b380 100644 --- a/html5/kubeinvaders.js +++ b/html5/kubeinvaders.js @@ -21,6 +21,7 @@ var spaceshipxOld = 0; var randomFactor = 10; // pods list from kubernetes var pods = []; +var game_mode_switch = false; // nodes list from kubernetes var nodes = []; @@ -252,13 +253,15 @@ function getNodes() { } } -window.setInterval(function getKubeItems() { - getNodes(); - getPods(); +window.setInterval(function getKubeItems() { + if (game_mode_switch) { + getNodes(); + getPods(); + } }, 1000) function keyDownHandler(e) { - if (!modal_opened) { + if (!modal_opened && game_mode_switch) { e.preventDefault(); if(e.key == "Right" || e.key == "ArrowRight") { rightPressed = true; @@ -682,7 +685,9 @@ window.setInterval(function setAliens() { }, 1000) window.setInterval(function metrics() { - getMetrics() + if (game_mode_switch) { + getMetrics() + } }, 2000) getEndpoint(); diff --git a/scripts/programming_mode.lua b/scripts/programming_mode.lua new file mode 100644 index 0000000..3935ffb --- /dev/null +++ b/scripts/programming_mode.lua @@ -0,0 +1,13 @@ +local https = require "ssl.https" +local ltn12 = require "ltn12" +local json = require 'lunajson' +local redis = require "resty.redis" + +if os.getenv("KUBERNETES_SERVICE_HOST") then + k8s_url = "https://" .. os.getenv("KUBERNETES_SERVICE_HOST") .. ":" .. os.getenv("KUBERNETES_SERVICE_PORT_HTTPS") +else + k8s_url = os.getenv("ENDPOINT") +end + +local token = os.getenv("TOKEN") +local arg = ngx.req.get_uri_args()