Skip to content

Commit

Permalink
[reformat] moved capitalWord back into helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Grovkillen committed Mar 26, 2020
1 parent c422e09 commit e1fb94e
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 134 deletions.
6 changes: 2 additions & 4 deletions src/gui_easy.css
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,16 @@ div.gamepads:empty {
}
div.gamepad {
width: calc(1.45 * var(--default-height-size));
padding-top: calc(0.4 * var(--default-height-size));
padding-bottom: calc(0.4 * var(--default-height-size));
margin: calc(0.4 * var(--default-height-size)) calc(0.4 * var(--default-height-size)) calc(0.4 * var(--default-height-size)) calc(3 * var(--default-height-size));
position: relative;
margin-left: calc(2 * var(--default-height-size));
}
div.gamepad > svg {
height: calc(1.45 * var(--default-height-size));
}
div.gamepad > div.number {
position: absolute;
width: calc(0.7 * var(--default-height-size));
top: calc(0.75 * var(--default-height-size));
top: calc(0.9 * var(--default-height-size));
right: 0;
border-radius: calc(1 * var(--default-height-size) / var(--button-radius-size));
font-size: calc(0.6 * var(--default-font-size));
Expand Down
4 changes: 2 additions & 2 deletions src/gui_easy_curly_icons.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

118 changes: 118 additions & 0 deletions src/gui_easy_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,124 @@ const helpEasy = {

array[index].ping.timestamp = Date.now();
},
'capitalWord' : function (str) {
let allCaps = [
"ac","ap",
"bin","bssid",
"cpu",
"dc","dhcp","dns","dst",
"esp",
"gui","gw","gpio","gps",
"http","https",
"ip","id","i2c","io","ir",
"json",
"led","l/r","lcd",
"md5","mqtt","mp3",
"ntp",
"ok","oled",
"p2p",
"rssi","ram","rfid",
"ssid","spi","sda","scl","sta","ssl","smtp","sd",
"ttn",
"udp","uuid",
"wpa"
];
let reformat = [
"AM2320","APDS9960","ADS1115",
"BMP085/180","BMP280","BMx280","BH1750",
"CO2","CSE7766",
"DS18b20","DHT11/12/22","DMX512","DHT12",
"FHEM",
"GitHub","GP2Y10","GY-63",
"HC-SR04","HT16K33","HLW8012/BL0937","HDC1080","HX711",
"iButton","INA219","ID12LA/RDM6300",
"LCD2004","LM75A","LoRa",
"MCP23017","MCP3221","MH-Z19","MLX90614","MS5611","MPU6050","MPR121",
"OpenHAB",
"PCF8591","PCF8574","PCF8574/MCP23017","phpBB","PMSx003","POW","PCA9685","PN532",
"RCW-0001","RN2483/RN2903",
"SHT1x","SHT30/31/35","SGP30","SI7021/HTU21D","SSD1306","SSD1306/SH1106","SDS011/018/198","SMD120C/220T/230/630",
"TSL2561","TSL2591","TCS32725","TCS34725","TSOP4838","TTP229",
"VEML6040","VEML6070"
];
let reformatCheck = [[],[],[],[],[]];
for (let i = 0; i < reformat.length; i++) {
reformatCheck[0].push(reformat[i].toLowerCase());
reformatCheck[1].push("(" + reformat[i].toLowerCase());
reformatCheck[2].push(reformat[i].toLowerCase() + ")");
reformatCheck[3].push("(" + reformat[i].toLowerCase() + ")");
reformatCheck[4].push(reformat[i].toLowerCase() + ",");
}
let allCapsCheck = [[],[],[],[],[]];
for (let i = 0; i < allCaps.length; i++) {
allCapsCheck[0].push(allCaps[i].toLowerCase());
allCapsCheck[1].push("(" + allCaps[i].toLowerCase());
allCapsCheck[2].push(allCaps[i].toLowerCase() + ")");
allCapsCheck[3].push("(" + allCaps[i].toLowerCase() + ")");
allCapsCheck[4].push(allCaps[i].toLowerCase() + ",");
}
let words = str.toLowerCase().split(" ");
for (let i = 0; i < words.length; i++) {
let index = helpEasy.findInArray(words[i], reformatCheck[0]);
if (index > -1) {
words[i] = reformat[index];
continue;
}
index = helpEasy.findInArray(words[i], reformatCheck[3]);
if (index > -1) {
words[i] = "(" + reformat[index] + ")";
continue;
}
index = helpEasy.findInArray(words[i], reformatCheck[1]);
if (index > -1) {
words[i] = "(" + reformat[index];
continue;
}
index = helpEasy.findInArray(words[i], reformatCheck[2]);
if (index > -1) {
words[i] = reformat[index] + ")";
continue;
}
index = helpEasy.findInArray(words[i], reformatCheck[4]);
if (index > -1) {
words[i] = reformat[index] + ",";
continue;
}
//all caps
index = helpEasy.findInArray(words[i], allCapsCheck[0]);
if (index > -1) {
words[i] = allCaps[index].toUpperCase();
continue;
}
index = helpEasy.findInArray(words[i], allCapsCheck[3]);
if (index > -1) {
words[i] = "(" + allCaps[index].toUpperCase() + ")";
continue;
}
index = helpEasy.findInArray(words[i], allCapsCheck[1]);
if (index > -1) {
words[i] = "(" + allCaps[index].toUpperCase();
continue;
}
index = helpEasy.findInArray(words[i], allCapsCheck[2]);
if (index > -1) {
words[i] = allCaps[index].toUpperCase() + ")";
continue;
}
index = helpEasy.findInArray(words[i], allCapsCheck[4]);
if (index > -1) {
words[i] = allCaps[index].toUpperCase() + ",";
continue;
}
//if not found in any of the arrays.. camel case
if (words[i].charAt(0) === "(") {
words[i] = "(" + words[i].charAt(1).toUpperCase() + words[i].substring(2);
} else {
words[i] = words[i].charAt(0).toUpperCase() + words[i].substring(1);
}
}
return words.join(" ");
},
'bumpScheduler': function (array, index, endpoint) {
let nextRun = Date.now() + 10;
let x = array[index]["scheduler"];
Expand Down
119 changes: 0 additions & 119 deletions src/gui_easy_helper_esp_specific.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,125 +13,6 @@ helpEasy.int32binaryBool = function (obj, int, names, base, emptyString = "_empt
}
};

helpEasy.capitalWord = function (str) {
let allCaps = [
"ac","ap",
"bin","bssid",
"cpu",
"dc","dhcp","dns","dst",
"esp",
"gui","gw","gpio","gps",
"http","https",
"ip","id","i2c","io","ir",
"json",
"led","l/r","lcd",
"md5","mqtt","mp3",
"ntp",
"ok","oled",
"p2p",
"rssi","ram","rfid",
"ssid","spi","sda","scl","sta","ssl","smtp","sd",
"ttn",
"udp","uuid",
"wpa"
];
let reformat = [
"AM2320","APDS9960","ADS1115",
"BMP085/180","BMP280","BMx280","BH1750",
"CO2","CSE7766",
"DS18b20","DHT11/12/22","DMX512","DHT12",
"FHEM",
"GitHub","GP2Y10","GY-63",
"HC-SR04","HT16K33","HLW8012/BL0937","HDC1080","HX711",
"iButton","INA219","ID12LA/RDM6300",
"LCD2004","LM75A","LoRa",
"MCP23017","MCP3221","MH-Z19","MLX90614","MS5611","MPU6050","MPR121",
"OpenHAB",
"PCF8591","PCF8574","PCF8574/MCP23017","phpBB","PMSx003","POW","PCA9685","PN532",
"RCW-0001","RN2483/RN2903",
"SHT1x","SHT30/31/35","SGP30","SI7021/HTU21D","SSD1306","SSD1306/SH1106","SDS011/018/198","SMD120C/220T/230/630",
"TSL2561","TSL2591","TCS32725","TCS34725","TSOP4838","TTP229",
"VEML6040","VEML6070"
];
let reformatCheck = [[],[],[],[],[]];
for (let i = 0; i < reformat.length; i++) {
reformatCheck[0].push(reformat[i].toLowerCase());
reformatCheck[1].push("(" + reformat[i].toLowerCase());
reformatCheck[2].push(reformat[i].toLowerCase() + ")");
reformatCheck[3].push("(" + reformat[i].toLowerCase() + ")");
reformatCheck[4].push(reformat[i].toLowerCase() + ",");
}
let allCapsCheck = [[],[],[],[],[]];
for (let i = 0; i < allCaps.length; i++) {
allCapsCheck[0].push(allCaps[i].toLowerCase());
allCapsCheck[1].push("(" + allCaps[i].toLowerCase());
allCapsCheck[2].push(allCaps[i].toLowerCase() + ")");
allCapsCheck[3].push("(" + allCaps[i].toLowerCase() + ")");
allCapsCheck[4].push(allCaps[i].toLowerCase() + ",");
}
let words = str.toLowerCase().split(" ");
for (let i = 0; i < words.length; i++) {
let index = helpEasy.findInArray(words[i], reformatCheck[0]);
if (index > -1) {
words[i] = reformat[index];
continue;
}
index = helpEasy.findInArray(words[i], reformatCheck[3]);
if (index > -1) {
words[i] = "(" + reformat[index] + ")";
continue;
}
index = helpEasy.findInArray(words[i], reformatCheck[1]);
if (index > -1) {
words[i] = "(" + reformat[index];
continue;
}
index = helpEasy.findInArray(words[i], reformatCheck[2]);
if (index > -1) {
words[i] = reformat[index] + ")";
continue;
}
index = helpEasy.findInArray(words[i], reformatCheck[4]);
if (index > -1) {
words[i] = reformat[index] + ",";
continue;
}
//all caps
index = helpEasy.findInArray(words[i], allCapsCheck[0]);
if (index > -1) {
words[i] = allCaps[index].toUpperCase();
continue;
}
index = helpEasy.findInArray(words[i], allCapsCheck[3]);
if (index > -1) {
words[i] = "(" + allCaps[index].toUpperCase() + ")";
continue;
}
index = helpEasy.findInArray(words[i], allCapsCheck[1]);
if (index > -1) {
words[i] = "(" + allCaps[index].toUpperCase();
continue;
}
index = helpEasy.findInArray(words[i], allCapsCheck[2]);
if (index > -1) {
words[i] = allCaps[index].toUpperCase() + ")";
continue;
}
index = helpEasy.findInArray(words[i], allCapsCheck[4]);
if (index > -1) {
words[i] = allCaps[index].toUpperCase() + ",";
continue;
}
//if not found in any of the arrays.. camel case
if (words[i].charAt(0) === "(") {
words[i] = "(" + words[i].charAt(1).toUpperCase() + words[i].substring(2);
} else {
words[i] = words[i].charAt(0).toUpperCase() + words[i].substring(1);
}
}
return words.join(" ");
};

helpEasy.getDataFromNode = function (array, index, endpoint, ttl_fallback) {
array[index]["scheduler"].shift();
let timeStart = Date.now();
Expand Down
27 changes: 18 additions & 9 deletions src/gui_easy_popper.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,18 @@ guiEasy.popper.gamepad.indicator = function (type, index) {
let idx = window.gamepads.active.indexOf(index + "-1");
if (type === "gamepadconnected") {
let gpElement = document.createElement("div");
container.appendChild(gpElement);
gpElement.classList.add("gamepad");
gpElement.classList.add("connected");
gpElement.id = (idx + 1) + "-gamepad-" + index;
gpElement.innerHTML = svg + "<div class='number'>" + (idx + 1) + "</div>"
container.appendChild(gpElement);
gpElement.innerHTML = svg + "<div class='number'>" + (idx + 1) + "</div>";
helpEasy.blinkElement(gpElement, "inverted");
setTimeout( function () {
helpEasy.blinkElement(gpElement, "inverted");
}, 500);
setTimeout( function () {
helpEasy.blinkElement(gpElement, "inverted");
}, 1000);
}
if (type === "gamepaddisconnected") {
let element = document.getElementById((idx + 1) + "-gamepad-" + index);
Expand All @@ -224,7 +231,8 @@ guiEasy.popper.gamepad.indicator = function (type, index) {
// sort their placement
[...container.children]
.sort((a,b)=>a.innerText>b.innerText?1:-1)
.map(node=>container.appendChild(node))
.map(node=>container.appendChild(node));
// auto close the menu...
setTimeout( function () {
container.classList.remove("show");
}, 5000)
Expand Down Expand Up @@ -270,9 +278,9 @@ guiEasy.popper.gamepad.eventListener = function (gamepadMap) {
let eventDetails = {
"type": args[0],
"args": args,
"dataset": element,
"x": element.x,
"y": element.y,
"dataset": element.dataset,
"x": Math.floor(element.getBoundingClientRect().left),
"y": Math.floor(element.getBoundingClientRect().top),
"element": element
};
helpEasy.addToLogDOM("Calling click event: " + JSON.stringify(eventDetails), 2);
Expand All @@ -290,9 +298,9 @@ guiEasy.popper.gamepad.eventListener = function (gamepadMap) {
let eventDetails = {
"type": args[0],
"args": args,
"dataset": element,
"x": element.x,
"y": element.y,
"dataset": element.dataset,
"x": Math.floor(element.getBoundingClientRect().left),
"y": Math.floor(element.getBoundingClientRect().top),
"element": element
};
helpEasy.addToLogDOM("Calling click event: " + JSON.stringify(eventDetails), 2);
Expand Down Expand Up @@ -623,6 +631,7 @@ guiEasy.popper.tab = function (tabToOpen) {
}
if (y.tab === tab) {
x[i].classList.add("nav-selected");
x[i].focus();
}
}
helpEasy.addToLogDOM("tab open: " + tab, 1);
Expand Down

0 comments on commit e1fb94e

Please sign in to comment.