Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JS Docs to functions #111

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 51 additions & 9 deletions perlite/.js/perlite.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,23 @@ if ($('#showTOC').data('option') == true && localStorage.getItem("showTOC") ===
}


// scroll to anchor
/**
* scroll to anchor
* @param {String} aid
*/
function scrollToAnchor(aid) {
var aTag = $("a[name='" + aid + "']");
$('html,body,div').animate({ scrollTop: aTag.offset().top }, 'slow');
}


// get markdown content
/**
* get markdown content
* @param {String} str
* @param {Boolean} home
* @param {Boolean} popHover
* @param {String} anchor
*/
function getContent(str, home = false, popHover = false, anchor = "") {

// reset content if request is empty
Expand Down Expand Up @@ -379,7 +388,12 @@ function getContent(str, home = false, popHover = false, anchor = "") {
}
};

// vis js stuff
/**
* vis js stuff
* @param {Boolean} modal
* @param {String} path
* @param {Boolean} filter_emptyNodes
*/
function renderGraph(modal, path = "", filter_emptyNodes = false) {

// no graph found exit
Expand Down Expand Up @@ -665,7 +679,9 @@ function renderGraph(modal, path = "", filter_emptyNodes = false) {

};

// change mobile settings
/**
* change mobile settings
*/
function isMobile() {

if ($(window).width() < 990) {
Expand Down Expand Up @@ -707,7 +723,10 @@ function hideLeftMobile() {

};

// search
/**
* search
* @param {String} str
*/
function search(str) {
if (str.length == 0) {
$("div.search-results-children").html("");
Expand All @@ -730,20 +749,32 @@ function search(str) {
};

// edit button

/**
* @param {String} name
* @returns {string}
*/
function getCookie(name) {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) return parts.pop().split(';').shift();
};

// helper
/**
* helper
* @param {String} oldClass
* @param {String} newClass
*/
function replaceClass(oldClass, newClass) {
var elem = $("." + oldClass);
elem.removeClass(oldClass);
elem.addClass(newClass);
};

// search entry
/**
* search entry
* @param {Event} e
*/
function toggleSearchEntry(e) {

el = $(e.target);
Expand All @@ -768,7 +799,10 @@ function toggleSearchEntry(e) {

};

// nav menu collapse functions
/**
* nav menu collapse functions
* @param {Event} e
*/
function toggleNavFolder(e) {
el = $(e.target);

Expand Down Expand Up @@ -808,6 +842,11 @@ function toggleNavFolder(e) {
return
};

/**
*
* @param {String} target
* @param {Boolean} openAll
*/
function openNavMenu(target, openAll = false) {

// open nav menu to target
Expand Down Expand Up @@ -1619,7 +1658,10 @@ $(document).ready(function () {

});

// close modal
/**
* close modal
* @param {String[]} elementIds
*/
function hideElements(elementIds) {
elementIds.forEach(function (id) {
$("#" + id).css("display", "none");
Expand Down