working on debug statements

This commit is contained in:
Tyler 2021-06-23 11:34:54 -05:00
parent d3c08de5a3
commit fbbb8469d4
1 changed files with 113 additions and 11 deletions

View File

@ -10,7 +10,6 @@
// @version 0.0.1
// ==/UserScript==
// draw frame
var zNode = document.createElement('div');
zNode.setAttribute('id', 'myContainer');
@ -18,16 +17,23 @@ document.body.appendChild(zNode);
var auxHTML = '<center><button id="applyButton" type="button">Apply Selection</button><button id="resetButton" type="button">Reset Form</button><center>';
var debugFlag = true;
//azure status page controls
if (window.location.href.indexOf("5d49ec10226b9e13cb6a422e") > -1) {
// render initial HTML
var profilesHTML = '<center><button id="controlplanesButton" type="button">Controlplanes</button> ' +
'<button id="stagesButton" type="button">Stages</button> <button id="dataplanesButton" type="button">' +
'Dataplanes</button> <button id="shrinkButton" type="button">Shrink</button></center>';
'Dataplanes</button> <button id="shrinkButton" type="button">Shrink</button> <button id="debugButton" type="button">Debug</button></center>';
zNode.innerHTML = profilesHTML;
if (debugFlag == true) {
toggleButtonColor(debugButton);
};
document.getElementById("controlplanesButton").addEventListener("click", controlplanesButtonClickAction, false);
document.getElementById("dataplanesButton").addEventListener("click", dataplanesButtonClickAction, false);
document.getElementById("stagesButton").addEventListener("click", stagesButtonClickAction, false);
document.getElementById("shrinkButton").addEventListener("click", shrinkButtonClickAction, false);
document.getElementById("debugButton").addEventListener("click", debugButtonClickAction, false);
// initialize azure component and region variables
var componentArray = ["api", "auth", "compute", "jobs", "odbc", "webapp", "sql"];
@ -342,7 +348,6 @@ if (window.location.href.indexOf("5d49ec10226b9e13cb6a422e") > -1) {
toggleButtonColor("sqlButton");
};
// profile management functions
function loadDataplanes() {
console.log("Loading Azure dataplanes profile");
@ -350,6 +355,9 @@ if (window.location.href.indexOf("5d49ec10226b9e13cb6a422e") > -1) {
zNode.innerHTML = profilesHTML + '<hr class="solid">' + dataplaneHTML + '<hr class="solid">' + componentsHTML +
auxHTML;
if (debugFlag == true) {
toggleButtonColor(debugButton);
};
// array of active buttons
buttonArray = ["canadacentral", "canadaeast", "centralindia", "southindia", "westindia",
@ -403,6 +411,7 @@ if (window.location.href.indexOf("5d49ec10226b9e13cb6a422e") > -1) {
document.getElementById("dataplanesButton").addEventListener("click", dataplanesButtonClickAction, false);
document.getElementById("stagesButton").addEventListener("click", stagesButtonClickAction, false);
document.getElementById("shrinkButton").addEventListener("click", shrinkButtonClickAction, false);
document.getElementById("debugButton").addEventListener("click", debugButtonClickAction, false);
// component listeners
document.getElementById("apiButton").addEventListener("click", apiButtonClickAction, false);
@ -422,6 +431,9 @@ if (window.location.href.indexOf("5d49ec10226b9e13cb6a422e") > -1) {
console.log("Loading Azure controlplanes profile");
var controlplaneHTML = '<center><button id="canadacentralButton" style="width:234px" type="button">Canada Central</button><button id="centralindiaButton" style="width:234px" type="button">Central India</button></br><button id="switzerlandnorthButton" style="width:234px" type="button">Switzerland North</button><button id="norwayeastButton" style="width:234px" type="button">Norway East</button></br></br><button id="westusButton" style="width:468px" type="button">West US</button></br></br><button id="westeuropeButton" style="width:234px" type="button">West Europe</button><button id="ukwestButton" style="width:234px" type="button">UK West</button></br><button id="southafricanorthButton" style="width:234px" type="button">South Africa North</button><button id="uaenorthButton" style="width:234px" type="button">UAE North</button></br></br><button id="australiaeastButton" style="width:117px" type="button">Australia East</button><button id="japaneastButton" style="width:117px" type="button">Japan East</button><button id="koreacentralButton" style="width:117px" type="button">Korea Central</button><button id="southeastasiaButton" style="width:117px" type="button">Southeast Asia</button></br></br><button id="brazilsouthButton" style="width:156px" type="button">Brazil South</button><button id="eastus2Button" style="width:156px" type="button">East US 2</button><button id="francecentralButton" style="width:156px" type="button">France Central</button></br></br><button id="chinanorth2Button" style="width:117px" type="button">China North 2</button><button id="chinaeast2Button" style="width:117px" type="button">China East 2</button><button id="usgovvirginiaButton" style="width:117px" type="button">US Gov Virginia</button><button id="usgovarizonaButton" style="width:117px" type="button">US Gov Arizona</button></center>';
zNode.innerHTML = profilesHTML + '<hr class="solid">' + controlplaneHTML + '<hr class="solid">' + componentsHTML + auxHTML;
if (debugFlag == true) {
toggleButtonColor(debugButton);
};
// array of active buttons
buttonArray = ["canadacentral", "centralindia", "switzerlandnorth", "norwayeast", "westus", "westeurope","ukwest", "southafricanorth",
@ -458,6 +470,7 @@ if (window.location.href.indexOf("5d49ec10226b9e13cb6a422e") > -1) {
document.getElementById("dataplanesButton").addEventListener("click", dataplanesButtonClickAction, false);
document.getElementById("stagesButton").addEventListener("click", stagesButtonClickAction, false);
document.getElementById("shrinkButton").addEventListener("click", shrinkButtonClickAction, false);
document.getElementById("debugButton").addEventListener("click", debugButtonClickAction, false);
// component listeners
document.getElementById("apiButton").addEventListener("click", apiButtonClickAction, false);
@ -478,6 +491,9 @@ if (window.location.href.indexOf("5d49ec10226b9e13cb6a422e") > -1) {
var stagesHTML = '<center><button id="stage1Button" style="width:94px" type="button">Stage-1</button><button id="stage1point5Button" style="width:94px" type="button">Stage-1.5</button><button id="stage2Button" style="width:92px" type="button">Stage-2</button><button id="stage3amButton" style="width:94px" type="button">Stage-3AM</button><button id="stage3pmButton" style="width:94px" type="button">Stage-3PM</button></br><button id="stagegovcloudButton" style="width:234px" type="button">Govcloud</button><button id="stagemooncakeButton" style="width:234px" type="button">Mooncake</button></center>';
zNode.innerHTML = profilesHTML + '<hr class="solid">' + stagesHTML + '<hr class="solid">' + componentsHTML + auxHTML;
if (debugFlag == true) {
toggleButtonColor(debugButton);
};
// array of active buttons
buttonArray = ["stage1", "stage1point5", "stage2", "stage3am", "stage3pm", "stagegovcloud", "stagemooncake"];
@ -497,6 +513,7 @@ if (window.location.href.indexOf("5d49ec10226b9e13cb6a422e") > -1) {
document.getElementById("dataplanesButton").addEventListener("click", dataplanesButtonClickAction, false);
document.getElementById("stagesButton").addEventListener("click", stagesButtonClickAction, false);
document.getElementById("shrinkButton").addEventListener("click", shrinkButtonClickAction, false);
document.getElementById("debugButton").addEventListener("click", debugButtonClickAction, false);
// component listeners
document.getElementById("apiButton").addEventListener("click", apiButtonClickAction, false);
@ -514,6 +531,10 @@ if (window.location.href.indexOf("5d49ec10226b9e13cb6a422e") > -1) {
};
function shrink() {
zNode.innerHTML = profilesHTML
if (debugFlag == true) {
toggleButtonColor(debugButton);
};
document.getElementById("controlplanesButton").addEventListener("click", controlplanesButtonClickAction, false);
document.getElementById("dataplanesButton").addEventListener("click", dataplanesButtonClickAction, false);
document.getElementById("stagesButton").addEventListener("click", stagesButtonClickAction, false);
@ -521,22 +542,28 @@ if (window.location.href.indexOf("5d49ec10226b9e13cb6a422e") > -1) {
};
};
// aws status page controls
if (window.location.href.indexOf("5cf02dde58a00904bda41926") > -1) {
// render initial HTML
var profilesHTML = '<center><button id="controlplanesButton" type="button">Controlplanes</button> ' +
'<button id="stagesButton" type="button">Stages</button> <button id="dataplanesButton" type="button">' +
'Dataplanes</button> <button id="shrinkButton" type="button">Shrink</button></center>';
'Dataplanes</button> <button id="shrinkButton" type="button">Shrink</button> <button id="debugButton" type="button">Debug</button></center>';
zNode.innerHTML = profilesHTML;
if (debugFlag == true) {
toggleButtonColor(debugButton);
};
document.getElementById("controlplanesButton").addEventListener("click", controlplanesButtonClickAction, false);
document.getElementById("dataplanesButton").addEventListener("click", dataplanesButtonClickAction, false);
document.getElementById("stagesButton").addEventListener("click", stagesButtonClickAction, false);
document.getElementById("shrinkButton").addEventListener("click", shrinkButtonClickAction, false);
document.getElementById("debugButton").addEventListener("click", debugButtonClickAction, false);
// initialize azure component and region variables
var componentArray = ["api", "auth", "compute", "jobs", "odbc", "webapp", "sql"];
var regionArray = ["us-west-1", "us-west-2", "us-east-1", "us-east-2", "sa-east-1", "eu-west-1", "eu-west-2", "eu-central-1",
"ap-south-1", "ap-southeast-1", "ap-southeast-2", "ap-northeast-1", "ap-northeast-2", "ca-central-1"];
var buttonArray = [];
var ceFlag = false;
// create tracking maps
var selectedComponents = new Map();
@ -619,6 +646,30 @@ if (window.location.href.indexOf("5cf02dde58a00904bda41926") > -1) {
toggleRegion("canadaeast");
toggleButtonColor("canadacentralButton");
};
function ceButtonClickAction(zEvent) {
toggleButtonColor("ceButton");
toggleCe();
};
function selectCe() {
ceFlag = true;
if (debugFlag = true) {
console.log("DEBUG: ceFlag = " + ceFlag);
};
};
function deselectCe() {
ceFlag = false;
};
function toggleCe() {
if (checkCe == false) {
selectCe();
} else {
deselectCe();
}
};
function checkCe() {
var status = ceFlag;
return status;
};
// profile management functions
function loadDataplanes() {
@ -626,6 +677,9 @@ if (window.location.href.indexOf("5cf02dde58a00904bda41926") > -1) {
var dataplaneHTML = '<center><button id="ceButton" style="width:117px" type="button">CE</button><button id="cacentral1Button" style="width:117px" type="button">ca-central-1</button><button id="eucentral1Button" style="width:117px" type="button">eu-central-1</button><button id="euwest2Button" style="width:117px" type="button">eu-west-2</button></br></br><button id="uswest2Button" style="width:234px" type="button">us-west-2</button><button id="uswest1Button" style="width:234px" type="button">us-west-1</button></br><button id="useast1Button" style="width:234px" type="button">us-east-1</button><button id="useast2Button" style="width:234px" type="button">us-east-2</button></br></br><button id="apsouth1Button" style="width:156px" type="button">ap-south-1</button><button id="apsoutheast2Button" style="width:156px" type="button">ap-southeast-2</button><button id="apnortheast1Button" style="width:156px" type="button">ap-northeast-1</button></br></br><button id="euwest1Button" style="width:468px" type="button">eu-west-1</button></center>';
zNode.innerHTML = profilesHTML + '<hr class="solid">' + dataplaneHTML + '<hr class="solid">' + componentsHTML + auxHTML;
if (debugFlag == true) {
toggleButtonColor(debugButton);
};
// array of active buttons
buttonArray = ["CE", "ca-central-1", "eu-central-1", "eu-west-2", "us-west-2", "us-east-1", "us-east-2", "ap-south-1",
@ -643,12 +697,14 @@ if (window.location.href.indexOf("5cf02dde58a00904bda41926") > -1) {
document.getElementById("apsoutheast2Button").addEventListener("click", apsoutheast2ButtonClickAction, false);
document.getElementById("apnortheast1Button").addEventListener("click", apnortheast1ButtonClickAction, false);
document.getElementById("euwest1Button").addEventListener("click", euwest1ButtonClickAction, false);
document.getElementById("ceButton").addEventListener("click", ceButtonClickAction, false);
// profile listeners
document.getElementById("controlplanesButton").addEventListener("click", controlplanesButtonClickAction, false);
document.getElementById("dataplanesButton").addEventListener("click", dataplanesButtonClickAction, false);
document.getElementById("stagesButton").addEventListener("click", stagesButtonClickAction, false);
document.getElementById("shrinkButton").addEventListener("click", shrinkButtonClickAction, false);
document.getElementById("debugButton").addEventListener("click", debugButtonClickAction, false);
// component listeners
document.getElementById("apiButton").addEventListener("click", apiButtonClickAction, false);
@ -668,6 +724,9 @@ if (window.location.href.indexOf("5cf02dde58a00904bda41926") > -1) {
console.log("Loading AWS controlplanes profile");
var controlplaneHTML = '<center><button id="ceButton" style="width:117px" type="button">CE</button><button id="cacentral1Button" style="width:117px" type="button">ca-central-1</button><button id="eucentral1Button" style="width:117px" type="button">eu-central-1</button><button id="euwest2Button" style="width:117px" type="button">eu-west-2</button></br></br><button id="uswest2Button" style="width:156px" type="button">us-west-2</button><button id="useast1Button" style="width:156px" type="button">us-east-1</button><button id="useast2Button" style="width:156px" type="button">us-east-2</button></br></br><button id="apsouth1Button" style="width:156px" type="button">ap-south-1</button><button id="apsoutheast2Button" style="width:156px" type="button">ap-southeast-2</button><button id="apnortheast1Button" style="width:156px" type="button">ap-northeast-1</button></br></br><button id="euwest1Button" style="width:468px" type="button">eu-west-1</button></center>';
zNode.innerHTML = profilesHTML + '<hr class="solid">' + controlplaneHTML + '<hr class="solid">' + componentsHTML + auxHTML;
if (debugFlag == true) {
toggleButtonColor(debugButton);
};
// array of active buttons
buttonArray = ["canadacentral", "centralindia", "switzerlandnorth", "norwayeast", "westus", "westeurope","ukwest", "southafricanorth",
@ -695,6 +754,7 @@ if (window.location.href.indexOf("5cf02dde58a00904bda41926") > -1) {
document.getElementById("dataplanesButton").addEventListener("click", dataplanesButtonClickAction, false);
document.getElementById("stagesButton").addEventListener("click", stagesButtonClickAction, false);
document.getElementById("shrinkButton").addEventListener("click", shrinkButtonClickAction, false);
document.getElementById("debugButton").addEventListener("click", debugButtonClickAction, false);
// component listeners
document.getElementById("apiButton").addEventListener("click", apiButtonClickAction, false);
@ -715,6 +775,9 @@ if (window.location.href.indexOf("5cf02dde58a00904bda41926") > -1) {
var stagesHTML = '<center><button id="stage1Button" style="width:117px" type="button">Stage-1</button><button id="stage2Button" style="width:117px" type="button">Stage-2</button><button id="stage3amButton" style="width:117px" type="button">Stage-3 AM</button><button id="stage3pmButton" style="width:117px" type="button">Stage-3 PM</button></center>';
zNode.innerHTML = profilesHTML + '<hr class="solid">' + stagesHTML + '<hr class="solid">' + componentsHTML + auxHTML;
if (debugFlag == true) {
toggleButtonColor(debugButton);
}
// array of active buttons
buttonArray = ["stage1", "stage1point5", "stage2", "stage3am", "stage3pm", "stagegovcloud", "stagemooncake"];
@ -745,20 +808,28 @@ if (window.location.href.indexOf("5cf02dde58a00904bda41926") > -1) {
};
function shrink() {
zNode.innerHTML = profilesHTML
if (debugFlag == true) {
toggleButtonColor(debugButton);
};
document.getElementById("controlplanesButton").addEventListener("click", controlplanesButtonClickAction, false);
document.getElementById("dataplanesButton").addEventListener("click", dataplanesButtonClickAction, false);
document.getElementById("stagesButton").addEventListener("click", stagesButtonClickAction, false);
document.getElementById("shrinkButton").addEventListener("click", shrinkButtonClickAction, false);
};
document.getElementById("debugButton").addEventListener("click", debugButtonClickAction, false);
};
};
// gcp status page controls
if (window.location.href.indexOf("60087ab5608daf0535dc8e23") > -1) {
// render initial HTML
var profilesHTML = '<center><button id="controlplanesButton" type="button">Controlplanes</button> ' +
'<button id="stagesButton" type="button">Stages</button> <button id="dataplanesButton" type="button">' +
'Dataplanes</button> <button id="shrinkButton" type="button">Shrink</button></center>';
'Dataplanes</button> <button id="shrinkButton" type="button">Shrink</button> <button id="debugButton" type="button">Debug</button></center>';
zNode.innerHTML = profilesHTML;
if (debugFlag == true) {
toggleButtonColor(debugButton);
};
};
// profile functions
@ -774,6 +845,10 @@ function stagesButtonClickAction(zEvent) {
function shrinkButtonClickAction(zEvent) {
shrink();
};
function debugButtonClickAction(zEvent) {
toggleDebug();
toggleButtonColor("debugButton");
};
// aux functions
function applyButtonClickAction(zEvent) {
@ -831,11 +906,15 @@ function checkRegion(region) {
};
function selectComponent(component) {
selectedComponents.set(component, true);
// console.log(selectedComponents);
if (debugFlag = true) {
console.log(selectedComponents);
}
};
function deselectComponent(component) {
selectedComponents.set(component, false);
// console.log(selectedComponents);
if (debugFlag = true) {
console.log(selectedComponents);
};
};
function toggleRegion(region) {
if (checkRegion(region) == false) {
@ -846,11 +925,15 @@ function toggleRegion(region) {
};
function selectRegion(region) {
selectedRegions.set(region, true);
// console.log(selectedRegions);
if (debugFlag = true) {
console.log(selectedRegions);
};
};
function deselectRegion(region) {
selectedRegions.set(region, false);
// console.log(selectedRegions);
if (debugFlag = true) {
console.log(selectedRegions);
};
};
function setButtonColor(buttonName) {
document.getElementById(buttonName).style.background = '#00FF00';
@ -901,3 +984,22 @@ function reset() {
};
apply();
};
function checkDebug() {
var status = debugFlag;
return status;
};
function toggleDebug() {
if (checkDebug == false) {
enableDebug();
} else {
disableDebug();
};
};
function enableDebug() {
debugFlag = true;
console.log("DEBUG logging enabled");
};
function disableDebug() {
debugFlag = false;
console.log("DEBUG logging disabled");
};