From bcf743e25e2a80ef644eadd1ee7461fdb7873813 Mon Sep 17 00:00:00 2001 From: Sam Sneed <163201376+sam-sneed@users.noreply.github.com> Date: Wed, 15 May 2024 00:09:43 +0000 Subject: [PATCH] Add files via upload --- LICENSE | 21 +++ README.md | 3 +- frontend.js | 450 ++++++++++++++++++++++++++++++++++++++++++++++++++++ index.html | 93 +++++++++++ 4 files changed, 566 insertions(+), 1 deletion(-) 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..da8a51a --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Sneed Group + +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/README.md b/README.md index 5511c00..2cdaf3a 100644 --- a/README.md +++ b/README.md @@ -1 +1,2 @@ -# blog \ No newline at end of file +# sam-sneed.github.io +Code for Sneed Group blog 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, '

$1

'); + markdown = markdown.replace(/^## (.*$)/gim, '

$1

'); + markdown = markdown.replace(/^### (.*$)/gim, '

$1

'); + + // Replace bold and italic text with corresponding HTML tags + markdown = markdown.replace(/\*\*(.*)\*\*/gim, '$1'); + markdown = markdown.replace(/\*(.*)\*/gim, '$1'); + + // Replace unordered list items with HTML list tags + markdown = markdown.replace(/\* (.*?)(\n|$)/gim, '
  • $1
  • '); + + // Replace inline code with HTML 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, '$1'); + + // 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(/