simple text form 2
by Julian
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Paste and Download Indexed Words</title>
<style>
body {
font-family: Arial, sans-serif;
}
#output {
margin: 20px 0;
font-size: 1.2em;
}
.word {
display: inline-block;
margin-right: 10px;
cursor: text;
}
.index {
font-size: 0.7em;
vertical-align: super;
margin-left: 2px;
}
#copied {
margin-top: 20px;
width: 100%;
height: 100px;
font-size: 1.2em;
white-space: pre-wrap; /* Preserve spaces and line breaks */
border: 1px solid #ccc;
padding: 10px;
background-color: #f9f9f9;
font-family: Arial, sans-serif;
overflow-y: auto;
}
button {
margin-top: 20px;
padding: 10px 20px;
font-size: 1em;
cursor: pointer;
}
.highlight {
background-color: yellow;
}
</style>
</head>
<body>
<h1>Paste and Download Indexed Words</h1>
<p id="output"></p>
<div id="copied" contenteditable="true" placeholder="Paste words here..."></div>
<button id="downloadBtn">Download Words as JSON</button>
<script>
// Input string
const inputString = "This is an example string";
// Split the string into words
const words = inputString.split(" ");
// Select the output container
const outputParagraph = document.getElementById("output");
// Display each word with its index
words.forEach((word, index) => {
// Create a container for the word
const wordSpan = document.createElement("span");
wordSpan.className = "word";
// Add the word text
wordSpan.textContent = word;
// Create a small superscript for the index
const indexSup = document.createElement("sup");
indexSup.className = "index";
indexSup.textContent = index;
// Append the index to the word
...