Added basic Formula Wizard, Added script to compile SASS and TS, many other random changes.
Update .gitignore, .htaccess, and 68 more files...
This commit is contained in:
112
tools/items/b64-tools/code.js
Normal file
112
tools/items/b64-tools/code.js
Normal file
@@ -0,0 +1,112 @@
|
||||
"use strict";
|
||||
const langKey = document.documentElement.lang.match("(en|fr)") ? document.documentElement.lang : "en";
|
||||
const langData = {
|
||||
en: {
|
||||
"alert.textarea.missing.text": "The 'TextArea' element for text is missing !",
|
||||
"alert.textarea.missing.b64": "The 'TextArea' element for base64 is missing !",
|
||||
"alert.textarea.mismatch.text": "The 'TextArea' element for text isn't declared as a 'TextArea'!",
|
||||
"alert.textarea.mismatch.b64": "The 'TextArea' element for base64 isn't declared as a 'TextArea'!",
|
||||
"alert.other.missing": "An element is missing from the page !",
|
||||
"alert.other.mismatch": "An element is no declared with the proper element type !",
|
||||
},
|
||||
fr: {
|
||||
"alert.textarea.missing.text": "L'élément 'TextArea' pour le texte est introuvable !",
|
||||
"alert.textarea.missing.b64": "L'élément 'TextArea' pour les données base64 est introuvable !",
|
||||
"alert.textarea.mismatch.text": "L'élément 'TextArea' pour le texte n'est pas un 'TextArea'!",
|
||||
"alert.textarea.mismatch.b64": "L'élément 'TextArea' pour les données base64 n'est pas un 'TextArea'!",
|
||||
"alert.other.missing": "Un élément de la page est introuvable !",
|
||||
"alert.other.mismatch": "Un élément de la page n'est pas bien déclaré !",
|
||||
}
|
||||
};
|
||||
function localize(stringKey) {
|
||||
let _langData = langKey in langData ? langData[langKey] : langData.en;
|
||||
return stringKey in _langData ? _langData[stringKey] : (stringKey in langData["en"] ? langData["en"][stringKey] : stringKey);
|
||||
}
|
||||
const idPrefix = "tool-b64-tools-";
|
||||
const eTextTextarea = document.getElementById(idPrefix + "ta-text");
|
||||
const eBase64Textarea = document.getElementById(idPrefix + "ta-b64");
|
||||
const eClearAllButton = document.getElementById(idPrefix + "btn-clear-all");
|
||||
const eClearTextButton = document.getElementById(idPrefix + "btn-clear-text");
|
||||
const eClearBase64Button = document.getElementById(idPrefix + "btn-clear-b64");
|
||||
const eConvertTextButton = document.getElementById(idPrefix + "btn-convert-text");
|
||||
const eConvertBase64Button = document.getElementById(idPrefix + "btn-convert-b64");
|
||||
const eSelectEncoding = document.getElementById(idPrefix + "encoding");
|
||||
const eCheckboxPadding = document.getElementById(idPrefix + "checkbox-padding");
|
||||
if (eTextTextarea == null) {
|
||||
alert(localize("alert.textarea.missing.text"));
|
||||
throw new Error(localize("alert.textarea.missing.text"));
|
||||
}
|
||||
if (eBase64Textarea == null) {
|
||||
alert(localize("alert.textarea.missing.b64"));
|
||||
throw new Error(localize("alert.textarea.missing.b64"));
|
||||
}
|
||||
if (eClearAllButton == null || eClearTextButton == null || eClearBase64Button == null || eConvertTextButton == null ||
|
||||
eConvertBase64Button == null || eCheckboxPadding == null || eSelectEncoding == null) {
|
||||
alert(localize("alert.other.missing"));
|
||||
throw new Error(localize("alert.other.missing"));
|
||||
}
|
||||
var TextEncoding;
|
||||
(function (TextEncoding) {
|
||||
TextEncoding[TextEncoding["UTF8"] = 0] = "UTF8";
|
||||
TextEncoding[TextEncoding["ASCII"] = 1] = "ASCII";
|
||||
TextEncoding[TextEncoding["UNICODE"] = 2] = "UNICODE";
|
||||
})(TextEncoding || (TextEncoding = {}));
|
||||
if (!(eTextTextarea instanceof HTMLTextAreaElement)) {
|
||||
alert(localize("alert.textarea.mismatch.text"));
|
||||
throw new Error(localize("alert.textarea.mismatch.text"));
|
||||
}
|
||||
if (!(eBase64Textarea instanceof HTMLTextAreaElement)) {
|
||||
alert(localize("alert.textarea.mismatch.b64"));
|
||||
throw new Error(localize("alert.textarea.mismatch.b64"));
|
||||
}
|
||||
if (!(eCheckboxPadding instanceof HTMLInputElement)) {
|
||||
alert(localize("alert.other.mismatch"));
|
||||
throw new Error(localize("alert.other.mismatch"));
|
||||
}
|
||||
if (!(eSelectEncoding instanceof HTMLSelectElement)) {
|
||||
alert(localize("alert.other.mismatch"));
|
||||
throw new Error(localize("alert.other.mismatch"));
|
||||
}
|
||||
function shouldAddPadding() {
|
||||
return eCheckboxPadding.checked;
|
||||
}
|
||||
function getTextEncoding() {
|
||||
switch (eSelectEncoding.value) {
|
||||
case "utf8":
|
||||
return TextEncoding.UTF8;
|
||||
case "unicode":
|
||||
return TextEncoding.UNICODE;
|
||||
case "ascii":
|
||||
return TextEncoding.ASCII;
|
||||
default:
|
||||
return TextEncoding.UTF8;
|
||||
}
|
||||
}
|
||||
function getText() {
|
||||
switch (getTextEncoding()) {
|
||||
case TextEncoding.UTF8:
|
||||
break;
|
||||
case TextEncoding.UNICODE:
|
||||
return new TextEncoder().encode(eTextTextarea.value);
|
||||
case TextEncoding.ASCII:
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
eClearAllButton.addEventListener('click', function handleClick() {
|
||||
eTextTextarea.value = "";
|
||||
eBase64Textarea.value = "";
|
||||
});
|
||||
eClearTextButton.addEventListener('click', function handleClick() {
|
||||
eTextTextarea.value = "";
|
||||
});
|
||||
eClearBase64Button.addEventListener('click', function handleClick() {
|
||||
eBase64Textarea.value = "";
|
||||
});
|
||||
eConvertTextButton.addEventListener('click', function handleClick() {
|
||||
eBase64Textarea.value = "";
|
||||
});
|
||||
eConvertBase64Button.addEventListener('click', function handleClick() {
|
||||
eTextTextarea.value = "";
|
||||
});
|
||||
//# sourceMappingURL=code.js.map
|
137
tools/items/b64-tools/code.ts
Normal file
137
tools/items/b64-tools/code.ts
Normal file
@@ -0,0 +1,137 @@
|
||||
const langKey= document.documentElement.lang.match("(en|fr)") ? document.documentElement.lang : "en";
|
||||
const langData = {
|
||||
en: {
|
||||
"alert.textarea.missing.text": "The 'TextArea' element for text is missing !",
|
||||
"alert.textarea.missing.b64": "The 'TextArea' element for base64 is missing !",
|
||||
"alert.textarea.mismatch.text": "The 'TextArea' element for text isn't declared as a 'TextArea'!",
|
||||
"alert.textarea.mismatch.b64": "The 'TextArea' element for base64 isn't declared as a 'TextArea'!",
|
||||
"alert.other.missing": "An element is missing from the page !",
|
||||
"alert.other.mismatch": "An element is no declared with the proper element type !",
|
||||
},
|
||||
fr: {
|
||||
"alert.textarea.missing.text": "L'élément 'TextArea' pour le texte est introuvable !",
|
||||
"alert.textarea.missing.b64": "L'élément 'TextArea' pour les données base64 est introuvable !",
|
||||
"alert.textarea.mismatch.text": "L'élément 'TextArea' pour le texte n'est pas un 'TextArea'!",
|
||||
"alert.textarea.mismatch.b64": "L'élément 'TextArea' pour les données base64 n'est pas un 'TextArea'!",
|
||||
"alert.other.missing": "Un élément de la page est introuvable !",
|
||||
"alert.other.mismatch": "Un élément de la page n'est pas bien déclaré !",
|
||||
}
|
||||
}
|
||||
|
||||
function localize(stringKey: string): string {
|
||||
// @ts-ignore -> Implicit any on "langData[langKey]"
|
||||
let _langData = langKey in langData ? langData[langKey] : langData.en;
|
||||
return stringKey in _langData ? _langData[stringKey] : (
|
||||
// @ts-ignore -> Implicit any on " langData["en"][stringKey]"
|
||||
stringKey in langData["en"] ? langData["en"][stringKey] : stringKey
|
||||
);
|
||||
}
|
||||
|
||||
const idPrefix : string = "tool-b64-tools-"
|
||||
|
||||
const eTextTextarea : HTMLElement | null = document.getElementById(idPrefix + "ta-text");
|
||||
const eBase64Textarea : HTMLElement | null = document.getElementById(idPrefix + "ta-b64");
|
||||
|
||||
const eClearAllButton : HTMLElement | null = document.getElementById(idPrefix + "btn-clear-all");
|
||||
const eClearTextButton : HTMLElement | null = document.getElementById(idPrefix + "btn-clear-text");
|
||||
const eClearBase64Button : HTMLElement | null = document.getElementById(idPrefix + "btn-clear-b64");
|
||||
|
||||
const eConvertTextButton : HTMLElement | null = document.getElementById(idPrefix + "btn-convert-text");
|
||||
const eConvertBase64Button : HTMLElement | null = document.getElementById(idPrefix + "btn-convert-b64");
|
||||
|
||||
const eSelectEncoding : HTMLElement | null = document.getElementById(idPrefix + "encoding");
|
||||
const eCheckboxPadding : HTMLElement | null = document.getElementById(idPrefix + "checkbox-padding");
|
||||
|
||||
// Checking if the elements exist
|
||||
if(eTextTextarea == null) {
|
||||
alert(localize("alert.textarea.missing.text"));
|
||||
throw new Error(localize("alert.textarea.missing.text"));
|
||||
}
|
||||
|
||||
if(eBase64Textarea == null) {
|
||||
alert(localize("alert.textarea.missing.b64"));
|
||||
throw new Error(localize("alert.textarea.missing.b64"));
|
||||
}
|
||||
|
||||
if(eClearAllButton == null || eClearTextButton == null || eClearBase64Button == null || eConvertTextButton == null ||
|
||||
eConvertBase64Button == null || eCheckboxPadding == null || eSelectEncoding == null) {
|
||||
alert(localize("alert.other.missing"));
|
||||
throw new Error(localize("alert.other.missing"));
|
||||
}
|
||||
|
||||
// Other stuff
|
||||
enum TextEncoding {
|
||||
UTF8,
|
||||
ASCII,
|
||||
UNICODE,
|
||||
}
|
||||
|
||||
// Checking their type
|
||||
if(!(eTextTextarea instanceof HTMLTextAreaElement)) {
|
||||
alert(localize("alert.textarea.mismatch.text"));
|
||||
throw new Error(localize("alert.textarea.mismatch.text"));
|
||||
}
|
||||
|
||||
if(!(eBase64Textarea instanceof HTMLTextAreaElement)) {
|
||||
alert(localize("alert.textarea.mismatch.b64"));
|
||||
throw new Error(localize("alert.textarea.mismatch.b64"));
|
||||
}
|
||||
|
||||
if(!(eCheckboxPadding instanceof HTMLInputElement)) {
|
||||
alert(localize("alert.other.mismatch"));
|
||||
throw new Error(localize("alert.other.mismatch"));
|
||||
}
|
||||
|
||||
if(!(eSelectEncoding instanceof HTMLSelectElement)) {
|
||||
alert(localize("alert.other.mismatch"));
|
||||
throw new Error(localize("alert.other.mismatch"));
|
||||
}
|
||||
|
||||
// Generic functions
|
||||
function shouldAddPadding(): boolean {
|
||||
return (eCheckboxPadding as HTMLInputElement).checked;
|
||||
}
|
||||
|
||||
function getTextEncoding(): TextEncoding {
|
||||
switch((eSelectEncoding as HTMLSelectElement).value) {
|
||||
case "utf8":
|
||||
return TextEncoding.UTF8;
|
||||
case "unicode":
|
||||
return TextEncoding.UNICODE;
|
||||
case "ascii":
|
||||
return TextEncoding.ASCII;
|
||||
default:
|
||||
return TextEncoding.UTF8;
|
||||
}
|
||||
}
|
||||
|
||||
function getText(): Uint8Array | null {
|
||||
switch(getTextEncoding()) {
|
||||
case TextEncoding.UTF8:
|
||||
break;
|
||||
case TextEncoding.UNICODE:
|
||||
return new TextEncoder().encode((eTextTextarea as HTMLTextAreaElement).value);
|
||||
case TextEncoding.ASCII:
|
||||
break; //return new Buffer(string, "ascii");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Setting up button actions
|
||||
eClearAllButton.addEventListener('click', function handleClick() {
|
||||
eTextTextarea.value = "";
|
||||
eBase64Textarea.value = "";
|
||||
});
|
||||
eClearTextButton.addEventListener('click', function handleClick() {
|
||||
eTextTextarea.value = "";
|
||||
});
|
||||
eClearBase64Button.addEventListener('click', function handleClick() {
|
||||
eBase64Textarea.value = "";
|
||||
});
|
||||
|
||||
eConvertTextButton.addEventListener('click', function handleClick() {
|
||||
eBase64Textarea.value = "";
|
||||
});
|
||||
eConvertBase64Button.addEventListener('click', function handleClick() {
|
||||
eTextTextarea.value = "";
|
||||
});
|
26
tools/items/b64-tools/lang.json
Normal file
26
tools/items/b64-tools/lang.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"en": {
|
||||
"tool.b64-tools.title": "Base64 Tools",
|
||||
"tool.b64-tools.text": "Text",
|
||||
"tool.b64-tools.base64": "Base64",
|
||||
"tool.b64-tools.actions": "Other actions",
|
||||
"tool.b64-tools.actions.clear.all": "Clear All",
|
||||
"tool.b64-tools.actions.clear.text": "Clear",
|
||||
"tool.b64-tools.actions.clear.base64": "Clear",
|
||||
"tool.b64-tools.actions.convert.text": "Convert to Base64",
|
||||
"tool.b64-tools.actions.convert.b64": "Convert to text",
|
||||
"tool.b64-tools.options": "Options"
|
||||
},
|
||||
"fr": {
|
||||
"tool.b64-tools.title": "Outils pour Base64",
|
||||
"tool.b64-tools.text": "Texte",
|
||||
"tool.b64-tools.base64": "Base64",
|
||||
"tool.b64-tools.actions": "Autres actions",
|
||||
"tool.b64-tools.actions.clear.all": "Nettoyer Tout",
|
||||
"tool.b64-tools.actions.clear.text": "Nettoyer",
|
||||
"tool.b64-tools.actions.clear.base64": "Nettoyer",
|
||||
"tool.b64-tools.actions.convert.text": "Convertir en Base64",
|
||||
"tool.b64-tools.actions.convert.b64": "Convertir en texte",
|
||||
"tool.b64-tools.options": "Options"
|
||||
}
|
||||
}
|
68
tools/items/b64-tools/page.php
Normal file
68
tools/items/b64-tools/page.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
echo(getMainHeader(localize("tool.b64-tools.text"), null, null, null,
|
||||
true, "bkgd-math", 3, false, false, true));
|
||||
?>
|
||||
<div class="p-xs pb-0">
|
||||
<label for="tool-b64-tools-ta-text"></label>
|
||||
<textarea id="tool-b64-tools-ta-text" class="my-xs w-full no-resize border r-s" name="" rows="10"></textarea>
|
||||
|
||||
<?php
|
||||
echo('<button id="tool-b64-tools-btn-convert-text" class="p-mxs r-s border b-light primary">');
|
||||
echo('<span class="text-monospace"><i class="fad fa-file-search"></i> ');
|
||||
echo(localize("tool.b64-tools.actions.convert.text"));
|
||||
echo('</span></button>');
|
||||
|
||||
echo('<button id="tool-b64-tools-btn-clear-text" class="p-mxs r-s border b-light primary">');
|
||||
echo('<span class="text-monospace"><i class="fad fa-file-search"></i> ');
|
||||
echo(localize("tool.b64-tools.actions.clear.text"));
|
||||
echo('</span></button>');
|
||||
|
||||
echo('<div class="f-right">');
|
||||
echo('<label for="tool-b64-tools-encoding" class="mr-xs">Encoding:</label>');
|
||||
echo('<select id="tool-b64-tools-encoding">');
|
||||
echo('<option value="utf8">UTF-8</option>');
|
||||
echo('<option value="unicode">Unicode</option>');
|
||||
echo('<option value="ascii">ASCII</option>');
|
||||
echo('</select>');
|
||||
echo('</div>');
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
echo(getMainHeader(localize("tool.b64-tools.base64"), null, null, null,
|
||||
true, "bkgd-math", 3, false, false, true));
|
||||
?>
|
||||
<div class="p-xs pb-0">
|
||||
<label for="tool-b64-tools-ta-b64"></label>
|
||||
<textarea id="tool-b64-tools-ta-b64" class="my-xs w-full no-resize border r-s" name="" rows="10"></textarea>
|
||||
<?php
|
||||
echo('<button id="tool-b64-tools-btn-convert-b64" class="p-mxs r-s border b-light primary">');
|
||||
echo('<span class="text-monospace"><i class="fad fa-file-search"></i> ');
|
||||
echo(localize("tool.b64-tools.actions.convert.b64"));
|
||||
echo('</span></button>');
|
||||
|
||||
echo('<button id="tool-b64-tools-btn-clear-b64" class="p-mxs r-s border b-light primary">');
|
||||
echo('<span class="text-monospace"><i class="fad fa-file-search"></i> ');
|
||||
echo(localize("tool.b64-tools.actions.clear.base64"));
|
||||
echo('</span></button>');
|
||||
|
||||
echo('<div class="f-right">');
|
||||
echo('<input class="border r-s my-0" type="checkbox" id="tool-b64-tools-checkbox-padding" name="vehicle1" value="Bike">');
|
||||
echo('<label for="tool-b64-tools-checkbox-padding"> Add padding</label>');
|
||||
echo('</div>');
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
echo(getMainHeader(localize("tool.b64-tools.actions"), null, null, null,
|
||||
true, "bkgd-math", 3, false, false, true));
|
||||
|
||||
echo('<div class="px-xs pt-s">');
|
||||
|
||||
echo('<button id="tool-b64-tools-btn-clear-all" class="p-mxs r-s border b-light primary">');
|
||||
echo('<span class="text-monospace"><i class="fad fa-file-search"></i> ');
|
||||
echo(localize("tool.b64-tools.actions.clear.all"));
|
||||
echo('</span></button>');
|
||||
|
||||
echo('</div>');
|
||||
?>
|
Reference in New Issue
Block a user