From fb47c5eea5d96809fc64ad1878ae80a8117b2499 Mon Sep 17 00:00:00 2001 From: Mark Szymanski Date: Sat, 28 Mar 2020 23:07:20 -0500 Subject: [PATCH] update source code link --- LICENSE | 40 +++---- README.md | 16 +-- index.html | 144 ++++++++++++------------- script.js | 306 ++++++++++++++++++++++++++--------------------------- style.css | 40 +++---- 5 files changed, 273 insertions(+), 273 deletions(-) diff --git a/LICENSE b/LICENSE index 03fe568..3b9c472 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,21 @@ -MIT License - -Copyright (c) 2019 mdszy - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +MIT License + +Copyright (c) 2019 mdszy + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index 8ae959b..759ee96 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# et - -just a dumb webpage thinger that generates mastodon-style emotes (or regional_designator-style emotes) based on text you give it - -that's it - -it's pretty dumb - +# et + +just a dumb webpage thinger that generates mastodon-style emotes (or regional_designator-style emotes) based on text you give it + +that's it + +it's pretty dumb + [i host it here](https://szy.io/et) \ No newline at end of file diff --git a/index.html b/index.html index f2dcf89..292cd1f 100644 --- a/index.html +++ b/index.html @@ -1,72 +1,72 @@ - - - - - - - - - - - - - - - emote text generator - - -
-
-

Emote Text Generator

-
-
-
-
-
- - - - -
Characters: 0
- - Copy -
-
-
-
-
- - - + + + + + + + + + + + + + + + emote text generator + + +
+
+

Emote Text Generator

