chronoman
Version:
Utility class to simplify use of timers created by setTimeout
1,528 lines (581 loc) • 21.3 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>chronoman Module: chronoman</title>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
<link type="text/css" rel="stylesheet" href="styles/site.spacelab.css">
</head>
<body>
<div class="navbar navbar-default navbar-fixed-top ">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="index.html">chronoman</a>
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#topNavigation">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse" id="topNavigation">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="modules.list.html" class="dropdown-toggle" data-toggle="dropdown">Modules<b class="caret"></b></a>
<ul class="dropdown-menu ">
<li><a href="module-chronoman.html">chronoman</a></li>
</ul>
</li>
<li class="dropdown">
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b class="caret"></b></a>
<ul class="dropdown-menu ">
<li><a href="module-chronoman-Timer.html">chronoman~Timer</a></li>
</ul>
</li>
</ul>
<div class="col-sm-3 col-md-3">
<form class="navbar-form" role="search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" name="q" id="search-input">
<div class="input-group-btn">
<button class="btn btn-default" id="search-submit"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="container" id="toc-content">
<div class="row">
<div class="col-md-8">
<div id="main">
<h1 class="page-title">Module: chronoman</h1>
<section>
<header>
</header>
<article>
<div class="container-overview">
<dl class="details">
<dt class="tag-author method-doc-label method-doc-details-label">Author:</dt>
<dd class="tag-author">
<ul>
<li>Denis Sikuler</li>
</ul>
</dd>
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="chronoman.js.html">chronoman.js</a>,
<a href="chronoman.js.html#sunlight-1-line-1">line 1</a>
</li>
</ul>
</dd>
</dl>
</div>
<h3 class="subsection-title">Classes</h3>
<dl>
<dt><a href="module-chronoman-Timer.html">Timer</a></dt>
<dd></dd>
</dl>
<h3 class="subsection-title">Methods</h3>
<dl>
<hr>
<dt>
<h4 class="name" id=".getRandomValue"><span class="type-signature"><static> </span>getRandomValue(start [, end] [, bInteger])</h4>
</dt>
<dd>
<div class="description">
<p>Generate random number or randomly select item from specified array.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>start</code></td>
<td class="type">
<span class="param-type">Array</span>
|
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>Array from which an item should be selected
or minimal point of interval from which random number should be generated.</p></td>
</tr>
<tr>
<td class="name"><code>end</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
start+1
</td>
<td class="description last"><p>Maximal point of interval from which random number should be generated.</p></td>
</tr>
<tr>
<td class="name"><code>bInteger</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
true
</td>
<td class="description last"><p>Whether integer number should be returned.
This parameter can be used when value of <code>start</code> parameter is a number.</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="chronoman.js.html">chronoman.js</a>,
<a href="chronoman.js.html#sunlight-1-line-29">line 29</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>Random number when <code>start</code> parameter is a number
or randomly selected item when <code>start</code> parameter is an array.</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">*</span>
</dd>
</dl>
</dd>
</dl>
<h3 class="subsection-title">Type Definitions</h3>
<dl>
<hr>
<dt>
<h4 class="name" id="~Action"><span class="type-signature"></span>Action()</h4>
</dt>
<dd>
<div class="description">
<p>Action that should be executed after time period is elapsed.</p>
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="chronoman.js.html">chronoman.js</a>,
<a href="chronoman.js.html#sunlight-1-line-98">line 98</a>
</li>
</ul>
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="~ActionObject">
<h4 id="~ActionObject">ActionObject</h4>
</dt>
<dd>
<div class="description">
<p>Object describing action that should be executed after time period is elapsed.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">Object</span>
</li>
</ul>
<dl class="details">
<h5 class="subsection-title">Properties:</h5>
<dl>
<table class="props table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>execute</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last"><p>Function that should be executed.</p></td>
</tr>
</tbody>
</table>
</dl>
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="chronoman.js.html">chronoman.js</a>,
<a href="chronoman.js.html#sunlight-1-line-80">line 80</a>
</li>
</ul>
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="~ActionSpec">
<h4 id="~ActionSpec">ActionSpec</h4>
</dt>
<dd>
<div class="description">
<p>Object describing action that should be executed after time period is elapsed.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">Object</span>
</li>
</ul>
<dl class="details">
<h5 class="subsection-title">Properties:</h5>
<dl>
<table class="props table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>context</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last"><p><code>this</code> for function's call.</p></td>
</tr>
<tr>
<td class="name"><code>func</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>Function that should be executed.</p></td>
</tr>
</tbody>
</table>
</dl>
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="chronoman.js.html">chronoman.js</a>,
<a href="chronoman.js.html#sunlight-1-line-88">line 88</a>
</li>
</ul>
</dd>
</dl>
</dd>
<hr>
<dt>
<h4 class="name" id="~GetPeriodValue"><span class="type-signature"></span>GetPeriodValue( [timer])</h4>
</dt>
<dd>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>timer</code></td>
<td class="type">
<span class="param-type"><a href="module-chronoman-Timer.html">module:chronoman~Timer</a></span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="chronoman.js.html">chronoman.js</a>,
<a href="chronoman.js.html#sunlight-1-line-50">line 50</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="module-chronoman.html#~SinglePeriodValue">module:chronoman~SinglePeriodValue</a></span>
|
<span class="param-type">Array.<<a href="module-chronoman.html#~SinglePeriodValue">module:chronoman~SinglePeriodValue</a>></span>
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="~PeriodValue">
<h4 id="~PeriodValue">PeriodValue</h4>
</dt>
<dd>
<div class="description">
<p>Value determining time period in milliseconds that is used to schedule related action execution.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type"><a href="module-chronoman.html#~SinglePeriodValue">module:chronoman~SinglePeriodValue</a></span>
|
<span class="param-type">Array.<<a href="module-chronoman.html#~SinglePeriodValue">module:chronoman~SinglePeriodValue</a>></span>
|
<span class="param-type"><a href="module-chronoman.html#~GetPeriodValue">module:chronoman~GetPeriodValue</a></span>
</li>
</ul>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="chronoman.js.html">chronoman.js</a>,
<a href="chronoman.js.html#sunlight-1-line-74">line 74</a>
</li>
</ul>
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="~RandomPeriod">
<h4 id="~RandomPeriod">RandomPeriod</h4>
</dt>
<dd>
<div class="description">
<p>Object describing properties for generating random time period.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">Object</span>
</li>
</ul>
<dl class="details">
<h5 class="subsection-title">Properties:</h5>
<dl>
<table class="props table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>end</code></td>
<td class="type">
<span class="param-type">Integer</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last"><p>Maximal point of interval from which random time period should be generated.</p></td>
</tr>
<tr>
<td class="name"><code>list</code></td>
<td class="type">
<span class="param-type">Array.<Integer></span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last"><p>Array from which a time period should be selected randomly.</p></td>
</tr>
<tr>
<td class="name"><code>start</code></td>
<td class="type">
<span class="param-type">Integer</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last"><p>Minimal point of interval from which random time period should be generated.</p></td>
</tr>
</tbody>
</table>
</dl>
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="chronoman.js.html">chronoman.js</a>,
<a href="chronoman.js.html#sunlight-1-line-56">line 56</a>
</li>
</ul>
</dd>
</dl>
</dd>
<hr>
<dt class="name" id="~SinglePeriodValue">
<h4 id="~SinglePeriodValue">SinglePeriodValue</h4>
</dt>
<dd>
<div class="description">
<p>Single value determining time period in milliseconds that is used to schedule related action execution.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">Integer</span>
|
<span class="param-type"><a href="module-chronoman.html#~RandomPeriod">module:chronoman~RandomPeriod</a></span>
</li>
</ul>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="chronoman.js.html">chronoman.js</a>,
<a href="chronoman.js.html#sunlight-1-line-68">line 68</a>
</li>
</ul>
</dd>
</dl>
</dd>
</dl>
</article>
</section>
</div>
</div>
<div class="clearfix"></div>
<div class="col-md-3">
<div id="toc" class="col-md-3 hidden-xs hidden-sm hidden-md"></div>
</div>
</div>
</div>
<div class="modal fade" id="searchResults">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Search results</h4>
</div>
<div class="modal-body"></div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
<footer>
<span class="copyright">
Copyright (c) 2013-2020 Denis Sikuler
</span>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a>
on 2020-02-13T23:27:10+03:00
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
</footer>
<script src="scripts/docstrap.lib.js"></script>
<script src="scripts/toc.js"></script>
<script type="text/javascript" src="scripts/fulltext-search-ui.js"></script>
<script>
$( function () {
$( "[id*='$']" ).each( function () {
var $this = $( this );
$this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) );
} );
$( ".tutorial-section pre, .readme-section pre, pre.prettyprint.source" ).each( function () {
var $this = $( this );
var example = $this.find( "code" );
exampleText = example.html();
var lang = /{@lang (.*?)}/.exec( exampleText );
if ( lang && lang[1] ) {
exampleText = exampleText.replace( lang[0], "" );
example.html( exampleText );
lang = lang[1];
} else {
var langClassMatch = example.parent()[0].className.match(/lang\-(\S+)/);
lang = langClassMatch ? langClassMatch[1] : "javascript";
}
if ( lang ) {
$this
.addClass( "sunlight-highlight-" + lang )
.addClass( "linenums" )
.html( example.html() );
}
} );
Sunlight.highlightAll( {
lineNumbers : true,
showMenu : true,
enableDoclinks : true
} );
$.catchAnchorLinks( {
navbarOffset: 10
} );
$( "#toc" ).toc( {
anchorName : function ( i, heading, prefix ) {
return $( heading ).attr( "id" ) || ( prefix + i );
},
selectors : "#toc-content h1,#toc-content h2,#toc-content h3,#toc-content h4",
showAndHide : false,
smoothScrolling: true
} );
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
$( '.dropdown-toggle' ).dropdown();
$( "table" ).each( function () {
var $this = $( this );
$this.addClass('table');
} );
} );
</script>
<!--Navigation and Symbol Display-->
<!--Google Analytics-->
<script type="text/javascript">
$(document).ready(function() {
SearcherDisplay.init();
});
</script>
</body>
</html>