// JS++ // Created by Samuel Lord (NodeMixaholic/Sparksammy) // Now Maintained by Sneed Group // Licensed under Samuel Public License with <3 class JSPlusPlus { General = class { //Eval alternative //Example: exec("alert('Hello, world!')") exec(jsCode) { let js = jsCode.toString(); Function(js)() } readInternetText(url) { try { var request = new XMLHttpRequest(); // Create a new XMLHttpRequest object request.open('GET', url, false); // Open the request with synchronous mode request.send(null); // Send the request with no additional data if (request.status === 200) { // Check if the request was successful return request.responseText; // Return the response text } else { return 'Error: ' + request.status; // Return an error message if the request failed } } catch { try { let http = require('http'); let body = "" let request = http.get(url, function (res) { var data = ''; res.on('data', function (chunk) { data += chunk; }); res.on('end', function () { body = data.toString() }); }); request.on('error', function (e) { body = e.message }); request.end(); return body; } catch { return "Unknown error fetching URL! :'(" } } } require(jsURI) { try { let req = JSPlusPlus.JSPlusPlus.readInternetText(jsURI); JSPlusPlus.General.exec(req); } catch { console.log(`Error! (Using Node.JS?) If on NodeJS or equivalent try: 'let ${jsURI} = require("${jsURI}")'`) } } } HTMLFrontend = class { // Get element by ID getElementById(elementID) { return document.getElementById(elementID) } //Convert markdown to HTML and back 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; } 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(/