0% found this document useful (0 votes)
46 views

Topalian Python JavaScript Navigator by Christopher Topalian

PyWebview is a very nice way to make a graphical user interface using Python and JavaScript together. We make our application using PyWebview and we get to use HTML, CSS, JS and PY together! CODE: https://github.com/ChristopherTopalian/Topalian_Python_JavaScript_Navigator and VIDEO: https://www.youtube.com/watch?v=FLkqqM1QTzE Happy Scripting :-)
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

Topalian Python JavaScript Navigator by Christopher Topalian

PyWebview is a very nice way to make a graphical user interface using Python and JavaScript together. We make our application using PyWebview and we get to use HTML, CSS, JS and PY together! CODE: https://github.com/ChristopherTopalian/Topalian_Python_JavaScript_Navigator and VIDEO: https://www.youtube.com/watch?v=FLkqqM1QTzE Happy Scripting :-)
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 119

Topalian

Python
JavaScript
Navigator
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_Python_JavaScript_Navigator.pyw
# Version 001 - (2024-06-13)

# pip install pywebview

import webview
import base64

from py.date.getDate import getDate


from py.date.getDateTime12 import
getDateTime12
from py.date.getDayOfMonth import
getDayOfMonth
from py.date.getDayOfWeekName import
getDayOfWeekName
from py.date.getDayOfWeekNumber import
getDayOfWeekNumber
from py.date.getDayOfWeekNumber7 import
getDayOfWeekNumber7
from py.date.getMonthNumber import
getMonthNumber
from py.date.getYear import getYear

from py.time.getTime12 import getTime12


from py.time.getTime24 import getTime24

##
# Our JS is imported below

with open("js/date/getDateJS.js", "r") as file:


getDateJS = file.read()

with open("js/date/getDateTimeJS.js", "r") as


file:
getDateTimeJS = file.read()

with open("js/date/getDayOfMonthJS.js", "r")


as file:
getDayOfMonthJS = file.read()

with open("js/date/getDayOfWeekNameJS.js",
"r") as file:
getDayOfWeekNameJS = file.read()
with
open("js/date/getDayOfWeekNumber7JS.js",
"r") as file:
getDayOfWeekNumber7JS = file.read()

with
open("js/date/getDayOfWeekNumberJS.js",
"r") as file:
getDayOfWeekNumberJS = file.read()

with open("js/date/getMonthNumberJS.js",
"r") as file:
getMonthNumberJS = file.read()

with open("js/date/getYearJS.js", "r") as file:


getYearJS = file.read()
with open("js/time/getTime12JS.js", "r") as
file:
getTime12JS = file.read()

with open("js/time/getTime24JS.js", "r") as


file:
getTime24JS = file.read()

##

def getFileContent(filePath):
try:
with open(filePath, 'r') as file:
return file.read()
except FileNotFoundError:
return "File not found."
except Exception as e:
return str(e)
##

# reads texture file and encodes it as base64


