From eabbc931bb7c7603023ff14e77e83eb71440ad0f Mon Sep 17 00:00:00 2001 From: Sam Sneed <163201376+sam-sneed@users.noreply.github.com> Date: Thu, 4 Jul 2024 23:13:41 +0000 Subject: [PATCH] Add files via upload --- LICENSE | 21 +++ frontend.js | 450 ++++++++++++++++++++++++++++++++++++++++++++++++++++ index.html | 93 +++++++++++ 3 files changed, 564 insertions(+) create mode 100644 LICENSE create mode 100644 frontend.js create mode 100644 index.html diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3ee2104 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Sammy Lord + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/frontend.js b/frontend.js new file mode 100644 index 0000000..30c5dc5 --- /dev/null +++ b/frontend.js @@ -0,0 +1,450 @@ +// Created by Samuel Lord (NodeMixaholic/Sparksammy) +// Now Maintained by Maxwell (GOrwell1984) +// Licensed under Samuel Public License with <3 + +// Functions for commonly used elements + +// Get element by ID +function getElementById(elementID) { + return document.getElementById(elementID) +} + +//Convert markdown to HTML and back +function markdownToHTML(markdown) { + // Replace headers (h1, h2, h3) with corresponding HTML tags + markdown = markdown.replace(/^# (.*$)/gim, '
tag
+ markdown = markdown.replace(/`(.*?)`/gim, '$1
');
+
+ // Replace blockquotes with HTML tag
+ markdown = markdown.replace(/^\s*> (.*)$/gim, '$1
');
+
+ // Replace horizontal rules with HTML
tag
+ markdown = markdown.replace(/^\s*[-*_]{3,}\s*$/gim, '
');
+
+ // Replace line breaks with HTML
tag
+ markdown = markdown.replace(/\n$/gim, '
');
+
+ // Replace images with HTML tag
+ markdown = markdown.replace(/!\[(.*?)\]\((.*?)\)/gim, '');
+
+ // Replace links with HTML tag
+ markdown = markdown.replace(/\[(.*?)\]\((.*?)\)/gim, '$1');
+
+ markdown = markdown.replaceAll("", "")
+
+ markdown = markdown.replaceAll("
", "")
+
+ return markdown;
+}
+
+function htmlToMarkdown(html) {
+ // Replace headers (h1, h2, h3) with corresponding Markdown tags
+ html = html.replace(/(.*?)<\/h1>/gim, '# $1');
+ html = html.replace(/(.*?)<\/h2>/gim, '## $1');
+ html = html.replace(/(.*?)<\/h3>/gim, '### $1');
+
+ // Replace bold and italic text with corresponding Markdown tags
+ html = html.replace(/(.*?)<\/b>/gim, '**$1**');
+ html = html.replace(/(.*?)<\/i>/gim, '*$1*');
+
+ // Replace unordered list items with Markdown list tags
+ html = html.replace(/