diff --git a/html5/index.html b/html5/index.html
index 394e1ed..18ecf5e 100644
--- a/html5/index.html
+++ b/html5/index.html
@@ -132,10 +132,10 @@
-
+
-
+
@@ -160,7 +160,7 @@
diff --git a/html5/kubeinvaders.js b/html5/kubeinvaders.js
index 1dd2b74..0a07f71 100644
--- a/html5/kubeinvaders.js
+++ b/html5/kubeinvaders.js
@@ -81,6 +81,8 @@ var alert_div = '');
- aliens = [];
- pods = [];
+ switchNamespace();
}
else if(e.keyCode == 72) {
if (help) {
@@ -344,6 +336,19 @@ function keyDownHandler(e) {
}
}
+function switchNamespace() {
+ if (namespaces_index < namespaces.length-1) {
+ namespaces_index +=1 ;
+ }
+ else {
+ namespaces_index = 0;
+ }
+ namespace = namespaces[namespaces_index];
+ $('#alert_placeholder').replaceWith(alert_div + 'Latest action: Change target namespace to ' + namespace + '
');
+ aliens = [];
+ pods = [];
+}
+
function keyUpHandler(e) {
if(e.key == "Right" || e.key == "ArrowRight") {
rightPressed = false;
@@ -455,6 +460,11 @@ function drawSpaceship() {
function getRandomInt(max) {
return Math.floor(Math.random() * max);
}
+window.setInterval(function draw() {
+ if (namespacesJumpFlag){
+ randNamespaceJump(1, 10, 8);
+ }
+}, 1000)
window.setInterval(function draw() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
@@ -502,7 +512,6 @@ window.setInterval(function draw() {
spaceshipX -= 5;
}
}
-
}
if(rightPressed) {
@@ -539,9 +548,11 @@ window.setInterval(function draw() {
}
ctx.fillStyle = 'white';
ctx.font = '15px Verdana';
- ctx.fillText('Cluster: ' + endpoint, 10, 400);
- ctx.fillText('Current Namespace: ' + namespace, 10, 420);
- ctx.fillText('Alien Shuffle: ' + shuffle, 10, 440);
+ ctx.fillText('Cluster: ' + endpoint, 10, 390);
+ ctx.fillText('Current Namespace: ' + namespace, 10, 410);
+ ctx.fillText('Alien Shuffle: ' + shuffle, 10, 430);
+ ctx.fillText('Auto Namespaces Switch: ' + namespacesJumpStaus, 10, 450);
+
ctx.fillText('press \'h\' for help!', 10, 470);
if (help) {
@@ -566,6 +577,20 @@ function buttonShuffleHelper() {
}
}
+function namespacesJumpControl() {
+ if (namespacesJumpFlag) {
+ namespacesJumpFlag = false;
+ $("#namespacesJumpButton").text("Enable Auto NS Switch");
+ $('#alert_placeholder').replaceWith(alert_div + 'Latest action: Disabled automatic switch of namespace');
+ namespacesJumpStaus = 'Disabled'
+ } else {
+ namespacesJumpFlag = true;
+ $("#namespacesJumpButton").text("Disable Auto NS Switch");
+ $('#alert_placeholder').replaceWith(alert_div + 'Latest action: Enabled automatic switch of namespace ');
+ namespacesJumpStaus = 'Enabled'
+ }
+}
+
function showPodNameControl() {
if (showPodName) {
showPodName = false;
@@ -594,11 +619,19 @@ function findReplace() {
}
return -1;
}
-
+
+function randNamespaceJump(min, max, jumpRandomFactor) {
+ if ((Math.random() * (max - min) + min) > jumpRandomFactor) {
+ $('#alert_placeholder').replaceWith(alert_div + 'Latest action: Switch Namespace');
+ switchNamespace();
+ }
+}
window.setInterval(function setAliens() {
+
if (shuffle) {
pods = pods.sort(() => Math.random() - 0.5)
}
+
aliens = [];
//console.log("Length of aliensY array: " + aliensY.length);
if (pods.length > 0) {