def readImageAsBase64(filePath):
with open(filePath, "rb") as file:
imageData = file.read()
encodedImage =
base64.b64encode(imageData).decode("utf-
8")
return encodedImage

bgTexturePath = "media/textures/bg001.jpg"
bgImage =
readImageAsBase64(bgTexturePath)

##
htmlContent = f"""
<html>
<head>
<title> Topalian Python JavaScript Navigator
</title>

<style>

body
{{
background-color: rgb(0, 0, 0);
font-family: Arial;
color: rgb(255, 255, 255);
}}

#bg
{{
position: fixed;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
object-fit: cover;
z-index: -1;
}}

.textStyle001
{{
width: 300px;
margin: 2px;
border: solid 1px rgb(100, 100, 100);
border-radius: 8px;
padding-left: 10px;
padding-right: 10px;
background-color: rgb(0, 0, 0);
font-family: Arial;
font-size: 16px;
font-weight: bold;
color: rgb(150, 150, 150);
overflow: hidden;
cursor: pointer;
}}

.textStyle001:hover
{{
border-color: rgb(0, 255, 255);
}}

#code
{{
width: 99%;
height: 130vh;
margin: 2px;
border: solid 1px rgb(100, 100, 100);
border-radius: 8px;
padding-left: 10px;
padding-right: 10px;
padding-top: 5px;
padding-bottom: 5px;
background-color: rgb(0, 0, 0);
font-family: Arial;
font-size: 24px;
font-weight: bold;
color: rgb(220, 220, 220);
overflow-y: scroll;
cursor: pointer;
}}

* {{
scrollbar-width: thin;
scrollbar-color: rgb(100, 100, 100) rgb(0, 0,
0);
}}

</style>

<script>

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;
}}

//-//

// since we don't use two {{


// when we defined our functions
// we have to include these brackets
// as shown below:
{ getDateJS }
{ getDateTimeJS }
{ getDayOfMonthJS }
{ getDayOfWeekNameJS }
{ getDayOfWeekNumberJS }
{ getDayOfWeekNumber7JS }
{ getMonthNumberJS }
{ getYearJS }

{ getTime12JS }
{ getTime24JS }

//-//

function makeInterface()
{{
let mainDiv = ce('div');
mainDiv.id = 'mainDiv';
ba(mainDiv);

//-//

let divContainer = ce('div');


divContainer.id = 'divContainer';
divContainer.style.display = 'grid';
divContainer.style.gridTemplateColumns =
'repeat(2, 1fr)';
divContainer.style.gap = '2.5px';
mainDiv.append(divContainer);

//-//

// leftContainer
let leftContainer = ce('div');
leftContainer.id = 'leftContainer';
leftContainer.style.overflowY = 'scroll';
leftContainer.style.height = '200px';
divContainer.append(leftContainer);

//-//

let pyLabel = ce('div');


pyLabel.id = 'pyLabel';
pyLabel.textContent = 'PY';
pyLabel.style.fontWeight = 'bold';
leftContainer.append(pyLabel);

//-//

let datePY = ce('input');


datePY.id = 'datePY';
datePY.className = 'textStyle001';
datePY.value = 'Date: ' + '{getDate()}';
datePY.title = 'getDate()';
datePY.onclick = function()
{{
ge('code').value =
`{getFileContent('py/date/getDate.py')}`;
}};
leftContainer.append(datePY);

//-//

let time12PY = ce('input');


time12PY.id = 'time12PY';
time12PY.className = 'textStyle001';
time12PY.value = 'Time: ' + '{getTime12()}';
time12PY.title = 'getTime12()';
time12PY.onclick = function()
{{
ge('code').value =
`{getFileContent('py/time/getTime12.py')}`;
}};
leftContainer.append(time12PY);

//-//

let time24PY = ce('input');


time24PY.id = 'time24PY';
time24PY.className = 'textStyle001';
time24PY.value = 'Military Time: ' +
'{getTime24()}';
time24PY.title = 'getTime24()';
time24PY.onclick = function()
{{
ge('code').value =
`{getFileContent('py/time/getTime24.py')}`;
}};
leftContainer.append(time24PY);
//-//

let dateTime12PY = ce('input');


dateTime12PY.id = 'dateTime12PY';
dateTime12PY.className = 'textStyle001';
dateTime12PY.value = 'Date Time: ' +
'{getDateTime12()}';
dateTime12PY.title = 'getDateTime12()';
dateTime12PY.onclick = function()
{{
ge('code').value =
`{getFileContent('py/date/getDateTime12.py')}
`;
}};
leftContainer.append(dateTime12PY);

//-//
let yearPY = ce('input');
yearPY.id = 'yearPY';
yearPY.className = 'textStyle001';
yearPY.value = 'Year: ' + '{getYear()}';
yearPY.title = 'getYear()';
yearPY.onclick = function()
{{
ge('code').value =
`{getFileContent('py/date/getYear.py')}`;
}};
leftContainer.append(yearPY);

//-//

let monthNumberPY = ce('input');


monthNumberPY.id = 'monthNumberPY';
monthNumberPY.className =
'textStyle001';
monthNumberPY.value = 'Month Number: '
+ '{getMonthNumber()}';
monthNumberPY.title =
'getMonthNumber()';
monthNumberPY.onclick = function()
{{
ge('code').value =
`{getFileContent('py/date/getMonthNumber.py
')}`;
}};
leftContainer.append(monthNumberPY);

//-//

let dayOfMonthPY = ce('input');


dayOfMonthPY.id = 'dayOfMonthPY';
dayOfMonthPY.className = 'textStyle001';
dayOfMonthPY.value = 'Day of Month: ' +
'{getDayOfMonth()}';
dayOfMonthPY.title = 'getDayOfMonth()';
dayOfMonthPY.onclick = function()
{{
ge('code').value =
`{getFileContent('py/date/getDayOfMonth.py')
}`;
}};
leftContainer.append(dayOfMonthPY);

//-//

let dayOfWeekNamePY = ce('input');


dayOfWeekNamePY.id =
'dayOfWeekNamePY';
dayOfWeekNamePY.className =
'textStyle001';
dayOfWeekNamePY.value = 'Day of Week
Name: ' + '{getDayOfWeekName()}';
dayOfWeekNamePY.title =
'getDayOfWeekName()';
dayOfWeekNamePY.onclick = function()
{{
ge('code').value =
`{getFileContent('py/date/getDayOfWeekNam
e.py')}`;
}};
leftContainer.append(dayOfWeekNamePY);

//-//

let dayOfWeekNumberPY = ce('input');


dayOfWeekNumberPY.id =
'dayOfWeekNumberPY';
dayOfWeekNumberPY.className =
'textStyle001';
dayOfWeekNumberPY.value = 'Day of Week
Number: ' + '{getDayOfWeekNumber()}';
dayOfWeekNumberPY.title =
'getDayOfWeekNumber()';
dayOfWeekNumberPY.onclick = function()
{{
ge('code').value =
`{getFileContent('py/date/getDayOfWeekNum
ber.py')}`;
}};

leftContainer.append(dayOfWeekNumberPY);

//-//

let dayOfWeekNumber7PY = ce('input');


dayOfWeekNumber7PY.id =
'dayOfWeekNumber7PY';
dayOfWeekNumber7PY.className =
'textStyle001';
dayOfWeekNumber7PY.value = 'Day of
Week Number 7th: ' +
'{getDayOfWeekNumber7()}';
dayOfWeekNumber7PY.title =
'getDayOfWeekNumber7()';
dayOfWeekNumber7PY.onclick = function()
{{
ge('code').value =
`{getFileContent('py/date/getDayOfWeekNum
ber7.py')}`;
}};

leftContainer.append(dayOfWeekNumber7PY)
;
//----//

// rightContainer
let rightContainer = ce('div');
rightContainer.id = 'rightContainer';
rightContainer.style.overflowY = 'scroll';
rightContainer.style.height = '200px';
divContainer.append(rightContainer);

//-//

let jsLabel = ce('div');


jsLabel.id = 'jsLabel';
jsLabel.textContent = 'JS';
jsLabel.style.fontWeight = 'bold';
rightContainer.append(jsLabel);
//-//

let dateJS = ce('input');


dateJS.id = 'dateJS';
dateJS.className = 'textStyle001';
dateJS.value = 'Date: ' + getDateJS();
dateJS.title = 'getDateJS()';
dateJS.onclick = function()
{{
ge('code').value = getDateJS;
}};
rightContainer.append(dateJS);

//-//

let time12JS = ce('input');


time12JS.id = 'time12JS';
time12JS.className = 'textStyle001';
time12JS.value = 'Time: ' + getTime12JS();
time12JS.title = 'getTime12JS()';
time12JS.onclick = function()
{{
ge('code').value = getTime12JS;
}};
rightContainer.append(time12JS);

//-//

let time24JS = ce('input');


time24JS.id = 'time24JS';
time24JS.className = 'textStyle001';
time24JS.value = 'Military Time: ' +
getTime24JS();
time24JS.title = 'getTime24JS()';
time24JS.onclick = function()
{{
ge('code').value = getTime24JS;
}};
rightContainer.append(time24JS);

//-//

let dateTimeJS = ce('input');


dateTimeJS.id = 'dateTimeJS';
dateTimeJS.className = 'textStyle001';
dateTimeJS.value = 'Date Time: ' +
getDateTimeJS();
dateTimeJS.title = 'getDateTimeJS()';
dateTimeJS.onclick = function()
{{
ge('code').value = getDateTimeJS;
}};
rightContainer.append(dateTimeJS);
//-//

let yearJS = ce('input');


yearJS.id = 'yearJS';
yearJS.className = 'textStyle001';
yearJS.value = 'Year: ' + getYearJS();
yearJS.title = 'getYearJS()';
yearJS.onclick = function()
{{
ge('code').value = getYearJS;
}};
rightContainer.append(yearJS);

//-//

let monthNumberJS = ce('input');


monthNumberJS.id = 'monthNumberJS';
monthNumberJS.className =
'textStyle001';
monthNumberJS.value = 'Month Number: '
+ getMonthNumberJS();
monthNumberJS.title = '
getMonthNumberJS()';
monthNumberJS.onclick = function()
{{
ge('code').value = getMonthNumberJS;
}};
rightContainer.append(monthNumberJS);

//-//

let dayOfMonthNumberJS = ce('input');


dayOfMonthNumberJS.id =
'dayOfMonthNumberJS';
dayOfMonthNumberJS.className =
'textStyle001';
dayOfMonthNumberJS.value = 'Day of
Month: ' + getDayOfMonthJS();
dayOfMonthNumberJS.title =
'getDayOfMonthJS()';
dayOfMonthNumberJS.onclick = function()
{{
ge('code').value = getDayOfMonthJS;
}};

rightContainer.append(dayOfMonthNumberJ
S);

//-//

let dayOfWeekNameJS = ce('input');


dayOfWeekNameJS.id =
'dayOfWeekNameJS';
dayOfWeekNameJS.className =
'textStyle001';
dayOfWeekNameJS.value = 'Day of Week
Name: ' + getDayOfWeekNameJS();
dayOfWeekNameJS.title =
'getDayOfWeekNameJS()';
dayOfWeekNameJS.onclick = function()
{{
ge('code').value =
getDayOfWeekNameJS;
}};

rightContainer.append(dayOfWeekNameJS);

//-//
let dayOfWeekNumberJS = ce('input');
dayOfWeekNumberJS.id =
'dayOfWeekNumberJS';
dayOfWeekNumberJS.className =
'textStyle001';
dayOfWeekNumberJS.value = 'Day of Week
Number: ' + getDayOfWeekNumberJS();
dayOfWeekNumberJS.title =
'getDayOfWeekNumberJS()';
dayOfWeekNumberJS.onclick = function()
{{
ge('code').value =
getDayOfWeekNumberJS;
}};

rightContainer.append(dayOfWeekNumberJS)
;
//-//

let dayOfWeekNumber7JS = ce('input');


dayOfWeekNumber7JS.id =
'dayOfWeekNumber7JS';
dayOfWeekNumber7JS.className =
'textStyle001';
dayOfWeekNumber7JS.value = 'Day of
Week Number 7th: ' +
getDayOfWeekNumber7JS();
dayOfWeekNumber7JS.title =
'getDayOfWeekNumber7JS()';
dayOfWeekNumber7JS.onclick = function()
{{
ge('code').value =
getDayOfWeekNumber7JS;
}};
rightContainer.append(dayOfWeekNumber7J
S);

//-//

let hr001 = ce('hr');


mainDiv.append(hr001);

//-//

// centerContainer
let centerContainer = ce('div');
centerContainer.id = 'centerContainer';
centerContainer.style.overflowY = 'scroll';
centerContainer.style.height = '270px';
mainDiv.append(centerContainer);
//-//

let codeLabel = ce('div');


codeLabel.id = 'codeLabel';
codeLabel.textContent = 'CODE';
codeLabel.style.fontWeight = 'bold';
centerContainer.append(codeLabel);

//-//

let codeTextarea = ce('textarea');


codeTextarea.id = 'code';
centerContainer.append(codeTextarea);
}}

//-//

window.onload = function()
{{
makeInterface();
}};

</script>

</head>

<body>

<img src = "data:image/jpeg;base64,


{bgImage}" alt = "bgTexture" id = 'bg'>

</body>

</html>

"""
if __name__ == "__main__":
# we can start the window at a small size
# to avoid flashing white on the screen
# and then maximize it manually
widthOfWindow = 1200 #20
heightOfWindow = 670 # 20

# create window with HTML content


webview.create_window("Topalian Python
JavaScript Navigator", html=htmlContent,
width=widthOfWindow,
height=heightOfWindow)

# start pywebview event loop


# debug True enables console
webview.start(debug=True)
# getDate.py

import datetime as dt

def getDate():
today = dt.date.today()

return today

# print(getDate())
# input('')

#--------------------#
# 2024-06-10
#--------------------#

# Dedicated to God the Father


# All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
# getDate.py
# https://github.com/ChristopherTopalian
#
https://github.com/ChristopherAndrewTopalia
n

#********************#
# getDateTime12.py

import datetime as dt

def getDateTime12():
currentDateTime = dt.datetime.now()

# formatted date MM-DD-YY


date = currentDateTime.strftime("%m-%d-
%y")

# formatted time HH:MM AM/PM


time = currentDateTime.strftime("%I:%M
%p")

formattedDateTime = date + " " + time

return formattedDateTime
# print(getDateTime12())
# input('')

#--------------------#
# 06-11-24 05:33 PM
#--------------------#

# Dedicated to God the Father


# All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
# getDateTime12.py
# https://github.com/ChristopherTopalian
#
https://github.com/ChristopherAndrewTopalia
n

#********************#
# getDayOfMonth.py

import datetime as dt

def getDayOfMonth():
currentDate = dt.datetime.now()

dayNumber = currentDate.day

return dayNumber

# print(getDayOfMonth())
# input('')

#--------------------#
# 17
#--------------------#
# Dedicated to God the Father
# All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
# getDayOfMonth.py
# https://github.com/ChristopherTopalian
#
https://github.com/ChristopherAndrewTopalia
n

#********************#
# getDayOfWeekName.py

import datetime as dt

def getDayOfWeekName():
currentDate = dt.datetime.now()

# 0 is Monday, 6 is Sunday
dayOfWeek = currentDate.weekday()

days = ["Monday", "Tuesday",


"Wednesday", "Thursday", "Friday",
"Saturday", "Sunday"]

# get name of day using day of week index


dayName = days[dayOfWeek]

return dayName
#print(getDayOfWeekName())
#input('')

#--------------------#
# Monday
#--------------------#

# Dedicated to God the Father


# All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
# getDayOfWeekName.py
# https://github.com/ChristopherTopalian
#
https://github.com/ChristopherAndrewTopalia
n

#********************#
# getDayOfWeekNumber.py

import datetime as dt

def getDayOfWeekNumber():
now = dt.datetime.now()

# sunday returns as 6
dayOfWeekNumber = now.weekday()

# adjust so that sunday returns as 0


dayOfWeekNumber = (dayOfWeekNumber
+ 1) % 7

# adjust so that sunday returns as 1


dayOfWeekNumberAdjusted =
dayOfWeekNumber + 1
return dayOfWeekNumberAdjusted

# print(getDayOfWeekNumber())
# input('')

#--------------------#
# If today is Wednesday, it returns:
#4
#--------------------#

# Dedicated to God the Father


# All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
# getDayOfWeekNumber.py
# https://github.com/ChristopherTopalian
#
https://github.com/ChristopherAndrewTopalia
n
#********************#
# getDayOfWeekNumber7.py

import datetime as dt

def getDayOfWeekNumber7():
now = dt.datetime.now()

# monday is 0, sunday is 6
dayOfWeekNumber = now.weekday()

# adjust so that monday is 1, sunday is 7


dayOfWeekNumberAdjusted =
dayOfWeekNumber + 1

return dayOfWeekNumberAdjusted

# print(getDayOfWeekNumber7())
# input('')
#--------------------#
# If today is Wednesday, it returns:
#3
#--------------------#

# Dedicated to God the Father


# All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
# getDayOfWeekNumber7.py
# https://github.com/ChristopherTopalian
#
https://github.com/ChristopherAndrewTopalia
n

#********************#
# getMonthNumber.py

import datetime as dt

def getMonthNumber():
currentDate = dt.datetime.now()

# 1 is Jan, 12 is December
month = currentDate.month

return month

# print(getMonthNumber())
# input('')

#--------------------#
#6
#--------------------#
# Dedicated to God the Father
# All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
# getMonthNumber.py
# https://github.com/ChristopherTopalian
#
https://github.com/ChristopherAndrewTopalia
n

#********************#
# getYear.py

import datetime as dt

def getYear():
today = dt.date.today()

year = today.year

return year

# print(getYear())
# input('')

#--------------------#
# 2024
#--------------------#
# Dedicated to God the Father
# All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
# getYear.py
# https://github.com/ChristopherTopalian
#
https://github.com/ChristopherAndrewTopalia
n

#********************#
# getTime12.py

import datetime as dt

def getTime12():
now = dt.datetime.now()

currentTime = now.strftime("%I:%M:%S
%p")

return currentTime

# print(getTime12())
# input('')

#--------------------#
# 05:42:06 PM
#--------------------#
# Dedicated to God the Father
# All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
# getTime12.py
# https://github.com/ChristopherTopalian
#
https://github.com/ChristopherAndrewTopalia
n

#********************#
# getTime24.py

import datetime as dt

def getTime24():
now = dt.datetime.now()

currentTime = now.strftime("%H:%M:%S")

return currentTime

# print(getTime24())
# input('')

#--------------------#
# 17:07:29
#--------------------#
# Dedicated to God the Father
# All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
# getTime24.py
# https://github.com/ChristopherTopalian
#
https://github.com/ChristopherAndrewTopalia
n

#********************#
// getDateJS.js

function getDateJS()
{
let currentDate = new Date();

let year = currentDate.getFullYear();

let month = (currentDate.getMonth() +


1).toString();

// add a zero
if (month.length < 2)
{
month = '0' + month;
}

let day = currentDate.getDate().toString();


// add a zero
if (day.length < 2)
{
day = '0' + day;
}

let date = year + '-' + month + '-' + day;

return date;
}

// console.log(getDateJS());

//--------------------//
// 2024/06/07
//--------------------//
// Dedicated to God the Father
// All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
// getDateJS.js
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n

//********************//
// getDateTimeJS.js

function getDateTimeJS()
{
let currentDate = new Date();

return currentDate.toLocaleString();
}

// console.log(getDateTimeJS());

//--------------------//
// 5/18/2024, 12:33:45 AM
//--------------------//

// Dedicated to God the Father


// All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
// getDateTimeJS.js
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n

//********************//
// getDayOfMonthJS.js

function getDayOfMonthJS()
{
let currentDate = new Date();

let day = currentDate.getDate();

return day;
}

// console.log(getDayOfMonthJS());

//--------------------//
// 12
//--------------------//

// Dedicated to God the Father


// All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
// getDayOfMonthJS.js
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n

//********************//
// getDayOfWeekNameJS.js

function getDayOfWeekNameJS()
{
let currentDate = new Date();

// 0-6
let dayNumber = currentDate.getDay();

let daysOfWeek = ["Sunday", "Monday",


"Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday"];

let dayName = daysOfWeek[dayNumber];

return dayName;
}
// console.log(getDayOfWeekNameJS());

//--------------------//
// Tuesday
//--------------------//

// Dedicated to God the Father


// All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
// getDayOfWeekNameJS.js
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n

//********************//
// getDayOfWeekNumber7JS.js

function getDayOfWeekNumber7JS()
{
let currentDate = new Date();

let dayOfWeekNumber =
currentDate.getDay();

// make sunday be 6, monday 0


dayOfWeekNumber = (dayOfWeekNumber
+ 6) % 7;

dayOfWeekNumberAdjusted =
dayOfWeekNumber + 1

return dayOfWeekNumberAdjusted;
}
// console.log(getDayOfWeekNumber7JS());

//--------------------//
// If today is Wednesday, it returns:
// 3
//--------------------//

// Dedicated to God the Father


// All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
// getDayOfWeekNumber7JS.js
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n

//********************//
// getDayOfWeekNumberJS.js

function getDayOfWeekNumberJS()
{
let currentDate = new Date();

// sunday returns as 0
let dayOfWeekNumber =
currentDate.getDay();

// adjust sunday to return as 1


dayOfWeekNumberAdjusted =
dayOfWeekNumber + 1;

return dayOfWeekNumberAdjusted;
}

// console.log(getDayOfWeekNumberJS());
//--------------------//
// If today is Wednesday, it returns:
// 4
//--------------------//

// Dedicated to God the Father


// All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
// getDayOfWeekNumberJS.js
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n

//********************//
// getMonthNumberJS.js

function getMonthNumberJS()
{
let currentDate = new Date();

monthNumber = currentDate.getMonth();

monthNumberAdjusted = monthNumber +
1;

return monthNumberAdjusted;
}

// console.log(getMonthNumberJS());

//--------------------//
// 6
//--------------------//

// Dedicated to God the Father


// All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
// getMonthNumberJS.js
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n

//********************//
// getYearJS.js

function getYearJS()
{
let currentDate = new Date();

let year = currentDate.getFullYear();

return year;
}

// console.log(getYearJS());

//--------------------//
// 2024
//--------------------//

// Dedicated to God the Father


// All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
// getYearJS.js
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n

//********************//
// getTime12JS.js

function getTime12JS()
{
let currentDate = new Date();

let hours = currentDate.getHours();


let minutes = currentDate.getMinutes();
let seconds = currentDate.getSeconds();
let amOrPm;

// am or pm
if(hours < 12)
{
amOrPm = "AM";
}
else
{
amOrPm = "PM"
}

// convert from military time


if (hours > 12)
{
hours -= 12;
}
else if (hours === 0)
{
hours = 12;
}

// add a zero
if (hours < 10)
{
hours = "0" + hours;
}
if (minutes < 10)
{
minutes = "0" + minutes;
}

if (seconds < 10)


{
seconds = "0" + seconds;
}

let time = hours + ':' + minutes + ':' +


seconds + ' ' + amOrPm;

return time;
}

// console.log(getTime12JS());
//--------------------//
// 04:57:38 AM
//--------------------//

// Dedicated to God the Father


// All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
// getTime12JS.js
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n

//********************//
// getTime24JS.js

function getTime24JS()
{
let currentDate = new Date();

let hours = currentDate.getHours();


let minutes = currentDate.getMinutes();
let seconds = currentDate.getSeconds();

// add a zero at the beginning


if (hours < 10)
{
hours = "0" + hours;
}

if (minutes < 10)


{
minutes = "0" + minutes;
}

if (seconds < 10)


{
seconds = "0" + seconds;
}

let time = hours + ':' + minutes + ':' +


seconds;

return time;
}

// console.log(getTime24JS());

//--------------------//
// 04:57:08
//--------------------//

// Dedicated to God the Father


// All Rights Reserved Christopher Andrew
Topalian Copyright 2000-2024
// getTime24JS.js
// https://github.com/ChristopherTopalian
//
https://github.com/ChristopherAndrewTopalia
n

//********************//
How to Paste Code from a PDF
that has Junk Characters.
When we paste from a pdf into VSCode,
it might look like this:

We can't leave those junk characters in the


code, so we remove them with find/replace.
We Find 1 of the spaces.
We Replace All with the 1 space that we
typed. This gets rid of the junk characters in
the code.

We highlight 1 space with our mouse arrow:


We press Control + H to open the
Find/Replace feature and Replace All with our
own Space
Here we see that the Find/Replace All
has replaced the junk characters
with our working spaces instead:

Now that the code


has no junk characters,
it can run.
True Artificial Intelligence System
16-Gon
Tautology
MI 1111 CI
1101 1011
AND XNOR
0001 1001
LP RP
0011 0101

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

You might also like