+
+
+
+
+
+ + + + +
Characters: 0
+ + Copy +
+
+
+
+
+ + + diff --git a/script.js b/script.js index a972481..2af5365 100644 --- a/script.js +++ b/script.js @@ -1,153 +1,153 @@ -function fallbackCopyTextToClipboard(text) { - var textArea = document.createElement("textarea"); - textArea.value = text; - document.body.appendChild(textArea); - textArea.focus(); - textArea.select(); - - try { - var successful = document.execCommand("copy"); - var msg = successful ? "successful" : "unsuccessful"; - console.log("Fallback: Copying text command was " + msg); - } catch (err) { - console.error("Fallback: Oops, unable to copy", err); - } - - document.body.removeChild(textArea); -} -function copyTextToClipboard(text) { - if (!navigator.clipboard) { - fallbackCopyTextToClipboard(text); - return; - } - navigator.clipboard.writeText(text).then( - function() { - console.log("Async: Copying to clipboard was successful!"); - }, - function(err) { - console.error("Async: Could not copy text: ", err); - } - ); -} - -var replaceMapping = { - hacker: { - regexp: /[A-Za-z]/g, - replace: ":hacker_$&:​", - downcase: true - }, - lazer: { - regexp: /[A-Za-z0-9]/g, - replace: ":lazer_$&:​", - downcase: false, - preUpcase: true - }, - sm64: { - regexp: /[A-Za-z0-9'"\?]/g, - replace: ":sm64_$&:​", - postReplaceMatch: [/"/g, /'/g, /\?/g], - postReplace: ["dblquote", "quote", "question"], - downcase: true - }, - emoji: { - regexp: /[A-Za-z0-9#\*]/g, - replace: ":regional_indicator_$&:​", - postReplaceMatch: [ - /regional_indicator_0/g, - /regional_indicator_1/g, - /regional_indicator_2/g, - /regional_indicator_3/g, - /regional_indicator_4/g, - /regional_indicator_5/g, - /regional_indicator_6/g, - /regional_indicator_7/g, - /regional_indicator_8/g, - /regional_indicator_9/g, - /regional_indicator_#/g, - /regional_indicator_\*/g, - /regional_indicator_b/g - ], - postReplace: [ - "zero", - "one", - "two", - "three", - "four", - "five", - "six", - "seven", - "eight", - "nine", - "hash", - "keycap_star", - "b" - ], - downcase: true - }, - clapping: { - regexp: /\s/g, - replace: "👏", - postReplaceMatch: [/$/], - postReplace: ["👏"], - downcase: false - }, - bun: { - regexp: /\s/g, - replace: " :bun: ", - postReplaceMatch: [/$/], - postReplace: [" :bun: "], - downcase: false - }, - spaced: { - regexp: /./g, - replace: "$& ", - downcase: false - } -}; - -function updateOutput() { - let inString = $("#inputBox").val(); - const selectedEmote = $("#emoteType").val(); - - - const mapping = replaceMapping[selectedEmote]; - const regexp = mapping.regexp; - const replaceStr = mapping.replace; - - if(mapping.preUpcase === true) { - inString = inString.toUpperCase(); - } - - let outString = inString.replace(regexp, replaceStr); - - if (mapping.downcase === true) { - outString = outString.toLowerCase(); - } - - if (mapping.postReplaceMatch) { - for (let i = 0; i < mapping.postReplaceMatch.length; i++) { - outString = outString.replace( - mapping.postReplaceMatch[i], - mapping.postReplace[i] - ); - } - } - const finalString = outString.trim(); - - $("#chars").text("Characters: " + finalString.length); - $("#outputBox").val(finalString); -} - -$(document).ready(function() { - $("#inputBox").on("input propertychange", function(e) { - updateOutput(); - }); - - $("#emoteType").change(function(e) { - updateOutput(); - }); - - $("#copyButton").on("click", function(e) { - copyTextToClipboard($("#outputBox").val()); - }); -}); +function fallbackCopyTextToClipboard(text) { + var textArea = document.createElement("textarea"); + textArea.value = text; + document.body.appendChild(textArea); + textArea.focus(); + textArea.select(); + + try { + var successful = document.execCommand("copy"); + var msg = successful ? "successful" : "unsuccessful"; + console.log("Fallback: Copying text command was " + msg); + } catch (err) { + console.error("Fallback: Oops, unable to copy", err); + } + + document.body.removeChild(textArea); +} +function copyTextToClipboard(text) { + if (!navigator.clipboard) { + fallbackCopyTextToClipboard(text); + return; + } + navigator.clipboard.writeText(text).then( + function() { + console.log("Async: Copying to clipboard was successful!"); + }, + function(err) { + console.error("Async: Could not copy text: ", err); + } + ); +} + +var replaceMapping = { + hacker: { + regexp: /[A-Za-z]/g, + replace: ":hacker_$&:​", + downcase: true + }, + lazer: { + regexp: /[A-Za-z0-9]/g, + replace: ":lazer_$&:​", + downcase: false, + preUpcase: true + }, + sm64: { + regexp: /[A-Za-z0-9'"\?]/g, + replace: ":sm64_$&:​", + postReplaceMatch: [/"/g, /'/g, /\?/g], + postReplace: ["dblquote", "quote", "question"], + downcase: true + }, + emoji: { + regexp: /[A-Za-z0-9#\*]/g, + replace: ":regional_indicator_$&:​", + postReplaceMatch: [ + /regional_indicator_0/g, + /regional_indicator_1/g, + /regional_indicator_2/g, + /regional_indicator_3/g, + /regional_indicator_4/g, + /regional_indicator_5/g, + /regional_indicator_6/g, + /regional_indicator_7/g, + /regional_indicator_8/g, + /regional_indicator_9/g, + /regional_indicator_#/g, + /regional_indicator_\*/g, + /regional_indicator_b/g + ], + postReplace: [ + "zero", + "one", + "two", + "three", + "four", + "five", + "six", + "seven", + "eight", + "nine", + "hash", + "keycap_star", + "b" + ], + downcase: true + }, + clapping: { + regexp: /\s/g, + replace: "👏", + postReplaceMatch: [/$/], + postReplace: ["👏"], + downcase: false + }, + bun: { + regexp: /\s/g, + replace: " :bun: ", + postReplaceMatch: [/$/], + postReplace: [" :bun: "], + downcase: false + }, + spaced: { + regexp: /./g, + replace: "$& ", + downcase: false + } +}; + +function updateOutput() { + let inString = $("#inputBox").val(); + const selectedEmote = $("#emoteType").val(); + + + const mapping = replaceMapping[selectedEmote]; + const regexp = mapping.regexp; + const replaceStr = mapping.replace; + + if(mapping.preUpcase === true) { + inString = inString.toUpperCase(); + } + + let outString = inString.replace(regexp, replaceStr); + + if (mapping.downcase === true) { + outString = outString.toLowerCase(); + } + + if (mapping.postReplaceMatch) { + for (let i = 0; i < mapping.postReplaceMatch.length; i++) { + outString = outString.replace( + mapping.postReplaceMatch[i], + mapping.postReplace[i] + ); + } + } + const finalString = outString.trim(); + + $("#chars").text("Characters: " + finalString.length); + $("#outputBox").val(finalString); +} + +$(document).ready(function() { + $("#inputBox").on("input propertychange", function(e) { + updateOutput(); + }); + + $("#emoteType").change(function(e) { + updateOutput(); + }); + + $("#copyButton").on("click", function(e) { + copyTextToClipboard($("#outputBox").val()); + }); +}); diff --git a/style.css b/style.css index 2bb8eeb..c21382c 100644 --- a/style.css +++ b/style.css @@ -1,21 +1,21 @@ -textarea { - resize: none; -} - -.footer { - position: absolute; - right: 0; - bottom: 0; - left: 0; - padding: 1rem; - background-color: #efefef; - text-align: center; -} - -.liberapay-badge { - display: inline; - vertical-align: middle; - padding-top: 5px; - padding-bottom: 5px; - margin: auto; +textarea { + resize: none; +} + +.footer { + position: absolute; + right: 0; + bottom: 0; + left: 0; + padding: 1rem; + background-color: #efefef; + text-align: center; +} + +.liberapay-badge { + display: inline; + vertical-align: middle; + padding-top: 5px; + padding-bottom: 5px; + margin: auto; } \ No newline at end of file