-
Notifications
You must be signed in to change notification settings - Fork 1
/
converterdisplay.js.html
161 lines (132 loc) · 8.16 KB
/
converterdisplay.js.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: converterdisplay.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: converterdisplay.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/** Milesian Clock and converter functions - excluding initialisation and global variables.
* Associated with: converter.html.
* @file
* @requires milesianclockinitiate.
* @requires converteronload.js.
* other modules are made visible milesianclockinitiate.
* @see converter.html
* @version M2022-11-04
* @author Louis A. de Fouquières https://github.com/Louis-Aime
* @license MIT 2016-2022
*/
// Character set is UTF-8.
/* Version M2022-11-04 Enhance management of mark for non-valid calendars
see GitHub for details
*/
/* Copyright Louis A. de Fouquières https://github.com/Louis-Aime 2016-2022
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sub-license, or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
1. The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
2. Changes with respect to any former version shall be documented.
The software is provided "as is", without warranty of any kind,
express of implied, including but not limited to the warranties of
merchantability, fitness for a particular purpose and non-infringement.
In no event shall the authors of copyright holders be liable for any
claim, damages or other liability, whether in an action of contract,
tort or otherwise, arising from, out of or in connection with the software
or the use or other dealings in the software.
*/
"use strict";
function setDisplay () { // Disseminate targetDate and time on all display fields
// establish variables used only for this display cycle
var
dateComponent = targetDate.getFields(TZ),
milDate = new modules.ExtDate (milesian, targetDate.valueOf()),
mildateComponent = milDate.getFields(TZ), // Initiate a date decomposition in Milesian, to be used several times in subsequent code
myElement = document.querySelector("#mclock"), // myElement is a work variable
myCollection; // Another work variable, used later
// Update custom calendar
document.custom.year.value = dateComponent.fullYear;
document.custom.month.value = dateComponent.month;
document.custom.day.value = dateComponent.day;
document.week.weekyear.value = targetDate.weekYear(TZ);
document.week.weeknumber.value = targetDate.weekNumber(TZ);
document.week.weekday.value = targetDate.weekday(TZ);
document.week.weeksinyear.value = targetDate.weeksInYear(TZ);
document.week.dayofweek.value = weekFormat.format(targetDate);
// Place marks on all mutable elements, expressing that custom calendar is not valid at displayed date.
// myElement = document.querySelector("#customline"); // older version, when only one line should be tested
myCollection = document.getElementsByClassName("mutable");
// first remove marks from another display
for (let i = 0; i < myCollection.length; i++)
myCollection[i].setAttribute("class", myCollection[i].getAttribute("class").replace(" outbounds",""))
// Then check whether marks should be set
if (typeof calendars[customCalIndex].valid == "function" && !calendars[customCalIndex].valid(dateComponent))
for (let i = 0; i < myCollection.length; i++)
myCollection[i].setAttribute("class", myCollection[i].getAttribute("class").replace(" outbounds","") + " outbounds");
// Julian Day and chronological fields
let JD = new modules.ExtCountDate ("julianDayAtNight","iso8601",targetDate.valueOf()).getCount();
document.daycounter.julianday.value = JD;
// = JD.toLocaleString(undefined,{maximumFractionDigits:8}); // JD.toLocaleString(undefined,{useGrouping:false, maximumFractionDigits:8})
// Display Locale (language code only) as obtained after negotiation process
document.querySelector("#langCode").innerHTML = userOptions.locale.includes("-u-")
? userOptions.locale.substring (0,userOptions.locale.indexOf("-u-"))
: userOptions.locale ;
// Custom calendar date string following options. Catch error if navigator fails, in this case write without time part.
document.getElementById("customcalname").innerHTML = askedOptions.calendar.id;
myElement = document.getElementById("CustomString");
try { myElement.innerHTML = askedOptions.format(targetDate); }
catch (e) { myElement.innerHTML = "ExtDateTimeFormat.format error: " + e; }
// Write Milesian date string near dial
myElement = document.getElementById("clockmilesiandate"); // Milesian date element
myElement.innerHTML = clockFormat.format(targetDate);
// Finally update and display clock
milesianClock.setHands (milDate, TZ); // Display date on clock.
milesianClock.clock.querySelector(".moonage").innerHTML = modules.getCELunarDate(targetDate, TZ).day;
milesianClock.setSeasons (milDate.year("UTC")); // Display also seasons.
// Display dates in several calendars
myCollection = document.getElementsByClassName('calenddate'); // List of date elements to be computed
for (let i = 0; i < myCollection.length; i++) {
// myCollection[i].id is the the name of the calendar, either Unicode or custom. select the calendar object among calendar list.
let myCalendar = calendars.find ( (item) => (item.id == myCollection[i].id) ); // case the calendar is among the custom calendars.
if (myCalendar == undefined) myCalendar = myCollection[i].id; // if not found, it should be a built-in one.
let myOptions = {...userOptions} // a copy, since passed options are changed. (bug to be addressed)
// Write date string. Protect writing process against errors raised by browsers.
try {
myCollection[i].innerHTML =
new modules.ExtDateTimeFormat(userOptions.locale, myOptions, myCalendar).format(targetDate); // .format with conditional Era display.
}
catch (e) { // In case the browser raises an error
myCollection[i].innerHTML = e;
}
}
}
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-calendarclock.html">calendarclock</a></li><li><a href="module-countconversion.html">countconversion</a></li><li><a href="module-deltat.html">deltat</a></li><li><a href="module-lunar.html">lunar</a></li><li><a href="module-seasons.html">seasons</a></li><li><a href="module-yearsignature.html">yearsignature</a></li></ul><h3>Classes</h3><ul><li><a href="module-calendarclock.SolarClock.html">SolarClock</a></li><li><a href="module-countconversion.ExtCountDate.html">ExtCountDate</a></li><li><a href="timeShift.html">timeShift</a></li></ul><h3>Interfaces</h3><ul><li><a href="clockAnimate.html">clockAnimate</a></li><li><a href="myTimeShift.html">myTimeShift</a></li></ul><h3>Global</h3><ul><li><a href="global.html#calcCustomDate">calcCustomDate</a></li><li><a href="global.html#calcJulianDay">calcJulianDay</a></li><li><a href="global.html#calcTime">calcTime</a></li><li><a href="global.html#calcWeek">calcWeek</a></li><li><a href="global.html#setDateToNow">setDateToNow</a></li><li><a href="global.html#setDateToToday">setDateToToday</a></li><li><a href="global.html#setUTCHoursFixed">setUTCHoursFixed</a></li><li><a href="global.html#undef">undef</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.7</a> on Mon Apr 15 2024 21:10:03 GMT+0200 (heure d’été d’Europe centrale)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>