sync
This commit is contained in:
parent
8b3e93e1fc
commit
76fab1c44c
|
|
@ -10,116 +10,179 @@
|
|||
// @version 0.0.1
|
||||
// ==/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')")
|
||||
//
|
||||
//
|
||||
|
||||
function getAllMethods(obj = this) {
|
||||
return Object.keys(obj)
|
||||
.filter((key) => typeof obj[key] === 'function')
|
||||
.map((key) => obj[key]);
|
||||
var componentArray = ["api", "auth", "compute", "jobs", "odbc", "webapp"];
|
||||
var selectedComponents = new Map();
|
||||
var i;
|
||||
for (i = 0; i < componentArray.length; i++) {
|
||||
selectedComponents.set(componentArray[i], 0);
|
||||
}
|
||||
|
||||
|
||||
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')")
|
||||
|
||||
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")
|
||||
for (i = 0; i < componentArray.length; i++) {
|
||||
var component = componentArray[i];
|
||||
if (selectedComponents.get(component) == 0){
|
||||
var groupName = component + "Group";
|
||||
console.log(groupName);
|
||||
var group = window[groupName];
|
||||
console.log(group);
|
||||
}
|
||||
}
|
||||
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) {
|
||||
|
||||
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)
|
||||
}
|
||||
document.getElementById("authButton").addEventListener(
|
||||
"click", authButtonClickAction, false
|
||||
);
|
||||
|
||||
//--- Style our newly added elements using CSS.
|
||||
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;
|
||||
}
|
||||
*/} ) );
|
||||
function authButtonClickAction(zEvent) {
|
||||
toggleComponent("auth", "authButton");
|
||||
console.log(selectedComponents);
|
||||
}
|
||||
document.getElementById("computeButton").addEventListener(
|
||||
"click", computeButtonClickAction, false
|
||||
);
|
||||
|
||||
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;
|
||||
}
|
||||
function computeButtonClickAction(zEvent) {
|
||||
toggleComponent("compute", "computeButton");
|
||||
console.log(selectedComponents);
|
||||
}
|
||||
document.getElementById("jobsButton").addEventListener(
|
||||
"click", jobsButtonClickAction, false
|
||||
);
|
||||
|
||||
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