Browse Source

add character counter and lazer

master
mark 1 year ago
parent
commit
9c1e629315
2 changed files with 23 additions and 6 deletions
  1. +3
    -0
      index.html
  2. +20
    -6
      script.js

+ 3
- 0
index.html View File

@@ -42,6 +42,7 @@
<select id="emoteType">
<option value="hacker">Hacker Text (hacker)</option>
<option value="sm64">Super Mario 64 (sm64)</option>
<option value="lazer">Lazer Text (lazer)</option>
<option value="emoji">Emoji (regional_indicator)</option>
<option value="clapping">Clapping Text 👏</option>
<option value="spaced">S P A C E D T E X T</option>
@@ -49,6 +50,8 @@
</select>
<textarea placeholder="Input Text" id="inputBox"></textarea>
<textarea id="outputBox" disabled></textarea>
<div class="float-right" id="chars">Characters: 0</div>

<a class="button" id="copyButton">Copy</a>
</fieldset>
</form>


+ 20
- 6
script.js View File

@@ -36,6 +36,12 @@ var replaceMapping = {
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_$&:​",
@@ -101,11 +107,17 @@ var replaceMapping = {

function updateOutput() {
let inString = $("#inputBox").val();
let selectedEmote = $("#emoteType").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 mapping = replaceMapping[selectedEmote];
let regexp = mapping.regexp;
let replaceStr = mapping.replace;
let outString = inString.replace(regexp, replaceStr);

if (mapping.downcase === true) {
@@ -120,8 +132,10 @@ function updateOutput() {
);
}
}

$("#outputBox").val(outString.trim());
const finalString = outString.trim();
$("#chars").text("Characters: " + finalString.length);
$("#outputBox").val(finalString);
}

$(document).ready(function() {


Loading…
Cancel
Save