Skip to content

Commit

Permalink
add defaults to options descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnRDOrazio committed Mar 11, 2024
1 parent e9bc0fa commit bf49a2d
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions jqClock.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
* Sets time in clock div and calls itself every second
* Can take options as JSON object
* Possible options parameters:
* @timestamp defaults to clients current time
* @timestamp defaults to clients current time, using the performance API
* @timezone defaults to detection of client timezone, but can be passed in as a string such as "UTC-6" when using server generated timestamps
* @langSet defaults to "en", possible values are: "af", "am", "ar", "bg", "bn", "ca", "cs", "da", "de", "el", "en", "es", "et", "fa", "fi", "fr", "gu", "he", "hi", "hr", "hu", "id", "in", "it", "iw", "ja", "kn", "ko", "lt", "lv", "ml", "mo", "mr", "ms", "nb", "nl", "no", "pl", "pt", "ro", "ru", "sh", "sk", "sl", "sr", "sv", "sw", "ta", "te", "th", "tl", "tr", "uk", "ur", "vi", "zh", "arb", "cmn", "cnr", "drw", "ekk", "fil", "lvs", "pes", "prs", "swc", "swh", "tnf", "zsm"
* @langSet defaults to navigator language else "en", possible values are: "af", "am", "ar", "bg", "bn", "ca", "cs", "da", "de", "el", "en", "es", "et", "fa", "fi", "fr", "gu", "he", "hi", "hr", "hu", "id", "in", "it", "iw", "ja", "kn", "ko", "lt", "lv", "ml", "mo", "mr", "ms", "nb", "nl", "no", "pl", "pt", "ro", "ru", "sh", "sk", "sl", "sr", "sv", "sw", "ta", "te", "th", "tl", "tr", "uk", "ur", "vi", "zh", "arb", "cmn", "cnr", "drw", "ekk", "fil", "lvs", "pes", "prs", "swc", "swh", "tnf", "zsm" (can optionally add region)
* @calendar defaults to "true", possible value are: boolean "true" or "false"
* @dateFormat defaults to "l, F j, Y" when langSet==="en", else to "l, j F Y"
* @timeFormat defaults to "h:i:s A" when langSet==="en", else to "H:i:s"
Expand Down Expand Up @@ -185,9 +185,10 @@ if (!Number.prototype.map) {
{
name: "timestamp",
description:
"Either a javascript timestamp as produces by [JAVASCRIPT new Date().getTime()] or a php timestamp as produced by [PHP time()] ",
"Either a javascript timestamp as produced by [JAVASCRIPT new Date().getTime()] or a php timestamp as produced by [PHP time()] ",
type: "unix timestamp",
values: ["javascript timestamp", "php timestamp"]
values: ["javascript timestamp", "php timestamp"],
default: "\"localsystime\" which defaults to `new Date(performance.timeOrigin + performance.now()).getTime()`"
},
{
name: "langSet",
Expand All @@ -200,14 +201,16 @@ if (!Number.prototype.map) {
"mr", "ms", "nb", "nl", "no", "pl", "pt", "ro", "ru", "sh", "sk", "sl", "sr", "sv", "sw", "ta",
"te", "th", "tl", "tr", "uk", "ur", "vi", "zh", "arb", "cmn", "cnr", "drw", "ekk", "fil", "lvs",
"pes", "prs", "swc", "swh", "tnf", "zsm"
]
],
default: "navigator.language || \"en\""
},
{
name: "calendar",
description:
"Whether the date should be displayed together with the time",
type: "Boolean",
values: [true, false]
values: [true, false],
default: true
},
{
name: "dateFormat",
Expand All @@ -233,7 +236,8 @@ if (!Number.prototype.map) {
"o",
"Y",
"y"
]
],
default: "langSet === \"en\" ? \"l, F j, Y\" : \"l, j F Y\""
},
{
name: "timeFormat",
Expand All @@ -259,12 +263,13 @@ if (!Number.prototype.map) {
"c",
"r",
"U"
]
],
default: "langSet === \"en\" ? \"h:i:s A\" : \"H:i:s\""
},
{
name: "isDST",
description:
"When a client side timestamp is used, whether DST is active will be automatically determined. However this cannot be determined for a server-side timestamp which must be passed in as UTC, in that can case it can be set with this option",
"When a client side timestamp is used, whether DST is active will be automatically determined. However this cannot be determined for a server-side timestamp which must be passed in as UTC, in that case it can be set with this option",
type: "Boolean",
values: [true, false]
},
Expand All @@ -273,7 +278,8 @@ if (!Number.prototype.map) {
description:
"Defines the rate at which the clock will update, in milliseconds",
type: "Integer",
values: "1 - 9007199254740991 (recommended 10-60000)"
values: "1 - 9007199254740991 (recommended min 10 - max 60000)",
default: 500
}
]
}
Expand Down Expand Up @@ -636,7 +642,7 @@ if (!Number.prototype.map) {
options = options || {};
/* I prefer this method to jQuery.extend because we can dynamically set each option based on a preceding option's value */
options.timestamp = options.timestamp || "localsystime";
options.langSet = options.langSet || "en";
options.langSet = options.langSet || navigator.language || "en";
options.calendar = options.hasOwnProperty("calendar")
? options.calendar
: true;
Expand Down

0 comments on commit bf49a2d

Please sign in to comment.