Files
rappaurio-sae501_502/app/node_modules/wikiapi/docs/global.html
T
2023-09-25 13:27:24 +02:00

1513 lines
20 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Global - Documentation</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.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
<script src="scripts/nav.js" defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav >
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Wikiapi.html">Wikiapi</a><ul class='methods'><li data-type='method'><a href="Wikiapi.html#category_tree">category_tree</a></li><li data-type='method'><a href="Wikiapi.html#convert_Chinese">convert_Chinese</a></li><li data-type='method'><a href="Wikiapi.html#data">data</a></li><li data-type='method'><a href="Wikiapi.html#delete">delete</a></li><li data-type='method'><a href="Wikiapi.html#download">download</a></li><li data-type='method'><a href="Wikiapi.html#edit">edit</a></li><li data-type='method'><a href="Wikiapi.html#edit_page">edit_page</a></li><li data-type='method'><a href="Wikiapi.html#for_each_page">for_each_page</a></li><li data-type='method'><a href="Wikiapi.html#get_featured_content">get_featured_content</a></li><li data-type='method'><a href="Wikiapi.html#listen">listen</a></li><li data-type='method'><a href="Wikiapi.html#login">login</a></li><li data-type='method'><a href="Wikiapi.html#move_page">move_page</a></li><li data-type='method'><a href="Wikiapi.html#move_to">move_to</a></li><li data-type='method'><a href="Wikiapi.html#new_data_entity">new_data_entity</a></li><li data-type='method'><a href="Wikiapi.html#page">page</a></li><li data-type='method'><a href="Wikiapi.html#purge">purge</a></li><li data-type='method'><a href="Wikiapi.html#query">query</a></li><li data-type='method'><a href="Wikiapi.html#redirects_here">redirects_here</a></li><li data-type='method'><a href="Wikiapi.html#redirects_root">redirects_root</a></li><li data-type='method'><a href="Wikiapi.html#register_redirects">register_redirects</a></li><li data-type='method'><a href="Wikiapi.html#search">search</a></li><li data-type='method'><a href="Wikiapi.html#site_name">site_name</a></li><li data-type='method'><a href="Wikiapi.html#SPARQL">SPARQL</a></li><li data-type='method'><a href="Wikiapi.html#tracking_revisions">tracking_revisions</a></li><li data-type='method'><a href="Wikiapi.html#upload">upload</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#CeL">CeL</a></li><li><a href="global.html#KEY_SESSION">KEY_SESSION</a></li><li><a href="global.html#KEY_wiki_session">KEY_wiki_session</a></li><li><a href="global.html#modify_data_entity">modify_data_entity</a></li><li><a href="global.html#page_data_attributes">page_data_attributes</a></li><li><a href="global.html#reject_edit_error">reject_edit_error</a></li><li><a href="global.html#set_page_data_attributes">set_page_data_attributes</a></li><li><a href="global.html#setup_data_entity">setup_data_entity</a></li><li><a href="global.html#setup_wiki_session">setup_wiki_session</a></li><li><a href="global.html#wiki_API">wiki_API</a></li><li><a href="global.html#Wikiapi_list">Wikiapi_list</a></li></ul>
</nav>
<div id="main">
<h1 class="page-title">Global</h1>
<section>
<header>
<h2>
</h2>
</header>
<article>
<div class="container-overview">
<dl class="details">
</dl>
</div>
<h3 class="subsection-title">Members</h3>
<h4 class="name" id="CeL"><span class="type-signature"></span>CeL<span class="type-signature"> :function</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line17">line 17</a>
</li></ul></dd>
<dt class="tag-see">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="https://github.com/kanasimi/CeJS">https://github.com/kanasimi/CeJS</a></li>
</ul>
</dd>
</dl>
<div class="description usertext">
CeJS controller
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">function</span>
</li>
</ul>
<h4 class="name" id="KEY_SESSION"><span class="type-signature">(constant) </span>KEY_SESSION<span class="type-signature"> :Symbol</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line66">line 66</a>
</li></ul></dd>
</dl>
<div class="description usertext">
key to get <a href="global.html#wiki_API">wiki_API</a> operator when using <a href="global.html#wiki_API">wiki_API</a>.
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">Symbol</span>
</li>
</ul>
<h4 class="name" id="KEY_wiki_session"><span class="type-signature">(constant) </span>KEY_wiki_session<span class="type-signature"> :Symbol</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line79">line 79</a>
</li></ul></dd>
</dl>
<div class="description usertext">
key to get <a href="global.html#wiki_API">wiki_API</a> operator inside <a href="Wikiapi.html">Wikiapi</a>.
<code>this[KEY_wiki_session]</code> inside module code will get <a href="global.html#wiki_API">wiki_API</a> operator.
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">Symbol</span>
</li>
</ul>
<h4 class="name" id="page_data_attributes"><span class="type-signature">(constant) </span>page_data_attributes<span class="type-signature"> :Object</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line186">line 186</a>
</li></ul></dd>
</dl>
<div class="description usertext">
attributes of {Object} page_data, will setup by <a href="global.html#set_page_data_attributes">set_page_data_attributes</a>.
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">Object</span>
</li>
</ul>
<h4 class="name" id="wiki_API"><span class="type-signature">(constant) </span>wiki_API<span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line58">line 58</a>
</li></ul></dd>
</dl>
<div class="description usertext">
syntactic sugar for CeJS MediaWiki module. CeL.net.wiki === CeL.wiki
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="modify_data_entity"><span class="type-signature"></span>modify_data_entity<span class="signature">(data_entity, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line751">line 751</a>
</li></ul></dd>
</dl>
<div class="description usertext">
Modify data entity
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>data_entity</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
</td>
<td class="description last">wiki_API data entity</td>
</tr>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">options to run this function</td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
Promise object represents {Object} result data entity
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id="reject_edit_error"><span class="type-signature"></span>reject_edit_error<span class="signature">(reject, error, result<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Boolean}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line383">line 383</a>
</li></ul></dd>
</dl>
<div class="description usertext">
Handle the result of MediaWiki API when executing edit operation.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>reject</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="attributes">
</td>
<td class="description last">reject function</td>
</tr>
<tr>
<td class="name"><code>error</code></td>
<td class="type">
<span class="param-type">any</span>
</td>
<td class="attributes">
</td>
<td class="description last">error object / message</td>
</tr>
<tr>
<td class="name"><code>result</code></td>
<td class="type">
<span class="param-type">any</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">result of MediaWiki API</td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
Return <code>true</code> if the edit operation failed.
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Boolean</span>
</dd>
</dl>
<h4 class="name" id="set_page_data_attributes"><span class="type-signature"></span>set_page_data_attributes<span class="signature">(page_data, wiki)</span><span class="type-signature"> &rarr; {Promise}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line239">line 239</a>
</li></ul></dd>
</dl>
<div class="description usertext">
Bind <a href="global.html#page_data_attributes">page_data_attributes</a> to <code>page_data</code>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>page_data</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">page data</td>
</tr>
<tr>
<td class="name"><code>wiki</code></td>
<td class="type">
<span class="param-type"><a href="global.html#wiki_API">wiki_API</a></span>
</td>
<td class="description last">wiki_API session</td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
Promise object represents {Object} page's data
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id="setup_data_entity"><span class="type-signature"></span>setup_data_entity<span class="signature">(data_entity)</span><span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line728">line 728</a>
</li></ul></dd>
</dl>
<div class="description usertext">
Bind properties to <a href="global.html#wiki_API">wiki_API</a> data entity.
設定 wikidata entity object,讓我們能直接操作 entity.modify(),並且避免洩露 wiki_API session。
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>data_entity</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">wiki_API data entity</td>
</tr>
</tbody>
</table>
<h4 class="name" id="setup_wiki_session"><span class="type-signature"></span>setup_wiki_session<span class="signature">(wiki_session)</span><span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line106">line 106</a>
</li></ul></dd>
</dl>
<div class="description usertext">
Bind <a href="global.html#wiki_API">wiki_API</a> instance to <a href="Wikiapi.html">Wikiapi</a> instance
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>wiki_session</code></td>
<td class="type">
<span class="param-type"><a href="global.html#wiki_API">wiki_API</a></span>
</td>
<td class="description last">wiki_API session</td>
</tr>
</tbody>
</table>
<h4 class="name" id="Wikiapi_list"><span class="type-signature"></span>Wikiapi_list<span class="signature">()</span><span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1009">line 1009</a>
</li></ul></dd>
</dl>
<h5>Examples</h5>
<p class="code-caption">get list of [[w:en:Category:Chemical_elements]]</p>
<pre class="prettyprint"><code>// &lt;code>
const wiki = new Wikiapi;
let list = await wiki.categorymembers('Chemical elements');
console.log(list);
// Working on multiple pages
await wiki.for_each_page(
// {Array} title liat / page data list
list,
page_data => {
// ...
});
// &lt;/code></code></pre>
<p class="code-caption">get pages transcluding {{w:en:Periodic table}}</p>
<pre class="prettyprint"><code>// &lt;code>
const wiki = new Wikiapi;
let list = await wiki.embeddedin('Template:Periodic table');
console.log(list);
// &lt;/code></code></pre>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Tue Sep 20 2022 04:45:46 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/polyfill.js"></script>
<script src="scripts/linenumber.js"></script>
</body>
</html>