sync
This commit is contained in:
parent
8b3e93e1fc
commit
76fab1c44c
|
|
@ -10,116 +10,179 @@
|
||||||
// @version 0.0.1
|
// @version 0.0.1
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
|
// setup some variables
|
||||||
|
var apiGroup = $("div.form-group").filter(":contains('API Service')");
|
||||||
|
var authGroup = $("div.form-group").filter(":contains('Authentication')");
|
||||||
|
var computeGroup = $("div.form-group").filter(":contains('Compute Service')");
|
||||||
|
var jobsGroup = $("div.form-group").filter(":contains('Jobs Service')");
|
||||||
|
var odbcGroup = $("div.form-group").filter(":contains('ODBC/JDBC Service')");
|
||||||
|
var webappGroup = $("div.form-group").filter(":contains('User Interface')");
|
||||||
|
|
||||||
//console.log($("div.clearfix.prettycheckbox.labelright.blue").filter(":contains('West US 2')")
|
var componentArray = ["api", "auth", "compute", "jobs", "odbc", "webapp"];
|
||||||
//
|
var selectedComponents = new Map();
|
||||||
//
|
var i;
|
||||||
|
for (i = 0; i < componentArray.length; i++) {
|
||||||
function getAllMethods(obj = this) {
|
selectedComponents.set(componentArray[i], 0);
|
||||||
return Object.keys(obj)
|
|
||||||
.filter((key) => typeof obj[key] === 'function')
|
|
||||||
.map((key) => obj[key]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var apiGroup = $("div.form-group").filter(":contains('API Service')")
|
for (i = 0; i < componentArray.length; i++) {
|
||||||
var authGroup = $("div.form-group").filter(":contains('Authentication')")
|
var component = componentArray[i];
|
||||||
var computeGroup = $("div.form-group").filter(":contains('Compute Service')")
|
if (selectedComponents.get(component) == 0){
|
||||||
var jobsGroup = $("div.form-group").filter(":contains('Jobs Service')")
|
var groupName = component + "Group";
|
||||||
var odbcGroup = $("div.form-group").filter(":contains('ODBC/JDBC Service')")
|
console.log(groupName);
|
||||||
var webappGroup = $("div.form-group").filter(":contains('User Interface')")
|
var group = window[groupName];
|
||||||
|
console.log(group);
|
||||||
var componentArray = []
|
|
||||||
|
|
||||||
var testObj = apiGroup.find('*').filter(":contains('canadacentral')").filter("div.clearfix.prettycheckbox.labelright.blue").children().filter("A")[0]
|
|
||||||
console.log(Object.keys(testObj))
|
|
||||||
console.log(testObj)
|
|
||||||
|
|
||||||
|
|
||||||
var zNode = document.createElement ('div');
|
|
||||||
zNode.innerHTML = '<button id="allComponentsButton" type="button">AllComponents</button><button id="apiButton" type="button">API</button><button id="authButton">Auth</button>'
|
|
||||||
+ '<button id="computeButton" type="button">Compute</button><button id="jobsButton" type="button">Jobs</button><button id="ojdbcButton" type="button">ODBC/JDBC</button>'
|
|
||||||
+ '<button id="webappButton" type="button">Webapp</button></br></br><button id="canadaCentralButton" type="button">canadacentral</button><button id = jarvisButton>Jarvis'
|
|
||||||
+ '</button><button id=ascButton>ASC</button><button id = kustoButton>Kusto</button> <button id = printArrayButton>Print Array</button>'
|
|
||||||
;
|
|
||||||
zNode.setAttribute ('id', 'myContainer');
|
|
||||||
document.body.appendChild (zNode);
|
|
||||||
|
|
||||||
document.getElementById ("apiButton").addEventListener("click", apiButtonClickAction, false);
|
|
||||||
//--- Activate the newly added button.
|
|
||||||
document.getElementById ("canadaCentralButton").addEventListener (
|
|
||||||
"click", canadaCentralButtonClickAction, false
|
|
||||||
);
|
|
||||||
document.getElementById ("jarvisButton").addEventListener (
|
|
||||||
"click", jarvisButtonClickAction, false
|
|
||||||
);
|
|
||||||
document.getElementById ("ascButton").addEventListener (
|
|
||||||
"click", ascButtonClickAction, false
|
|
||||||
);
|
|
||||||
document.getElementById ("kustoButton").addEventListener (
|
|
||||||
"click", kustoButtonClickAction, false
|
|
||||||
);
|
|
||||||
document.getElementById ("printArrayButton").addEventListener (
|
|
||||||
"click", printArrayClickAction, false
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
function checkBoxToggle(box) {
|
|
||||||
if (box.getAttribute("class") == "checked") {
|
|
||||||
box.setAttribute("class", "")
|
|
||||||
} else {
|
|
||||||
box.setAttribute("class", "checked")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function apiButtonClickAction (zEvent) {
|
|
||||||
componentArray.push(apiGroup)
|
// load actions
|
||||||
|
var testObj = apiGroup.find('*').filter(":contains('canadacentral')").filter("div.clearfix.prettycheckbox.labelright.blue").children().filter("A")[0];
|
||||||
|
console.log(Object.keys(testObj));
|
||||||
|
console.log(testObj);
|
||||||
|
|
||||||
|
// draw frame
|
||||||
|
var zNode = document.createElement('div');
|
||||||
|
zNode.innerHTML = '<button id="allComponentsButton" type="button">AllComponents</button><button id="apiButton" type="button">API</button><button id="authButton">Auth</button>' +
|
||||||
|
'<button id="computeButton" type="button">Compute</button><button id="jobsButton" type="button">Jobs</button><button id="odbcButton" type="button">ODBC/JDBC</button>' +
|
||||||
|
'<button id="webappButton" type="button">Webapp</button></br></br><button id="canadaCentralButton" type="button">canadacentral</button>' +
|
||||||
|
' <button id = printArrayButton>Print Array</button>';
|
||||||
|
zNode.setAttribute('id', 'myContainer');
|
||||||
|
document.body.appendChild(zNode);
|
||||||
|
|
||||||
|
// component buttons
|
||||||
|
document.getElementById("apiButton").addEventListener(
|
||||||
|
"click", apiButtonClickAction, false
|
||||||
|
);
|
||||||
|
|
||||||
|
function apiButtonClickAction(zEvent) {
|
||||||
|
toggleComponent("api", "apiButton");
|
||||||
|
console.log(selectedComponents);
|
||||||
}
|
}
|
||||||
function canadaCentralButtonClickAction (zEvent) {
|
document.getElementById("authButton").addEventListener(
|
||||||
|
"click", authButtonClickAction, false
|
||||||
checkBoxToggle(testObj);
|
);
|
||||||
}
|
|
||||||
function jarvisButtonClickAction (zEvent) {
|
|
||||||
window.open(jarvisURL, "_blank");
|
|
||||||
}
|
|
||||||
function ascButtonClickAction (zEvent) {
|
|
||||||
window.open(ascURL, "_blank");
|
|
||||||
}
|
|
||||||
function kustoButtonClickAction (zEvent) {
|
|
||||||
GM_setClipboard(template, "kusto queries");
|
|
||||||
alert(`Kusto queries for ${cluster} have been copied to clipboard!`);
|
|
||||||
}
|
|
||||||
function printArrayClickAction (zEvent) {
|
|
||||||
console.log(componentArray)
|
|
||||||
}
|
|
||||||
|
|
||||||
//--- Style our newly added elements using CSS.
|
function authButtonClickAction(zEvent) {
|
||||||
GM_addStyle ( multilineStr ( function () {/*!
|
toggleComponent("auth", "authButton");
|
||||||
#myContainer {
|
console.log(selectedComponents);
|
||||||
position: fixed;
|
}
|
||||||
bottom: 0;
|
document.getElementById("computeButton").addEventListener(
|
||||||
right: 0;
|
"click", computeButtonClickAction, false
|
||||||
font-size: 14px;
|
);
|
||||||
background: orange;
|
|
||||||
border: 3px outset black;
|
|
||||||
margin: 3px;
|
|
||||||
opacity: 0.7;
|
|
||||||
z-index: 222;
|
|
||||||
padding: 5px 5px;
|
|
||||||
}
|
|
||||||
#myButton {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
#myContainer p {
|
|
||||||
color: red;
|
|
||||||
background: white;
|
|
||||||
}
|
|
||||||
*/} ) );
|
|
||||||
|
|
||||||
function multilineStr (dummyFunc) {
|
function computeButtonClickAction(zEvent) {
|
||||||
var str = dummyFunc.toString ();
|
toggleComponent("compute", "computeButton");
|
||||||
str = str.replace (/^[^\/]+\/\*!?/, '') // Strip function () { /*!
|
console.log(selectedComponents);
|
||||||
.replace (/\s*\*\/\s*\}\s*$/, '') // Strip */ }
|
}
|
||||||
.replace (/\/\/.+$/gm, '') // Double-slash comments wreck CSS. Strip them.
|
document.getElementById("jobsButton").addEventListener(
|
||||||
;
|
"click", jobsButtonClickAction, false
|
||||||
return str;
|
);
|
||||||
}
|
|
||||||
|
function jobsButtonClickAction(zEvent) {
|
||||||
|
toggleComponent("jobs", "jobsButton");
|
||||||
|
console.log(selectedComponents);
|
||||||
|
}
|
||||||
|
document.getElementById("odbcButton").addEventListener(
|
||||||
|
"click", odbcButtonClickAction, false
|
||||||
|
);
|
||||||
|
|
||||||
|
function odbcButtonClickAction(zEvent) {
|
||||||
|
toggleComponent("odbc", "odbcButton");
|
||||||
|
console.log(selectedComponents);
|
||||||
|
}
|
||||||
|
document.getElementById("webappButton").addEventListener(
|
||||||
|
"click", webappButtonClickAction, false
|
||||||
|
);
|
||||||
|
|
||||||
|
function webappButtonClickAction(zEvent) {
|
||||||
|
toggleComponent("webapp", "webappButton");
|
||||||
|
console.log(selectedComponents);
|
||||||
|
}
|
||||||
|
document.getElementById("allComponentsButton").addEventListener(
|
||||||
|
"click", allComponentsButtonClickAction, false
|
||||||
|
);
|
||||||
|
|
||||||
|
function allComponentsButtonClickAction(zEvent) {
|
||||||
|
for (i = 0; i < componentArray.length; i++) {
|
||||||
|
var component = componentArray[i];
|
||||||
|
var buttonName = component + "Button";
|
||||||
|
toggleComponent(component, buttonName);
|
||||||
|
console.log(buttonName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// regional buttons
|
||||||
|
document.getElementById("canadaCentralButton").addEventListener(
|
||||||
|
"click", canadaCentralButtonClickAction, false
|
||||||
|
);
|
||||||
|
|
||||||
|
function canadaCentralButtonClickAction(zEvent) {
|
||||||
|
|
||||||
|
checkBoxToggle(testObj, "canadaCentralButton");
|
||||||
|
}
|
||||||
|
// aux buttons
|
||||||
|
document.getElementById("printArrayButton").addEventListener(
|
||||||
|
"click", printArrayClickAction, false
|
||||||
|
);
|
||||||
|
|
||||||
|
function printArrayClickAction(zEvent) {
|
||||||
|
console.log(componentArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
// aux functions
|
||||||
|
function toggleComponent(component, buttonName) {
|
||||||
|
if (selectedComponents.get(component) == 0) {
|
||||||
|
selectedComponents.set(component, 1);
|
||||||
|
document.getElementById(buttonName).style.background = '#00FF00';
|
||||||
|
} else {
|
||||||
|
selectedComponents.set(component, 0);
|
||||||
|
document.getElementById(buttonName).style.background = '#FFFFFF';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkBoxToggle(box, buttonName) {
|
||||||
|
if (box.getAttribute("class") == "checked") {
|
||||||
|
box.setAttribute("class", "");
|
||||||
|
document.getElementById(buttonName).style.background = '#FFFFFF';
|
||||||
|
} else {
|
||||||
|
box.setAttribute("class", "checked");
|
||||||
|
document.getElementById(buttonName).style.background = '#00FF00';
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function multilineStr(dummyFunc) {
|
||||||
|
var str = dummyFunc.toString();
|
||||||
|
str = str.replace(/^[^\/]+\/\*!?/, '') // Strip function () { /*!
|
||||||
|
.replace(/\s*\*\/\s*\}\s*$/, '') // Strip */ }
|
||||||
|
.replace(/\/\/.+$/gm, '') // Double-slash comments wreck CSS. Strip them.
|
||||||
|
;
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// frame CSS style
|
||||||
|
GM_addStyle(multilineStr(function() {
|
||||||
|
/*!
|
||||||
|
#myContainer {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0;
|
||||||
|
right: 0;
|
||||||
|
font-size: 14px;
|
||||||
|
background: orange;
|
||||||
|
border: 3px outset black;
|
||||||
|
margin: 3px;
|
||||||
|
opacity: 0.7;
|
||||||
|
z-index: 222;
|
||||||
|
padding: 5px 5px;
|
||||||
|
}
|
||||||
|
#myButton {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
#myContainer p {
|
||||||
|
color: red;
|
||||||
|
background: white;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue