2020-03-21 21:03:29 -06:00
|
|
|
const moduleDocsPathPrefix = "/docs/modules/";
|
|
|
|
|
|
|
|
var moduleID = window.location.pathname.substr(moduleDocsPathPrefix.length);
|
|
|
|
if (moduleID) {
|
|
|
|
// update page title and load the docs for this module
|
|
|
|
document.title = "Module " + moduleID + " - Caddy Documentation";
|
|
|
|
$.get("/api/docs/module/"+moduleID, function(json) {
|
|
|
|
// wait until the DOM has finished loading before rendering the results
|
|
|
|
$(function() {
|
|
|
|
$('#module-docs-container').show();
|
|
|
|
$('h1').text("Module "+moduleID);
|
2021-05-25 17:26:35 -06:00
|
|
|
beginRendering(json.result, moduleID);
|
2020-03-21 21:03:29 -06:00
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
// populate the module list
|
2020-07-16 15:51:46 -06:00
|
|
|
$.get("/api/modules", function(json) {
|
|
|
|
var moduleList = json.result;
|
|
|
|
|
2020-03-21 21:03:29 -06:00
|
|
|
// wait until the DOM has finished loading before rendering the results
|
|
|
|
$(function() {
|
|
|
|
$('#module-list-container').show();
|
|
|
|
$table = $('#module-list');
|
|
|
|
for (modID in moduleList) {
|
2020-07-16 15:51:46 -06:00
|
|
|
var val = moduleList[modID];
|
2021-05-25 17:26:35 -06:00
|
|
|
|
|
|
|
// refine a short preview of the module's docs
|
|
|
|
let shortDoc = truncate(val.doc, 200);
|
|
|
|
if (shortDoc && shortDoc.indexOf(modID) === 0) {
|
|
|
|
shortDoc = shortDoc.substr(modID.length).trim();
|
|
|
|
}
|
|
|
|
|
2020-07-16 15:51:46 -06:00
|
|
|
var standard = isStandard(val.type_name);
|
2020-03-21 21:03:29 -06:00
|
|
|
var $tr = $('<tr/>');
|
2020-07-16 15:51:46 -06:00
|
|
|
$tr.append('<td><a href="./'+modID+'" class="module-link">'+modID+'</a>'+(standard ? '' : ' '+nonStandardFlag)+'</td>');
|
2021-05-25 17:26:35 -06:00
|
|
|
$tr.append($('<td/>').text(shortDoc));
|
2020-03-21 21:03:29 -06:00
|
|
|
$table.append($tr);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|