commit 5db65d64fd8be435909c3adcb4f78629a4a9a98a
parent 071e7482c313931bdcf884f5f3574777da484400
Author: AsherMorgan <59518073+AsherMorgan@users.noreply.github.com>
Date: Thu, 10 Sep 2020 13:01:54 -0700
Improve documentation in JS code.
Diffstat:
4 files changed, 54 insertions(+), 12 deletions(-)
diff --git a/Songs2Slides/static/error.js b/Songs2Slides/static/error.js
@@ -1,4 +1,7 @@
-// Finishes setting up the page
+/**
+ * Finishes setting up the page
+ * @returns {void}
+ */
function onLoad() {
// Set theme
UpdateTheme();
diff --git a/Songs2Slides/static/global.js b/Songs2Slides/static/global.js
@@ -1,4 +1,8 @@
-// Updates the interface theme
+/**
+ * Updates the interface theme
+ * @param {bool} theme - False for light mode, true for dark mode
+ * @returns {void}
+ */
function UpdateTheme(theme = null) {
// Get theme from localStorage
if (theme === null) {
diff --git a/Songs2Slides/static/home.js b/Songs2Slides/static/home.js
@@ -3,7 +3,10 @@ setId = 0; // Next valid song id number
-// Finishes setting up the page
+/**
+ * Finishes setting up the page
+ * @returns {void}
+ */
function onLoad() {
// Add song
AddSong();
@@ -14,7 +17,10 @@ function onLoad() {
-// Adds a song
+/**
+ * Adds a blank song to the songs div
+ * @returns {void}
+ */
function AddSong() {
// Create row
let clone = document.getElementById("songTemplate").content.cloneNode(true);
@@ -34,7 +40,10 @@ function AddSong() {
-// Gets the list of songs
+/**
+ * Gets the list of songs in the songs div
+ * @returns {list} - List of songs information
+ */
function getSongs() {
// Get song info
let titles = [];
@@ -58,7 +67,10 @@ function getSongs() {
-// Get the parsed lyrics for the user to review
+/**
+ * Gets the parsed lyrics for the user to review
+ * @returns {void}
+ */
async function ReviewLyrics() {
// Show and hide elements
document.getElementById("rawLyrics").value = "Loading lyrics...";
@@ -98,7 +110,10 @@ async function ReviewLyrics() {
-// Gets the powerpoint by submitting lyrics
+/**
+ * Prepares the lyrics form to be submitted and shows the thankyou screen
+ * @returns {void}
+ */
async function SubmitLyrics() {
// Get lyrics
let lyrics = document.getElementById("rawLyrics").value.split(/\n\s*\n/);
@@ -114,7 +129,10 @@ async function SubmitLyrics() {
-// Makes the previous div visible
+/**
+ * Makes the previous screen visible
+ * @returns {void}
+ */
function Back() {
if (document.getElementById("lyricsContainer").hidden == false) {
document.getElementById("songsContainer").hidden = false;
@@ -130,7 +148,10 @@ function Back() {
-// Makes the songs div visible and removes songs
+/**
+ * Clears the list of songs and makes the songs screen visible
+ * @returns {void}
+ */
function Reset() {
// Remove songs
let songs = document.getElementsByClassName("song");
diff --git a/Songs2Slides/static/settings.js b/Songs2Slides/static/settings.js
@@ -1,4 +1,7 @@
-// Finishes setting up the page
+/**
+ * Finishes setting up the page
+ * @returns {void}
+ */
function onLoad() {
// Load settings
if (localStorage.getItem("settings") == null) {
@@ -12,6 +15,11 @@ function onLoad() {
// Loads settings
+/**
+ * Loads settings
+ * @param {object} settings - The settings object
+ * @returns {void}
+ */
function loadSettings(settings) {
// Interface settings (not stored with other settings)
UpdateTheme();
@@ -54,7 +62,10 @@ function loadSettings(settings) {
-// Saves settings to local storage
+/**
+ * Saves settings to localStorage
+ * @returns {void}
+ */
function saveSettings() {
// Save interface settings and update interface
UpdateTheme(document.getElementById("theme").value);
@@ -97,7 +108,10 @@ function saveSettings() {
-// Resets all settings to their default values
+/**
+ * Resets all settings to their default values
+ * @returns {void}
+ */
async function resetSettings() {
// Send POST request
const rawResponse = await fetch("/settings.json", {