Topalian JavaScript Code Editor by Christopher Topalian
Topalian JavaScript Code Editor by Christopher Topalian
JavaScript
Code
Editor
by
Christopher Andrew Topalian
All Rights Reserved
Copyright 2000-2024
Dedicated
to
God the Father
<!-- Dedicated to God the Father -->
<!-- All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024 -->
<!-- https://github.com/ChristopherTopalian --
>
<!--
https://github.com/ChristopherAndrewTopalia
n -->
<!-- Topalian_JavaScript_Code_Editor.html --
>
<!-- Version 001 - (2024-07-04) -->
<html>
<head>
<title> Topalian JavaScript Code Editor
</title>
<style>
body
{
padding: 20px;
background-color: rgb(0, 0, 0);
font-family: Arial;
color: white;
}
#editorContainer
{
height: 300px;
}
#codeInput, #codeOutput
{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
padding: 10px;
font-family: Arial;
font-size: 24px;
font-weight: bold;
border: none;
resize: none;
tab-size: 4;
overflow-y: scroll;
}
#codeInput
{
background-color: rgba(0, 0, 0, 0);
/* hide text in textarea */
color: transparent;
caret-color: white;
z-index: 2;
overflow-y: scroll;
}
#codeOutput
{
/* if font size increaes, decrease top pos
corrospondingly */
top: -22px;
background-color: rgb(0, 0, 0);
color: white;
white-space: pre-wrap;
word-break: break-word;
/* make div not selectable */
pointer-events: none;
overflow-y: scroll;
z-index: 1;
}
.pink
{
color: pink;
}
.skyblue
{
color: skyblue;
}
.yellow
{
color: yellow;
}
.lightGray
{
color: rgb(200, 200, 200);
}
.magenta
{
color: rgb(255, 138, 255);
}
.objects
{
color: rgb(155, 195, 255);
}
</style>
</head>
<body>
<div id = "editorContainer">
<textarea id = "codeInput"></textarea>
<pre id = "codeOutput"></pre>
</div>
<script>
let theEvents =
[
'onabort',
'onafterprint',
'onanimationend',
'onanimationiteration',
'onanimationstart',
'onbeforeprint',
'onbeforeunload',
'onblur',
'oncanplay',
'oncanplaythrough',
'onchange',
'onclick',
'oncontextmenu',
'oncopy',
'oncut',
'ondblclick',
'ondrag',
'ondragend',
'ondragenter',
'ondragleave',
'ondragover',
'ondragstart',
'ondrop',
'ondurationchange',
'onemptied',
'onended',
'onerror',
'onfocus',
'onfocusin',
'onfocusout',
'onfullscreenchange',
'onfullscreenerror',
'onhashchange',
'oninput',
'oninvalid',
'onkeydown',
'onkeypress',
'onkeyup',
'onLine',
'onload',
'onloadeddata',
'onloadedmetadata',
'onloadstart',
'onmessage',
'onmousedown',
'onmouseenter',
'onmouseleave',
'onmousemove',
'onmouseover',
'onmouseout',
'onmouseup',
'onmousewheel',
'onoffline',
'ononline',
'onopen',
'onpagehide',
'onpageshow',
'onpaste',
'onpause',
'onplay',
'onplaying',
'onpopstate',
'onprogress',
'onratechange',
'onresize',
'onreset',
'onscroll',
'onsearch',
'onseeked',
'onseeking',
'onselect',
'onshow',
'onstalled',
'onstorage',
'onsubmit',
'onsuspend',
'ontimeupdate',
'ontoggle',
'ontouchcancel',
'ontouchend',
'ontouchmove',
'ontouchstart',
'ontransitionend',
'onunload',
'onvolumechange',
'onwaiting',
'onwheel'
];
let theFunctions =
[
'abs',
'acos',
'acosh',
'adoptNode',
'alert',
'appendChild',
'asin',
'asinh',
'assert',
'assert',
'assign',
'atan',
'atan2',
'atanh',
'atob',
'back',
'blur',
'btoa',
'cbrt',
'ceil',
'charAt',
'charCodeAt',
'clear',
'clearInterval',
'clearTimeout',
'clearWatch',
'click',
'close',
'closest',
'clz32',
'compile',
'concat',
'confirm',
'constructor',
'contains',
'copyWithin',
'cos',
'cosh',
'count',
'createAttribute',
'createComment',
'createDocumentFragment',
'createElement',
'createEvent',
'createTextNode',
'decodeURI',
'decodeURIComponent',
'encodeURI',
'encodeURIComponent',
'endsWith',
'entries',
'error',
'escape',
'eval',
'every',
'exec',
'execCommand',
'exitFullscreen',
'exp',
'expm1',
'fill',
'filter',
'find',
'fintIndex',
'floor',
'focus',
'forEach',
'forward',
'from',
'fromCharCode',
'fround',
'fullscreenEnabled',
'getDate',
'getDay',
'getAttribute',
'getAttributeNode',
'getBoundingClientRect',
'getComputedStyle',
'getCurrentPosition',
'getElementById',
'getElementsByClassName',
'getElementsByName',
'getElementsByTagName',
'getFullYear',
'getHours',
'getItem',
'getMilliseconds',
'getMinutes',
'getModifierState',
'getMonth',
'getNamedItem',
'getSeconds',
'getSelection',
'getTargetRanges',
'getTime',
'getTimezoneOffset',
'getUTCDate',
'getUTCDay',
'getUTCFullYear',
'getUTCHours',
'getUTCMilliseconds',
'getUTCMinutes',
'getUTCMonth',
'getUTCSeconds',
'getYear',
'go',
'group',
'groupCollapsed',
'groupEnd',
'hasAttribute',
'hasAttributes',
'hasChildNodes',
'hasFocus',
'importNode',
'includes',
'indexOf',
'info',
'insertAdjacentElement',
'insertAdjacentHTML',
'insertAdjacentText',
'insertBefore',
'isArray',
'isDefaultNamespace',
'isEqualNode',
'isFinite',
'isInteger',
'isNaN',
'isSafeInteger',
'isSameNode',
'isSupported',
'item',
'join',
'key',
'keys',
'lastIndexOf',
'localeCompare',
'log',
'log10',
'log1p',
'log2',
'map',
'match',
'matches',
'matchMedia',
'max',
'min',
'moveBy',
'moveTo',
'namedItem',
'normalize',
'normalizeDocument',
'now',
'Number',
'open',
'parse',
'parseFloat',
'parseInt',
'pop',
'preventDefault',
'print',
'push',
'querySelector',
'querySelectorAll',
'random',
'reduce',
'reduceRight',
'reload',
'remove',
'removeAttribute',
'removeAttributeNode',
'removeChild',
'removeEventListener',
'removeItem',
'repeat',
'replace',
'replaceChild',
'requestAnimationFrame',
'requestFullscreen',
'resizeBy',
'resizeTo',
'reverse',
'round',
'pow',
'prompt',
'removeEventListener',
'removeNamedItem',
'renameNode',
'scroll',
'scrollBy',
'scrollIntoView',
'scrollTo',
'search',
'setAttribute',
'setAttributeNode',
'setDate',
'setFullYear',
'setHours',
'setInterval',
'setItem',
'setMilliseconds',
'setMinutes',
'setMonth',
'setNamedItem',
'setSeconds',
'setTime',
'setTimeout',
'setUTCDate',
'setUTCFullYear',
'setUTCHours',
'setUTCMilliseconds',
'setUTCMinutes',
'setUTCMonth',
'setUTCSecond',
'setYear',
'shift',
'sign',
'sin',
'sinh',
'slice',
'some',
'sort',
'splice',
'split',
'startsWith',
'String',
'stop',
'stopImmediatePropagation',
'stopPropagation',
'stringify',
'substr',
'substring',
'table',
'tan',
'tanh',
'test',
'time',
'timeEnd',
'toDateString',
'toGMTString',
'toExponential',
'toFixed',
'toJSON',
'toISOString',
'toLocaleDateString',
'toLocaleLowerCase',
'toLocaleString',
'toLocaleTimeString',
'toLocaleUpperCase',
'toLowerCase',
'toPrecision',
'toString',
'toTimeString',
'toUpperCase',
'toUTCString',
'trace',
'trim',
'trunc',
'unescape',
'unshift',
'UTC',
'valueOf',
'warn',
'watchPosition',
'write',
'writeln'
];
let theObjects =
[
'console',
'document',
'window',
'Date',
'Math',
'JSON',
];
let codeInput =
document.getElementById('codeInput');
let codeOutput =
document.getElementById('codeOutput');
function escapeHtml(code)
{
return code.replace(/&/g,
'&').replace(/</g, '<').replace(/>/g,
'>');
}
function highlightCode()
{
let code = escapeHtml(codeInput.value);
let functionPattern = new RegExp(`\\b($
{theFunctions.join('|')})\\b`, 'g');
let highlightedCode =
code.replace(functionPattern, '<span
style="color: yellow;">$1</span>')
// events
.replace(eventPattern, '<span
class="flowControl">$1</span>')
// objects
.replace(objectPattern, '<span
class="objects">$1</span>')
// function
.replace(/\bfunction\b/g, '<span
class="pink">function</span>')
// let
.replace(/\blet\b/g, '<span
class="pink">let</span>')
// new
.replace(/\bnew\b/g, '<span
class="pink">new</span>')
// digits
.replace(/\d/g, '<span
class="lightGray">$&</span>')
// flowControl
.replace(/\b(if|else|do|while|for|forEach|
break|continue)\b/g, '<span
class="magenta">$1</span>');
codeOutput.innerHTML = highlightedCode;
}
codeInput.addEventListener('input',
highlightCode);
codeInput.addEventListener('scroll',
function()
{
codeOutput.scrollTop = this.scrollTop;
});
highlightCode();
codeInput.addEventListener("keydown",
function(event)
{
if (event.key === "Tab")
{
// prevent default tab behavior
event.preventDefault();
highlightCode();
});
</script>
</body>
</html>
How to Combine
.js files
into one
main.js file
using
Command
Prompt
:: Topalian_Combine_JS_Files.bat
@echo off
:: set the output file name
set "output=main.js"
let fs = require('fs');
let path = require('path');
function combineJSFiles(directory,
scriptFilename)
{
let outputFilePath = path.join(directory,
'main.js');
function traverseFolder(folder)
{
let files = fs.readdirSync(folder);
if (stats.isDirectory())
{
traverseFolder(filePath);
}
else if (path.extname(filePath) === '.js')
{
let content =
fs.readFileSync(filePath, 'utf8');
// check if file is not script file itself
if (filePath !== scriptFilename)
{
fileContents.push(content);
}
}
}
}
traverseFolder(directory);
fs.writeFileSync(outputFilePath,
fileContents.join('\n'), 'utf8');
console.log(`Combined $
{fileContents.length} .js files into $
{outputFilePath}`);
}
combineJSFiles(currentDirectory,
scriptFilename);
How to Combine
.js files
into one
main.js file
using
Python
import os
def combineJSFiles(directory,
scriptFileName):
outputFilePath = os.path.join(directory,
'main.js')
fileContents = []
def traverseFolder(folder):
for root, dirs, files in os.walk(folder):
for file in files:
filePath = os.path.join(root, file)
if filePath != scriptFileName and
filePath.endswith('.js'):
with open(filePath, 'r',
encoding='utf-8') as f:
fileContents.append(f.read())
traverseFolder(directory)
OR NOR
0111 1000
RC LC
1010 1100
XOR NAND
0110 1110
CNI MNI
Contra-
0100 0010
-diction
0000
For More Tutorials:
GitHub.com/ChristopherTopalian
GitHub.com/ChristopherAndrewTopalian
Sites.google.com/view/CollegeOfScripting
CollegeOfScripting.weebly.com
CollegeOfScripting.wordpress.com
Youtube.com/ScriptingCollege
Twitter.com/CollegeOfScript
Rumble.com/user/CollegeOfScripting
Dedicated to God the Father
This book is created by the
College of Scripting Music & Science.
Always remember, that each time you write a script
with a pencil and paper, it becomes imprinted so
deeply in memory that the material and methods are
learned extremely well.
When you Type the scripts, the same is true. The
more you type and write out the scripts by keyboard
or pencil and paper, the more you will learn
programming!
Write and Type every example that you find.
Keep all of your scripts organized.
Every script that you create increases your
programming abilities.
SEEING CODE, is one thing,
but WRITING CODE is another.
Write it, Type it, Speak it, See it, Dream it.
CollegeOfScripting.weebly.com