diff --git a/src/main/webapp/WEB-INF/jsp/base/code/code-main.jsp b/src/main/webapp/WEB-INF/jsp/base/code/code-main.jsp
index c7b22b88..8403de54 100644
--- a/src/main/webapp/WEB-INF/jsp/base/code/code-main.jsp
+++ b/src/main/webapp/WEB-INF/jsp/base/code/code-main.jsp
@@ -117,7 +117,7 @@
-?${ver}">
+
">
">
+?${ver}">
+">
?${ver}">
">
">
diff --git a/src/main/webapp/resources/js/base/code-support.js b/src/main/webapp/resources/js/base/code-support.js
new file mode 100644
index 00000000..45227581
--- /dev/null
+++ b/src/main/webapp/resources/js/base/code-support.js
@@ -0,0 +1,44 @@
+class CommonCodes {
+ constructor(codeList, asObject) {
+ codeList.forEach(item => this[item.code] = !asObject ? item.value : item);
+ this.codes = () => codeList.map(item => item.code);
+ this.list = () => codeList;
+ }
+
+ _value(code, field) {
+ let found = this[code];
+ if (!found)
+ return null;
+
+ return "string" == typeof found ? found : found[field]
+ }
+
+ value(code, nt) {
+ return ifEmpty(this._value(code, "value"), nt);
+ }
+
+ format(code) {
+ return this.value(code, "");
+ }
+
+ parse(value) {
+ for (let code in this) {
+ let val = this.value(code);
+ if (value == val)
+ return code;
+ }
+ return "";
+ }
+
+ etc1(code) {
+ return this._value(code, "etc1");
+ }
+
+ etc2(code) {
+ return this._value(code, "etc2");
+ }
+
+ etc3(code) {
+ return this._value(code, "etc3");
+ }
+}
\ No newline at end of file
diff --git a/src/main/webapp/resources/js/base/dataset.js b/src/main/webapp/resources/js/base/dataset.js
index 1099c883..8655b004 100644
--- a/src/main/webapp/resources/js/base/dataset.js
+++ b/src/main/webapp/resources/js/base/dataset.js
@@ -3,6 +3,10 @@
/**@file Classes and objects to help control user data in HTML pages
*/
+function lpad(v) {
+ return v < 10 ? "0" + v : v;
+}
+
/** value format for numbers */
const numberFormat = {
/**Parses the value for a number
@@ -44,12 +48,8 @@ const dateFormat = {
let _format = v => {
let date = "number" == typeof v ? new Date(v) : v;
let year = date.getFullYear(),
- month = date.getMonth() + 1,
- day = date.getDate();
- if (month < 10)
- month = "0" + month;
- if (day < 10)
- day = "0" + day;
+ month = lpad(date.getMonth() + 1),
+ day = lpad(date.getDate());
return year + "-" + month + "-" + day;
};
@@ -62,22 +62,43 @@ const dateFormat = {
}
};
-/** value format for datetimes */
-const datetimeFormat = {
+/** value format for time */
+const timeFormat = {
/**Formats the value
* @param {number} value value to format
* @returns {string} formatted value
*/
format(value) {
let _format = v => {
- let date = "number" == typeof v ? new Date(v) : v;
- return date.toLocaleTimeString();
+ let date = "number" == typeof v ? new Date(v) : v,
+ hours = lpad(date.getHours()),
+ minutes = lpad(date.getMinutes()),
+ seconds = lpad(date.getSeconds());
+ return hours + ":" + minutes + ":" + seconds;
};
switch (value instanceof Date ? "date" : typeof value) {
case "number":
- case "date": return dateFormat.format(value) + " " + _format(value);
- case "string": return dateFormat.format(value) + " " + value.substr(8, 2) + ":" + value.substr(10, 2) + ":" + value.substr(12)
+ case "date": return _format(value);
+ case "string":
+ let offset = value.length - 6;
+ return value.substr(0 + offset, 2) + ":" + value.substr(2 + offset, 2) + ":" + value.substr(4 + offset)
+ default: return "";
+ }
+ }
+}
+
+/** value format for datetimes */
+const datetimeFormat = {
+ /**Formats the value
+ * @param {number} value value to format
+ * @returns {string} formatted value
+ */
+ format(value) {
+ switch (value instanceof Date ? "date" : typeof value) {
+ case "number":
+ case "date": return dateFormat.format(value) + " " + timeFormat.format(value);
+ case "string": return dateFormat.format(value) + " " + timeFormat.format(value);
default: return "";
}
}
@@ -507,7 +528,6 @@ class Dataset {
if (this.empty)
return this.setData(obj);
-
let state = this.state;
let data = this._getDataItems(obj);
this._items = this._items.concat(data.items);