Topalian JavaScript Text Investigator by Christopher Topalian
Topalian JavaScript Text Investigator by Christopher Topalian
JavaScript
Text
Investigator
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 -->
<!-- https://github.com/ChristopherTopalian/ --
>
<!--
Topalian_JavaScript_Text_Investigator.html --
>
<!-- Version 001 - (2024-07-12) -->
<html>
<head>
<title> Topalian JavaScript Text Investigator
</title>
<script src =
'src/js/4text/getWordCount.js'></script>
<script src =
'src/js/4text/calculateAvgWordLength.js'></sc
ript>
<script src =
'src/js/4text/getWordFrequency.js'></script>
<script src =
'src/js/4text/detectSentiment.js'></script>
<script src =
'src/js/4text/extractKeywords.js'></script>
<script src =
'src/js/4text/categorizeWords.js'></script>
<script src =
'src/js/4text/extractKeywordsUppercase.js'></
script>
<script src =
'src/js/4text/titleCaseKeywords.js'></script>
<script src =
'src/js/4text/format/lowercaseText.js'></script
>
<script src =
'src/js/4text/format/capitalizeFirstLetters.js'><
/script>
<script src =
'src/js/4text/format/boldText.js'></script>
<script src =
'src/js/4text/format/normalText.js'></script>
<script src =
'src/js/4text/format/italicText.js'></script>
<script src =
'src/js/4text/format/underlineText.js'></script>
<script src =
'src/js/4text/format/formatAsBulletedList.js'><
/script>
<script src =
'src/js/fetch/fetchMostRecentEarthquakeData.
js'></script>
<script src =
'src/js/fetch/fetchAllEarthquakeData.js'></scri
pt>
<script src =
'src/js/sound/loadSounds.js'></script>
<script src =
'src/js/sound/audioPlay.js'></script>
</body>
</html>
/* Dedicated to God the Father */
/* All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024 */
/* https://github.com/ChristopherTopalian */
/*
https://github.com/ChristopherAndrewTopalia
n */
/* style001.css */
body
{
background-color: rgb(30, 30, 30);
font-family: Arial;
font-size: 20px;
color: rgb(255, 255, 255);
}
textarea
{
padding-left: 10px;
padding-right: 10px;
padding-top: 10px;
padding-bottom: 10px;
border: solid 1px rgb(0, 0, 0);
border-radius: 8px;
background-color: rgb(0, 0, 0);
font-family: Arial;
font-size: 20px;
color: rgb(255, 255, 255);
}
a
{
color: rgb(100, 100, 100);
text-decoration: none;
}
a:hover
{
text-decoration: underline;
}
#mainContainer
{
width: 95%;
margin: auto;
}
#textInput
{
width: 100%;
height: 150px;
}
#resultContainer
{
margin-top: 5px;
padding-left: 10px;
padding-right: 10px;
padding-top: 10px;
padding-bottom: 10px;
border: solid 1px rgb(0, 0, 0);
border-radius: 8px;
background-color: rgb(0, 0, 0);
font-family: Arial;
font-size: 20px;
color: rgb(255, 255, 255);
}
.buttonStyle001
{
max-height: 40px;
margin: 2px;
padding-left: 10px;
padding-right: 10px;
padding-top: 2px;
padding-bottom: 2px;
border: solid 1px rgb(100, 100, 100);
border-radius: 8px;
background-color: rgb(0, 0, 0);
font-size: 15px;
color: rgb(255, 255, 255);
cursor: pointer;
box-sizing: border-box;
}
.buttonStyle001:hover
{
border-color: rgb(0, 255, 255);
}
.buttonStyle001:active
{
position: relative;
top: 1px;
border-color: rgb(255, 0, 255);
color: rgb(255, 0, 255);
}
*{
scrollbar-width: thin;
scrollbar-color: rgb(100, 100, 100) rgb(0, 0,
0);
}
// Dedicated to God the Father
// All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n
// shortcuts.js
function ge(whichId)
{
let result =
document.getElementById(whichId);
return result;
}
function ce(whichType)
{
let result =
document.createElement(whichType);
return result;
}
function ba(whichElement)
{
let result =
document.body.append(whichElement);
return result;
}
// Dedicated to God the Father
// All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n
// worldVariables.js
function makeInterface()
{
// mainContainer
let mainContainer = ce('div');
mainContainer.id = 'mainContainer';
mainContainer.style.position = 'absolute';
mainContainer.style.left = '20px';
mainContainer.style.top = '25px';
ba(mainContainer);
//-//
// textInput
let textInput = ce('textarea');
textInput.id = 'textInput';
textInput.placeholder = 'Enter words
here...';
mainContainer.append(textInput);
//-//
// btnDivInternetData
let btnDivInternetData = ce('div');
btnDivInternetData.style.display = 'flex';
btnDivInternetData.style.flexDirection =
'row';
btnDivInternetData.style.overflowX = 'auto';
btnDivInternetData.style.whiteSpace =
'nowrap';
btnDivInternetData.addEventListener('wheel',
function(event)
{
if (event.deltaY !== 0)
{
btnDivInternetData.scrollLeft +=
event.deltaY;
event.preventDefault();
}
});
mainContainer.append(btnDivInternetData);
//-//
let internetDataBtnArray =
[
{
name: 'Earthquake (latest)',
functionName:
`fetchMostRecentEarthquakeData()`,
description: 'Get most recent
Earthquake data from the internet'
},
{
name: 'Earthquake (All)',
functionName:
`fetchAllEarthquakeData()`,
description: 'Get all Earthquake data
from the internet'
},
{
name: 'Get Random Joke',
functionName: `fetchRandomJoke()`,
description: 'Get a random joke from
the internet'
}
];
theButton.onclick = function(buttonInfo)
{
audioPlay('sfx_blip_001', 1.0);
ge('resultContainer').innerHTML =
eval(internetDataBtnArray[i].functionName);
}
btnDivInternetData.append(theButton);
}
//-//
// btnDivAnalyzeText
let btnDivAnalyzeText = ce('div');
btnDivAnalyzeText.style.display = 'flex';
btnDivAnalyzeText.style.flexDirection =
'row';
btnDivAnalyzeText.style.overflowX = 'auto';
btnDivAnalyzeText.style.whiteSpace =
'nowrap';
mainContainer.append(btnDivAnalyzeText);
//-//
let analyzeButtons =
[
{
name: 'Word Count',
functionName:
`getWordCount(textInput.value)`,
description: 'Count the number of
words'
},
{
name: 'Word Frequency',
functionName:
`getWordFrequency(textInput.value)`,
description: 'Count the frequency of
each word'
},
{
name: 'Pattern Recognition',
functionName:
`detectPattern(textInput.value)`,
description: 'Search for Pattern of
word THE'
},
{
name: 'Average Word Length',
functionName:
`calculateAvgWordLength(textInput.value)`,
description: 'Average length of words'
},
{
name: 'Sentiment Rating',
functionName:
`detectSentiment(textInput.value)`,
description: 'The general intention of
the text'
},
{
name: 'Extract Keywords',
functionName:
`extractKeywords(textInput.value)`,
description: 'Get Keywords without
getting common link words'
},
{
name: 'Extract Keywords Uppercase',
functionName:
`extractKeywordsUppercase(textInput.value)`
,
description: 'Uppercase extracted
keywords'
},
{
name: 'Titlecase Keywords',
functionName:
`titleCaseKeywords(textInput.value)`,
description: 'Titlecases the words'
},
{
name: 'Categorize Words',
functionName:
`categorizeWords(textInput.value)`,
description: 'Put words into
categories'
},
];
theButton.onclick = function(buttonInfo)
{
audioPlay('sfx_blip_001', 1.0);
ge('resultContainer').innerHTML =
eval(analyzeButtons[i].functionName);
}
btnDivAnalyzeText.append(theButton);
}
//-//
// btnDivFormatting
let btnDivFormatting = ce('div');
btnDivFormatting.style.display = 'flex';
btnDivFormatting.style.flexDirection =
'row';
btnDivFormatting.style.overflowX = 'auto';
btnDivFormatting.style.whiteSpace =
'nowrap';
btnDivFormatting.addEventListener('wheel',
function(event)
{
if (event.deltaY !== 0)
{
btnDivFormatting.scrollLeft +=
event.deltaY;
event.preventDefault();
}
});
mainContainer.append(btnDivFormatting);
//-//
let formattingButtons =
[
{
name: 'Capitalize Text',
functionName:
`capitalizeText(textInput.value)`,
description: 'Capitalizes all words'
},
{
name: 'Lowercase Text',
functionName:
`lowercaseText(textInput.value)`,
description: 'Lowercases all words'
},
{
name: 'Capitalize 1st Letter',
functionName:
`capitalizeFirstLetters(textInput.value)`,
description: 'Capitalizes the 1st Letter
of each word'
},
{
name: 'Bold Text',
functionName:
`boldText(textInput.value)`,
description: 'Bold all words'
},
{
name: 'Normal Text',
functionName:
`normalText(textInput.value)`,
description: 'Normalize all words'
},
{
name: 'Italic Text',
functionName:
`italicText(textInput.value)`,
description: 'Italicize all words'
},
{
name: 'Underline Text',
functionName:
`underlineText(textInput.value)`,
description: 'Underline all words'
},
{
name: 'Format as Bulleted List',
functionName:
`formatAsBulletedList(textInput.value)`,
description: 'Format words as Bullet
List'
}
];
theButton.onclick = function(buttonInfo)
{
audioPlay('sfx_blip_001', 1.0);
ge('resultContainer').innerHTML =
eval(formattingButtons[i].functionName);
}
btnDivFormatting.append(theButton);
}
//-//
function makeTitleOfApp()
{
// titleContainer
let titleContainer = ce('div');
titleContainer.style.position = 'absolute';
titleContainer.style.right = '20px';
titleContainer.style.top =
titleContainer.style.top = '2px';
titleContainer.style.zIndex = 1;
ba(titleContainer);
//-//
// titleOfApp
let titleOfApp = ce('div');
titleOfApp.id = 'titleOfApp';
titleOfApp.innerHTML =
`<a href =
'https://github.com/christophertopalian/topali
an_javascript_text_investigator' target =
'_blank'> Topalian JavaScript Text
Investigator </a>`;
titleOfApp.style.fontSize = '17px';
titleOfApp.style.fontWeight = 'bold';
titleContainer.append(titleOfApp);
}
// Dedicated to God the Father
// All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n
// calculateAvgWordLength.js
function calculateAvgWordLength(whichText)
{
let words = whichText.split(/\s+/);
let totalLength = 0;
let wordCount = 0;
if (wordCount > 0)
{
return (totalLength /
wordCount).toFixed(2);
}
else
{
return 0;
}
}
// Dedicated to God the Father
// All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n
//categorizeWords.js
function categorizeWords(whichText)
{
// define word categories
let categories =
{
specifier: ["the", "a", "an", "those",
"that", "them", "they", "this"],
connector: ["and", "but", "or",
"however", "therefore"],
thing: ["chair", "table", "car"],
time: ["early", "late", "morning",
"evening", "yesterday", "today", "tomorrow",
"now", "then", "when"]
};
let categoryWords =
categories[category];
categoryFound = true;
break;
}
}
if (categoryFound)
{
break;
}
}
function detectPattern(whichText)
{
let pattern = /the/gi;
let matchCount;
if (matches)
{
matchCount = matches.length;
}
else
{
matchCount = 0;
}
return matchCount;
}
// Dedicated to God the Father
// All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n
// detectSentiment.js
function detectSentiment(whichText)
{
// positive words
let positiveWords = ["happy", "joy", "love",
"excellent", "good", "great", "fantastic",
"positive", "nice", "wonderful"];
// negative words
let negativeWords = ["sad", "anger",
"hate", "terrible", "bad", "horrible",
"negative", "mean", "evil"];
let sentiment;
// determine sentiment
if (positiveScore > negativeScore)
{
sentiment = "Positive";
}
else if (negativeScore > positiveScore)
{
sentiment = "Negative";
}
else
{
sentiment = "Neutral";
}
return sentiment;
}
// Dedicated to God the Father
// All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n
// extractKeywords.js
function extractKeywords(whichText)
{
// array of common stop words to ignore
let stopWords = ["a", "an", "and", "the",
"in", "on", "at", "of", "to", "is", "it", "that",
"this", "with", "for", "as", "by", "but", "or",
"nor", "up", "down", "out", "over", "under",
"again", "further", "then", "once", "here",
"there", "when", "where", "why", "how", "all",
"any", "both", "each", "few", "more", "most",
"other", "some", "such", "no", "nor", "too",
"very", "can", "will", "just", "should", "now"];
function
extractKeywordsUppercase(whichText)
{
// array of common stop words to ignore
let stopWords = ["a", "an", "and", "the",
"in", "on", "at", "of", "to", "is", "it", "that",
"this", "with", "for", "as", "by", "but", "or",
"nor", "up", "down", "out", "over", "under",
"again", "further", "then", "once", "here",
"there", "when", "where", "why", "how", "all",
"any", "both", "each", "few", "more", "most",
"other", "some", "such", "no", "nor", "too",
"very", "can", "will", "just", "should", "now"];
function getWordCount(whichText)
{
let words = whichText.split(/\s+/);
let wordCount = 0;
return wordCount;
}
// Dedicated to God the Father
// All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n
// getWordFrequency.js
function getWordFrequency(whichText)
{
let words =
whichText.toLowerCase().split(/\s+/);
if (word.length > 0)
{
if (frequency[word])
{
frequency[word]++;
}
else
{
frequency[word] = 1;
}
}
}
return frequencyList;
}
// Dedicated to God the Father
// All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n
// titleCaseKeywords.js
function titleCaseKeywords(whichText)
{
// array of common stop words to ignore
let stopWords = ["a", "an", "and", "the",
"in", "on", "at", "of", "to", "is", "it", "that",
"this", "with", "for", "as", "by", "but", "or",
"nor"];
// convert whichText to lowercase and split
it into words
let words = whichText.toLowerCase().split('
');
resultWords.push(word.charAt(0).toUpperCa
se() + word.slice(1));
continue;
}
resultWords.push(word.charAt(0).toUpperCa
se() + word.slice(1));
}
else
{
resultWords.push(word);
}
}
function boldText(whichText)
{
let bold = "<b>" + whichText + "</b>";
return bold;
}
// Dedicated to God the Father
// All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n
// capitalizeFirstLetters.js
function capitalizeFirstLetters(whichText)
{
// split whichText into words
let words = whichText.split(" ");
capitalizedWords.push(capitalizedWord);
}
else
{
capitalizedWords.push(word);
}
}
function capitalizeText(whichText)
{
let upperCase = whichText.toUpperCase();
return upperCase;
}
// Dedicated to God the Father
// All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n
// formatAsBulletedList.js
function formatAsBulletedList(whichText)
{
let words = whichText.split(' ');
function italicText(whichText)
{
let bold = "<i>" + whichText + "</i>";
return bold;
}
// Dedicated to God the Father
// All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n
// lowercaseText.js
function lowercaseText(whichText)
{
let lowerCase = whichText.toLowerCase();
return lowerCase;
}
// Dedicated to God the Father
// All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n
// normalText.js
function normalText(whichText)
{
// replace <b> and </b> tags with empty
strings
whichText = whichText.replace(/<\/?b>/gi,
"");
return whichText;
}
// Dedicated to God the Father
// All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n
// underlineText.js
function underlineText(whichText)
{
let underline = "<u>" + whichText + "</u>";
return underline;
}
// Dedicated to God the Father
// All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n
// fetchAllEarthquakeData.js
function fetchAllEarthquakeData()
{
return
fetch('https://earthquake.usgs.gov/fdsnws/ev
ent/1/query?
format=geojson&orderby=time&minmagnitud
e=4.5')
.then(function(response)
{
if (!response.ok)
{
throw new Error('Network response
was not ok');
}
return response.json();
})
.then(function(data)
{
if (data.features.length > 0)
{
let earthquakeList = [];
// format date
let date = new
Date(earthquake.properties.time);
let formattedDate = `$
{date.toDateString()} $
{date.toLocaleTimeString()}`;
ge("textInput").value =
allEarthquakesInfo;
.catch(function(error)
{
console.error('Error fetching earthquake
data:', error);
function fetchMostRecentEarthquakeData()
{
fetch('https://earthquake.usgs.gov/fdsnws/ev
ent/1/query?
format=geojson&orderby=time&minmagnitud
e=4.5')
.then(function(response)
{
if (!response.ok)
{
throw new Error('Network response
was not ok');
}
return response.json();
})
.then(function(data)
{
if (data.features.length > 0)
{
// get most recent earthquake
let earthquake = data.features[0];
// format date
let date = new
Date(earthquake.properties.time);
let formattedDate = `$
{date.toDateString()} $
{date.toLocaleTimeString()}`;
return earthquakeInfo;
}
else
{
throw new Error('No earthquake data
found');
}
})
.catch(function(error)
{
console.error('Error fetching earthquake
data:', error);
});
}
// Dedicated to God the Father
// All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n
// fetchRandomJoke.js
function fetchRandomJoke()
{
fetch('https://official-joke-
api.appspot.com/random_joke')
.then(function(response)
{
return response.json();
})
.then(function(data)
{
let joke = data.setup + " " +
data.punchline;
ge("textInput").value = joke;
})
.catch(function(error)
{
console.error('Error fetching joke:',
error);
});
}
// Dedicated to God the Father
// All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n
// audioPlay.js
if (audio)
{
audio.volume = whichVolume;
audio.play();
}
}
// Dedicated to God the Father
// All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n
// loadSounds.js
function loadSounds(whichArray)
{
for (let x = 0; x < whichArray.length; x++)
{
let theSound = ce('audio');
if (online == false)
{
theSound.src =
whichArray[x].soundFileOffline;
}
else
{
theSound.src =
whichArray[x].soundFileOnline;
}
theSound.id = whichArray[x].name;
theSound.loop = false;
theSound.volume = 1.0;
ba(theSound);
}
}
// Dedicated to God the Father
// All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n
// sounds.js
let sounds =
[
{
name: 'sfx_blip_001',
soundFileOffline:
'src/media/sounds/sfx_blip_001.mp4',
soundFileOnline:
'https://collegeofscripting.weebly.com/upload
s/6/4/4/8/64482293/sfx_blip_001.mp4'
},
{
name: 'sfx_warp_001',
soundFileOffline:
'src/media/sounds/sfx_warp_001.mp3',
soundFileOnline:
'https://collegeofscripting.weebly.com/upload
s/6/4/4/8/64482293/sfx_warp_001.mp3'
}
];
// Dedicated to God the Father
// All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n
// whenLoaded.js
function whenLoaded()
{
loadSounds(sounds);
makeInterface();
makeTitleOfApp();
}
How to Combine
.js files
into one
main.js file
using
Command
Prompt
@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