Content Manager: Added Documentation, Implemented functional approach to the HTML table generation and refactored API codes, Using DOM purifier to prevent XSS
This commit is contained in:
90
src-manager/docs/manager/1.0.0/utils_tableWrapper.js.html
Normal file
90
src-manager/docs/manager/1.0.0/utils_tableWrapper.js.html
Normal file
@@ -0,0 +1,90 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>JSDoc: Source: utils/tableWrapper.js</title>
|
||||
|
||||
<script src="scripts/prettify/prettify.js"> </script>
|
||||
<script src="scripts/prettify/lang-css.js"> </script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<h1 class="page-title">Source: utils/tableWrapper.js</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>/**
|
||||
* @module utils/tableWrapper
|
||||
*/
|
||||
|
||||
/**
|
||||
* Wrap object array into HTML table body tr+td's
|
||||
* @param {Object[]} target - array of objects
|
||||
* @returns {string} Stringed HTML table body tr+td's
|
||||
* @example
|
||||
* const data = [
|
||||
* {id: 1, name: "John"},
|
||||
* {id: 2, name: "Marry"},
|
||||
* ];
|
||||
* const responseHTML = wrapInTable(data);
|
||||
* // responseHTML =
|
||||
* // <tr>
|
||||
* // <td>1</td>
|
||||
* // <td>John</td>
|
||||
* // </tr>
|
||||
* // <tr>
|
||||
* // <td>2</td>
|
||||
* // <td>Marry</td>
|
||||
* // </tr>
|
||||
*/
|
||||
const wrapInTable = (target) => {
|
||||
let res = "";
|
||||
for (const entry of target) {
|
||||
let tableData = "<tr>\n";
|
||||
for (const data in entry) {
|
||||
let dataEntry = ` <td>${entry[data]}</td>\n`
|
||||
tableData = tableData + dataEntry;
|
||||
}
|
||||
tableData = tableData + "</tr>\n";
|
||||
res = res + tableData;
|
||||
}
|
||||
return res;
|
||||
};
|
||||
|
||||
export { wrapInTable };
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-api_gallery-image.html">api/gallery-image</a></li><li><a href="module-api_news.html">api/news</a></li><li><a href="module-utils_asyncDatabase.html">utils/asyncDatabase</a></li><li><a href="module-utils_tableWrapper.html">utils/tableWrapper</a></li></ul>
|
||||
</nav>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.4</a> on Tue Nov 26 2024 23:18:12 GMT+0900 (日本標準時)
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
<script src="scripts/linenumber.js"> </script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user