Button definitions update

This commit is contained in:
Francisco Hodge 2018-09-23 23:38:11 -04:00
parent f0ef1e8e7b
commit 345f22827b

View File

@ -34,6 +34,8 @@ class Utilities {
output = 'closebracket'; output = 'closebracket';
else if(string === "//") else if(string === "//")
output = 'emptybutton'; output = 'emptybutton';
else if(string === ".com")
output = 'com';
else else
output = ''; output = '';
@ -54,19 +56,74 @@ class Utilities {
static getDefaultDiplay(){ static getDefaultDiplay(){
return { return {
'{bksp}': 'backspace', '{bksp}': 'backspace',
'{backspace}': 'backspace',
'{enter}': '< enter', '{enter}': '< enter',
'{shift}': 'shift', '{shift}': 'shift',
'{shiftleft}': 'shift',
'{shiftright}': 'shift',
'{alt}': 'alt',
'{s}': 'shift', '{s}': 'shift',
'{tab}': 'tab', '{tab}': 'tab',
'{lock}': 'caps', '{lock}': 'caps',
'{capslock}': 'caps',
'{accept}': 'Submit', '{accept}': 'Submit',
'{space}': ' ', '{space}': ' ',
'{//}': ' ' '{//}': ' ',
"{esc}": "esc",
"{escape}": "esc",
"{f1}": "f1",
"{f2}": "f2",
"{f3}": "f3",
"{f4}": "f4",
"{f5}": "f5",
"{f6}": "f6",
"{f7}": "f7",
"{f8}": "f8",
"{f9}": "f9",
"{f10}": "f10",
"{f11}": "f11",
"{f12}": "f12",
'{numpaddivide}': '/',
'{numlock}': 'lock',
"{arrowup}": "↑",
"{arrowleft}": "←",
"{arrowdown}": "↓",
"{arrowright}": "→",
"{prtscr}": "print",
"{scrolllock}": "scroll",
"{pause}": "pause",
"{insert}": "ins",
"{home}": "home",
"{pageup}": "up",
"{delete}": "del",
"{end}": "end",
"{pagedown}": "down",
"{numpadmultiply}": "*",
"{numpadsubtract}": "-",
"{numpadadd}": "+",
"{numpadenter}": "enter",
"{period}": ".",
"{numpaddecimal}": ".",
"{numpad0}": "0",
"{numpad1}": "1",
"{numpad2}": "2",
"{numpad3}": "3",
"{numpad4}": "4",
"{numpad5}": "5",
"{numpad6}": "6",
"{numpad7}": "7",
"{numpad8}": "8",
"{numpad9}": "9",
}; };
} }
static getButtonDisplayName = (button, display) => { static getButtonDisplayName = (button, display, mergeDisplay) => {
if(mergeDisplay){
display = Object.assign({}, Utilities.getDefaultDiplay(), display);
} else {
display = display || Utilities.getDefaultDiplay(); display = display || Utilities.getDefaultDiplay();
}
return display[button] || button; return display[button] || button;
} }
@ -74,7 +131,7 @@ class Utilities {
let output = input; let output = input;
let newLineOnEnter = options.newLineOnEnter; let newLineOnEnter = options.newLineOnEnter;
if(button === "{bksp}" && output.length > 0){ if((button === "{bksp}" || button === "{backspace}") && output.length > 0){
/** /**
* Emojis are made out of two characters, so we must take a custom approach to trim them. * Emojis are made out of two characters, so we must take a custom approach to trim them.
* For more info: https://mathiasbynens.be/notes/javascript-unicode * For more info: https://mathiasbynens.be/notes/javascript-unicode
@ -91,13 +148,33 @@ class Utilities {
output = output + ' '; output = output + ' ';
else if(button === "{tab}") else if(button === "{tab}")
output = output + "\t"; output = output + "\t";
else if(button === "{enter}" && newLineOnEnter) else if((button === "{enter}" || button === "{numpadenter}") && newLineOnEnter)
output = output + "\n"; output = output + "\n";
else if(button.includes("numpad") && Number.isInteger(Number(button[button.length - 2]))){
output = output + button[button.length - 2];
}
else if(button === "{numpaddivide}")
output = output + '/';
else if(button === "{numpadmultiply}")
output = output + '*';
else if(button === "{numpadsubtract}")
output = output + '-';
else if(button === "{numpadadd}")
output = output + '+';
else if(button === "{numpadadd}")
output = output + '+';
else if(button === "{numpaddecimal}")
output = output + '.';
else if(!button.includes("{") && !button.includes("}")) else if(!button.includes("{") && !button.includes("}"))
output = output + button; output = output + button;
return output; return output;
} }
static camelCase = (string) => {
return string.toLowerCase().trim().split(/[.\-_\s]/g).reduce((string, word) => string + word[0].toUpperCase() + word.slice(1));
};
} }
export default Utilities; export default Utilities;