Summary Files Commits Branches @commit @diff @stats
path: root / string.html
diff options
context:
space:
mode:
1 files changed, 63 insertions, 0 deletions
-rw-r--r--string.html63
diff --git a/string.html b/string.html
new file mode 100644
index 0000000..b22a1ef
--- /dev/null
+++ b/string.html
@@ -0,0 +1,63 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <meta name="author" content="Syndamia">
+ <meta name="robots" content="index, follow">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>String functions</title>
+<style>
+#notice {
+ font-size: 0.9em;
+ color: gray;
+ font-style: italic;
+}
+#strlen-l {
+ font-weight: bold;
+}
+</style>
+ </head>
+ <body>
+ <header>
+ <h2>String functions</h2>
+ <p>
+ An asortment of functions for simple (local) string manipulation and inspection.
+ </p>
+ <a href="/">Home</a>
+ <span id="notice">&emsp; Made by <a href="https://syndamia.com">Syndamia</a>, licensed under <a href="https://gitlab.com/Syndamia/small-web-utilities/-/blob/main/LICENSE">GNU GPLv3</a></span>
+ <hr>
+ </header>
+
+ <div>
+ <p>String length: <span id="strlen-l">0</span></p>
+ <textarea rows="10" cols="80" id="strlen-ta" placeholder="Input here"></textarea>
+ </div>
+ <br>
+
+ <div>
+ <p>String to HTML entities</p>
+ <textarea rows="10" cols="80" id="strtohtmlent-in" placeholder="Input here"></textarea>
+ <textarea rows="10" cols="80" id="strtohtmlent-out" placeholder="Output here"></textarea>
+ </div>
+ <script>
+ const strlenLabel = document.getElementById('strlen-l');
+ const strlenIn = document.getElementById('strlen-ta');
+ function stringLength() {
+ strlenLabel.innerText = this.value.length;
+ }
+ stringLength.call(strlenIn);
+ strlenIn.addEventListener('input', stringLength);
+
+ const strtoheIn = document.getElementById('strtohtmlent-in');
+ const strtoheOut = document.getElementById('strtohtmlent-out');
+ function stringToHTMLEntities() {
+ strtoheOut.value = '';
+ for (var i = 0; i < this.value.length; i++) {
+ strtoheOut.value += '&#' + this.value.charCodeAt(i) + ';';
+ }
+ }
+ stringToHTMLEntities.call(strtoheIn);
+ strtoheIn.addEventListener('input', stringToHTMLEntities);
+ </script>
+ </body>
+</html>