| 1 |
<!DOCTYPE html> |
| 2 |
|
| 3 |
<html lang="en"> |
| 4 |
<head> |
| 5 |
<meta charset="utf-8"> |
| 6 |
<meta name="viewport" content="width=device-width"> |
| 7 |
<title>weekstart Source: main.js</title> |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css"> |
| 13 |
|
| 14 |
<link type="text/css" rel="stylesheet" href="styles/site.spacelab.css"> |
| 15 |
|
| 16 |
</head> |
| 17 |
|
| 18 |
<body> |
| 19 |
|
| 20 |
<div class="navbar navbar-default navbar-fixed-top "> |
| 21 |
<div class="container"> |
| 22 |
<div class="navbar-header"> |
| 23 |
<a class="navbar-brand" href="index.html">weekstart</a> |
| 24 |
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#topNavigation"> |
| 25 |
<span class="icon-bar"></span> |
| 26 |
<span class="icon-bar"></span> |
| 27 |
<span class="icon-bar"></span> |
| 28 |
</button> |
| 29 |
</div> |
| 30 |
<div class="navbar-collapse collapse" id="topNavigation"> |
| 31 |
<ul class="nav navbar-nav"> |
| 32 |
|
| 33 |
<li class="dropdown"> |
| 34 |
<a href="modules.list.html" class="dropdown-toggle" data-toggle="dropdown">Modules<b class="caret"></b></a> |
| 35 |
<ul class="dropdown-menu "> |
| 36 |
<li><a href="module-api.html">api</a></li><li><a href="module-full.html">full</a></li><li><a href="module-fullLangRegionMap.html">fullLangRegionMap</a></li><li><a href="module-langRegionMap.html">langRegionMap</a></li><li><a href="module-main.html">main</a></li><li><a href="module-regionDayMap.html">regionDayMap</a></li> |
| 37 |
</ul> |
| 38 |
</li> |
| 39 |
|
| 40 |
</ul> |
| 41 |
|
| 42 |
<div class="col-sm-3 col-md-3"> |
| 43 |
<form class="navbar-form" role="search"> |
| 44 |
<div class="input-group"> |
| 45 |
<input type="text" class="form-control" placeholder="Search" name="q" id="search-input"> |
| 46 |
<div class="input-group-btn"> |
| 47 |
<button class="btn btn-default" id="search-submit"><i class="glyphicon glyphicon-search"></i></button> |
| 48 |
</div> |
| 49 |
</div> |
| 50 |
</form> |
| 51 |
</div> |
| 52 |
|
| 53 |
</div> |
| 54 |
|
| 55 |
</div> |
| 56 |
</div> |
| 57 |
|
| 58 |
|
| 59 |
<div class="container" id="toc-content"> |
| 60 |
<div class="row"> |
| 61 |
|
| 62 |
|
| 63 |
<div class="col-md-12"> |
| 64 |
|
| 65 |
<div id="main"> |
| 66 |
|
| 67 |
|
| 68 |
<h1 class="page-title">Source: main.js</h1> |
| 69 |
|
| 70 |
<section> |
| 71 |
<article> |
| 72 |
<pre |
| 73 |
class="sunlight-highlight-javascript linenums">/* |
| 74 |
* weekstart |
| 75 |
* https://github.com/gamtiq/weekstart |
| 76 |
*/ |
| 77 |
|
| 78 |
/** |
| 79 |
* Library to get first day of week. |
| 80 |
* |
| 81 |
* Uses data from {@link module:langRegionMap langRegionMap.js} and |
| 82 |
* {@link module:regionDayMap regionDayMap.js}. |
| 83 |
* |
| 84 |
* @module main |
| 85 |
*/ |
| 86 |
|
| 87 |
import * as api from './api'; |
| 88 |
import langRegionMap from './langRegionMap'; |
| 89 |
import regionDayMap from './regionDayMap'; |
| 90 |
|
| 91 |
/** |
| 92 |
* Return first day of week for country/region code. |
| 93 |
* |
| 94 |
* Based on data from: |
| 95 |
* - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html) |
| 96 |
* - [https://www.iso.org/iso-3166-country-codes.html](https://www.iso.org/iso-3166-country-codes.html) |
| 97 |
* |
| 98 |
* @example |
| 99 |
* getWeekStartByRegion('PNG'); // 1 |
| 100 |
* getWeekStartByRegion('qa'); // 6 |
| 101 |
* getWeekStartByRegion(462); // 5 |
| 102 |
* |
| 103 |
* @param {number | string} regionCode |
| 104 |
* ISO 3166 Alpha-2, Alpha-3 or numeric code. |
| 105 |
* @return {number} |
| 106 |
* Code of first day of week for the given country/region code: |
| 107 |
* 0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday. |
| 108 |
* @alias module:main.getWeekStartByRegion |
| 109 |
* @see module:api.getWeekStartByRegion |
| 110 |
*/ |
| 111 |
export function getWeekStartByRegion(regionCode) { |
| 112 |
return api.getWeekStartByRegion(regionCode, regionDayMap); |
| 113 |
} |
| 114 |
|
| 115 |
/** |
| 116 |
* Return first day of week for locale identifier. |
| 117 |
* |
| 118 |
* Based on data from: |
| 119 |
* - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_language_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_language_information.html) |
| 120 |
* - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/language_territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/language_territory_information.html) |
| 121 |
* - [https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html](https://unicode-org.github.io/cldr-staging/charts/latest/supplemental/territory_information.html) |
| 122 |
* - [http://www.unicode.org/reports/tr35/tr35.html#Unicode_Language_and_Locale_Identifiers](http://www.unicode.org/reports/tr35/tr35.html#Unicode_Language_and_Locale_Identifiers) |
| 123 |
* |
| 124 |
* @example |
| 125 |
* getWeekStartByLocale('no'); // 1 |
| 126 |
* getWeekStartByLocale('Pa_Guru'); // 0 |
| 127 |
* getWeekStartByLocale('fr-DZ'); // 6 |
| 128 |
* |
| 129 |
* @param {string} locale |
| 130 |
* Locale identifier. |
| 131 |
* @return {number} |
| 132 |
* Code of first day of week for the given locale identifier: |
| 133 |
* 0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday. |
| 134 |
* @alias module:main.getWeekStartByLocale |
| 135 |
* @see module:api.getWeekStartByLocale |
| 136 |
*/ |
| 137 |
export function getWeekStartByLocale(locale) { |
| 138 |
return api.getWeekStartByLocale(locale, langRegionMap, regionDayMap); |
| 139 |
} |
| 140 |
</pre> |
| 141 |
</article> |
| 142 |
</section> |
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
</div> |
| 149 |
</div> |
| 150 |
|
| 151 |
<div class="clearfix"></div> |
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
</div> |
| 156 |
</div> |
| 157 |
|
| 158 |
|
| 159 |
<div class="modal fade" id="searchResults"> |
| 160 |
<div class="modal-dialog"> |
| 161 |
<div class="modal-content"> |
| 162 |
<div class="modal-header"> |
| 163 |
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> |
| 164 |
<h4 class="modal-title">Search results</h4> |
| 165 |
</div> |
| 166 |
<div class="modal-body"></div> |
| 167 |
<div class="modal-footer"> |
| 168 |
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button> |
| 169 |
</div> |
| 170 |
</div> |
| 171 |
</div> |
| 172 |
</div> |
| 173 |
|
| 174 |
|
| 175 |
<footer> |
| 176 |
|
| 177 |
|
| 178 |
<span class="copyright"> |
| 179 |
Copyright (c) 2017-present Denis Sikuler |
| 180 |
</span> |
| 181 |
|
| 182 |
<span class="jsdoc-message"> |
| 183 |
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a> |
| 184 |
|
| 185 |
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>. |
| 186 |
</span> |
| 187 |
</footer> |
| 188 |
|
| 189 |
<script src="scripts/docstrap.lib.js"></script> |
| 190 |
<script src="scripts/toc.js"></script> |
| 191 |
|
| 192 |
<script type="text/javascript" src="scripts/fulltext-search-ui.js"></script> |
| 193 |
|
| 194 |
|
| 195 |
<script> |
| 196 |
$( function () { |
| 197 |
$( "[id*='$']" ).each( function () { |
| 198 |
var $this = $( this ); |
| 199 |
|
| 200 |
$this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) ); |
| 201 |
} ); |
| 202 |
|
| 203 |
$( ".tutorial-section pre, .readme-section pre, pre.prettyprint.source" ).each( function () { |
| 204 |
var $this = $( this ); |
| 205 |
|
| 206 |
var example = $this.find( "code" ); |
| 207 |
exampleText = example.html(); |
| 208 |
var lang = /{@lang (.*?)}/.exec( exampleText ); |
| 209 |
if ( lang && lang[1] ) { |
| 210 |
exampleText = exampleText.replace( lang[0], "" ); |
| 211 |
example.html( exampleText ); |
| 212 |
lang = lang[1]; |
| 213 |
} else { |
| 214 |
var langClassMatch = example.parent()[0].className.match(/lang\-(\S+)/); |
| 215 |
lang = langClassMatch ? langClassMatch[1] : "javascript"; |
| 216 |
} |
| 217 |
|
| 218 |
if ( lang ) { |
| 219 |
|
| 220 |
$this |
| 221 |
.addClass( "sunlight-highlight-" + lang ) |
| 222 |
.addClass( "linenums" ) |
| 223 |
.html( example.html() ); |
| 224 |
|
| 225 |
} |
| 226 |
} ); |
| 227 |
|
| 228 |
Sunlight.highlightAll( { |
| 229 |
lineNumbers : true, |
| 230 |
showMenu : true, |
| 231 |
enableDoclinks : true |
| 232 |
} ); |
| 233 |
|
| 234 |
$.catchAnchorLinks( { |
| 235 |
navbarOffset: 10 |
| 236 |
} ); |
| 237 |
$( "#toc" ).toc( { |
| 238 |
anchorName : function ( i, heading, prefix ) { |
| 239 |
return $( heading ).attr( "id" ) || ( prefix + i ); |
| 240 |
}, |
| 241 |
selectors : "#toc-content h1,#toc-content h2,#toc-content h3,#toc-content h4", |
| 242 |
showAndHide : false, |
| 243 |
smoothScrolling: true |
| 244 |
} ); |
| 245 |
|
| 246 |
$( "#main span[id^='toc']" ).addClass( "toc-shim" ); |
| 247 |
$( '.dropdown-toggle' ).dropdown(); |
| 248 |
|
| 249 |
$( "table" ).each( function () { |
| 250 |
var $this = $( this ); |
| 251 |
$this.addClass('table'); |
| 252 |
} ); |
| 253 |
|
| 254 |
} ); |
| 255 |
</script> |
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
<script type="text/javascript"> |
| 267 |
$(document).ready(function() { |
| 268 |
SearcherDisplay.init(); |
| 269 |
}); |
| 270 |
</script> |
| 271 |
|
| 272 |
|
| 273 |
</body> |
| 274 |
</html> |