JSFiddle - React, Tailwind, and code Playground

by aswinkumar863

HTML

<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]>      <html class="no-js"> <!--<![endif]-->
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title></title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="app.css">
    </head>
    <body>
        <!--[if lt IE 7]>
            <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p>
        <![endif]-->
        <h1 class="columns">Text Form</h1>
        <h1 class="columns">Change Preview</h1>
        <form action="" id="text-form">
            <label for="">Input Text</label>
            <br>
            <!-- <input type="text" placeholder="paste your text here" id="input-text"> -->
            <textarea name="" id="input-text" cols="30" rows="10" placeholder="paste your text here" type="text" oninput="textareaInput()"></textarea>
            <!-- <textarea name="" id="input-text" cols="30" rows="10" placeholder="paste your text here" type="text"></textarea> -->

            <br>
            <label for="">Select All:</label>
            <input type="checkbox" name="allcheck" value="selectall" id="check-all" onclick="togglecheckall('singlecheck')">
            <br>
            
            <input type="checkbox" name="singlecheck" value="colon" id="check-colon" oninput="highlightColonOnCheck()">
            <!-- <input type="checkbox" name="singlecheck" value="colon" id="check-colon" > -->
            <label for=""><em><b>:</b></em></label>
            <br>
            
            <input type="checkbox" name="singlecheck" value="arrows"...

CSS

label{
    font-size: larger;
}

/* div#output-container{
    float: left;
    width: 48%;
    margin: 1%;
} */

div.text{
    float: left;
    width: 25%;
    margin: 1%;
}

div.text p{
    word-break: break-all;
}

form{
    float: left;
    width: 50%;
}

mark{
    background: #FF7F7F;
    color: black;
}

h1.columns{
    float:left;
    width: 48%;
    margin: 1%;
}

JavaScript

const form = document.querySelector("#text-form");
const input = document.querySelector("#input-text");
const originalParagraph = document.querySelector("#original-text");
const highlightedParagraph = document.querySelector("#highlightedp");
const paragraph = document.querySelector("#outputted-text");
const checkedAll = document.querySelector("#check-all");
const checkedColon = document.querySelector("#check-colon");
const checkedArrows = document.querySelector("#check-arrows");
const checkedDigitsDot = document.querySelector("#check-digits-dot");
const checkedParenthesis = document.querySelector("#check-parenthesis");
const checkedSemicolon = document.querySelector("#check-semicolon");


function filterAll(textString) {
  let updatedText = textString;

  updatedText = updatedText.replaceAll("...", "")

  if (updatedText.includes(";")) {
    updatedText = updatedText.replaceAll(/\s/g, "\n");
  }

  if (checkedColon.checked) {
    if (updatedText.includes(":")) {
      updatedText = updatedText.replaceAll(":", "")
        .replaceAll(/\n\n/g, "\n");
    }
  }

  if (updatedText.includes(";")) {
    if (checkedParenthesis.checked) {
      updatedText = updatedText.replaceAll(/\(.*?\)/g, '');
    }
    if (checkedSemicolon.checked) {
      updatedText = updatedText.replaceAll(";", "");
    }
  } else {
    if (checkedParenthesis.checked) {
      updatedText = updatedText.replaceAll(/\(.*?\)/g, '');
    }
  }

  if (checkedDigitsDot.checked) {
    if (updatedText.includes(".")) {
      updatedText = updatedText.replaceAll(/\d*[.]/g, "");
    }
  }

  if (checkedArrows.checked) {
    if (updatedText.includes("«")) {
      updatedText = updatedText.replaceAll("«", "");
    }
    if (updatedText.includes("»")) {
      updatedText = updatedText.replaceAll("»", "");
    }
  }

  return updatedText;
}

form.addEventListener("submit", function(e) {
  e.preventDefault();
  console.log(input.value);

  const output = input.value;
  console.log(output);
  const oldP =...