gs-mobile-cordova-plugin-jslib
Version:
GS Mobile JSLib
1,990 lines (490 loc) • 20.5 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: Utility</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">Class: Utility</h1>
<section>
<header>
<h2><span class="attribs"><span class="type-signature"></span></span>Utility<span class="signature">()</span><span class="type-signature"></span></h2>
</header>
<article>
<div class="container-overview">
<h4 class="name" id="Utility"><span class="type-signature"></span>new Utility<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
phone, etc.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="gs_mobile_jslib.js.html">gs_mobile_jslib.js</a>, <a href="gs_mobile_jslib.js.html#line36">line 36</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="formatNumber"><span class="type-signature"></span>formatNumber<span class="signature">(number, point)</span><span class="type-signature"> → {<a href="String.html">String</a>}</span></h4>
<p class="summary">格式化數字補千分位,固定小數n位</p>
<div class="description">
formatNumber(1234.123, 2)
</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>number</code></td>
<td class="type">
<span class="param-type"><a href="String.html">String</a></span>
</td>
<td class="description last">傳入值</td>
</tr>
<tr>
<td class="name"><code>point</code></td>
<td class="type">
<span class="param-type"><a href="String.html">String</a></span>
</td>
<td class="description last">固定小數n位</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="gs_mobile_jslib.js.html">gs_mobile_jslib.js</a>, <a href="gs_mobile_jslib.js.html#line105">line 105</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
num 1,234.12
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="String.html">String</a></span>
</dd>
</dl>
<h4 class="name" id="getCurrentDate"><span class="type-signature"></span>getCurrentDate<span class="signature">()</span><span class="type-signature"> → {<a href="String.html">String</a>}</span></h4>
<p class="summary">取得當下民國日期</p>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="gs_mobile_jslib.js.html">gs_mobile_jslib.js</a>, <a href="gs_mobile_jslib.js.html#line167">line 167</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
109年01月02日
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="String.html">String</a></span>
</dd>
</dl>
<h4 class="name" id="getCurrentDateDiff"><span class="type-signature"></span>getCurrentDateDiff<span class="signature">(diff)</span><span class="type-signature"> → {<a href="String.html">String</a>}</span></h4>
<p class="summary">取得當下日期減天數</p>
<div class="description">
getCurrentDateDiff(2) 假設當下是2020/01/03
</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>diff</code></td>
<td class="type">
<span class="param-type"><a href="String.html">String</a></span>
</td>
<td class="description last">欲減掉的天數</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="gs_mobile_jslib.js.html">gs_mobile_jslib.js</a>, <a href="gs_mobile_jslib.js.html#line185">line 185</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
傳回就是2020/01/01
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="String.html">String</a></span>
</dd>
</dl>
<h4 class="name" id="getCurrentTime"><span class="type-signature"></span>getCurrentTime<span class="signature">()</span><span class="type-signature"> → {<a href="String.html">String</a>}</span></h4>
<p class="summary">取得當下時間(時跟分)</p>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="gs_mobile_jslib.js.html">gs_mobile_jslib.js</a>, <a href="gs_mobile_jslib.js.html#line200">line 200</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
18時10分
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="String.html">String</a></span>
</dd>
</dl>
<h4 class="name" id="getInfo"><span class="type-signature"></span>getInfo<span class="signature">(successCallback, errorCallback)</span><span class="type-signature"></span></h4>
<div class="description">
取得行動裝置資訊
</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>successCallback</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">The function to call when the heading data is available</td>
</tr>
<tr>
<td class="name"><code>errorCallback</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">The function to call when there is an error getting the heading data. (OPTIONAL)</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="gs_mobile_jslib.js.html">gs_mobile_jslib.js</a>, <a href="gs_mobile_jslib.js.html#line78">line 78</a>
</li></ul></dd>
</dl>
<h4 class="name" id="getLastMonthCurrentDate"><span class="type-signature"></span>getLastMonthCurrentDate<span class="signature">(num)</span><span class="type-signature"> → {<a href="String.html">String</a>}</span></h4>
<p class="summary">取得N個月前的當天</p>
<div class="description">
假設當天是109/01/02
</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>num</code></td>
<td class="type">
<span class="param-type"><a href="String.html">String</a></span>
</td>
<td class="description last">往前n個月</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="gs_mobile_jslib.js.html">gs_mobile_jslib.js</a>, <a href="gs_mobile_jslib.js.html#line216">line 216</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
回傳108/12/02
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="String.html">String</a></span>
</dd>
</dl>
<h4 class="name" id="getNextMonthCurrentDate"><span class="type-signature"></span>getNextMonthCurrentDate<span class="signature">(num)</span><span class="type-signature"> → {<a href="String.html">String</a>}</span></h4>
<p class="summary">取得N個月後的當天</p>
<div class="description">
假設當天是109/01/02
</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>num</code></td>
<td class="type">
<span class="param-type"><a href="String.html">String</a></span>
</td>
<td class="description last">往後n個月</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="gs_mobile_jslib.js.html">gs_mobile_jslib.js</a>, <a href="gs_mobile_jslib.js.html#line228">line 228</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
回傳109/02/02
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="String.html">String</a></span>
</dd>
</dl>
<h4 class="name" id="getParameterByName"><span class="type-signature"></span>getParameterByName<span class="signature">(name, num)</span><span class="type-signature"> → {<a href="String.html">String</a>}</span></h4>
<p class="summary">取得網址參數的值</p>
<div class="description">
假設網址(url)是https://a.b.c/xxx.aspx?x=val1&y=val2, getParameterByName(y,url)
</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>name</code></td>
<td class="type">
<span class="param-type"><a href="String.html">String</a></span>
</td>
<td class="description last">欲取得的參數名稱</td>
</tr>
<tr>
<td class="name"><code>num</code></td>
<td class="type">
<span class="param-type"><a href="String.html">String</a></span>
</td>
<td class="description last">完整的網址</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="gs_mobile_jslib.js.html">gs_mobile_jslib.js</a>, <a href="gs_mobile_jslib.js.html#line241">line 241</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
回傳y的值是val2
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="String.html">String</a></span>
</dd>
</dl>
<h4 class="name" id="leftPad"><span class="type-signature"></span>leftPad<span class="signature">(value, length)</span><span class="type-signature"> → {<a href="String.html">String</a>}</span></h4>
<p class="summary">固定n位數, 不足補0</p>
<div class="description">
leftPad(1,3)
</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>value</code></td>
<td class="type">
<span class="param-type">int</span>
</td>
<td class="description last">傳入值</td>
</tr>
<tr>
<td class="name"><code>length</code></td>
<td class="type">
<span class="param-type">int</span>
</td>
<td class="description last">n位數</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="gs_mobile_jslib.js.html">gs_mobile_jslib.js</a>, <a href="gs_mobile_jslib.js.html#line90">line 90</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
str 001
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="String.html">String</a></span>
</dd>
</dl>
<h4 class="name" id="twd97_to_latlng"><span class="type-signature"></span>twd97_to_latlng<span class="signature">($x, $y)</span><span class="type-signature"> → {array}</span></h4>
<p class="summary">TWD97轉WGS84</p>
<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>$x</code></td>
<td class="type">
<span class="param-type">float</span>
</td>
<td class="description last">TWD97 x坐標</td>
</tr>
<tr>
<td class="name"><code>$y</code></td>
<td class="type">
<span class="param-type">float</span>
</td>
<td class="description last">TWD97 y坐標</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="gs_mobile_jslib.js.html">gs_mobile_jslib.js</a>, <a href="gs_mobile_jslib.js.html#line259">line 259</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
回傳WGS84坐標陣列
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">array</span>
</dd>
</dl>
<h4 class="name" id="yyy2yyyy"><span class="type-signature"></span>yyy2yyyy<span class="signature">()</span><span class="type-signature"> → {<a href="String.html">String</a>}</span></h4>
<p class="summary">民國年轉西元年</p>
<div class="description">
yyyy2yyy('107年01月02日')
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="gs_mobile_jslib.js.html">gs_mobile_jslib.js</a>, <a href="gs_mobile_jslib.js.html#line149">line 149</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
2020年01月02日
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="String.html">String</a></span>
</dd>
</dl>
<h4 class="name" id="yyyy2yyy"><span class="type-signature"></span>yyyy2yyy<span class="signature">()</span><span class="type-signature"> → {<a href="String.html">String</a>}</span></h4>
<p class="summary">西元年轉民國年</p>
<div class="description">
yyyy2yyy('2020年01月02日')
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="gs_mobile_jslib.js.html">gs_mobile_jslib.js</a>, <a href="gs_mobile_jslib.js.html#line131">line 131</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
109年01月02日
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="String.html">String</a></span>
</dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Utility.html">Utility</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.3</a> on Wed Mar 25 2020 17:38:38 GMT+0800 (Taipei Standard Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>