Skip to content

Commit

Permalink
Merge pull request #111 from selfiens/pr/add-js-function-doc
Browse files Browse the repository at this point in the history
  • Loading branch information
secure-77 committed Jan 10, 2024
2 parents cc79bb4 + 459313d commit eefd7ef
Showing 1 changed file with 51 additions and 9 deletions.
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

0 comments on commit eefd7ef

Please sign in to comment.