Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commit328da9467b071aa614ed2468093c8560da4ba1af (patch)
Author
 Syndamia <kamen@syndamia.com>
2023-09-13 19:10:14 +0300
Committer
 Syndamia <kamen@syndamia.com>
2023-09-13 19:10:14 +0300
Files9ff1b36e1d09abe99581c541a98e0b639470041d
small-web-utilities-328da9467b071aa614ed2468093c8560da4ba1af.tar
small-web-utilities-328da9467b071aa614ed2468093c8560da4ba1af.tar.gz
small-web-utilities-328da9467b071aa614ed2468093c8560da4ba1af.zip
Parent4ea2aadba445a8311e5b9faaba468cd6b25ace70 (diff)
(string) Added string page with a strlen and characters to HTML entities functions
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>