File: datetime.html

package info (click to toggle)
json-editor.js 1.3.2%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 1,692 kB
  • sloc: perl: 39; makefile: 5
file content (285 lines) | stat: -rw-r--r-- 9,467 bytes parent folder | download | duplicates (2)
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
<!DOCTYPE HTML>

<html>

<head>
  <title>datetime editor examples</title>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">

  <!-- Enable responsive viewport -->
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <!-- jQuery -->
  <script src="../../../javascript/jquery/jquery.min.js" crossorigin="anonymous"></script>

  <!-- Bootstrap3 -->
  <!-- Latest compiled and minified CSS -->
  <link rel="stylesheet" href="../../../javascript/bootstrap/css/bootstrap.min.css">
  <!-- Optional theme -->
  <link rel="stylesheet" href="../../../javascript/bootstrap/css/bootstrap-theme.min.css" >
  <!-- Latest compiled and minified JavaScript -->
  <script src="../../../javascript/bootstrap/js/bootstrap.min.js" ></script>

  <!-- Foundation
  <script type="text/javascript" src=""></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.2.4/foundation.min.css" />
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/foundicons/3.0.0/foundation-icons.css" />
  -->

  <!-- Handlebars -->
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.12/handlebars.min.js"></script>

  <!-- Flatpickr -->
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/flatpickr/4.5.1/flatpickr.min.js"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/flatpickr/4.5.1/flatpickr.min.css" />

  <!-- JSON-Editor -->
  <script src="../../../javascript/json-editor/jsoneditor.min.js"></script>

  <style type="text/css">
  body {
    margin: 1em;
  }

  </style>
</head>

<body>
  <h2>Extended handling of date, time and datetime-local type fields.</h2>

  <p>Works with both string and integer data types. (If integer is used, the date will be returned in epoch format)</p>
  <p>Adds support for setting "placeholder" through options.</p>
  <p>Has optional support for using <a href="https://flatpickr.js.org/" target="_blank" title="Flatpickr datepicker">flatpickr datepicker</a>.</p>
  <p>All flatpickr options is supported with a few minor differences.
  <ul>
    <li>"<strong>enableTime</strong>" and "<strong>noCalendar</strong>" are set automatically, based on the data type.</li>
    <li>Extra config option "<strong>errorDateFormat</strong>". If this is set, it will replace the format displayed in error messages.</li>
    <li>It is not possible to use "<strong>inline</strong>" and "<strong>wrap</strong>" options together.</li>
    <li>When using the "<strong>wrap</strong>" option, "toggle" and "clear" buttons are automatically added to markup. 2 extra boolean options ("<strong>showToggleButton</strong>" and "<strong>showClearButton</strong>") are available to control which buttons to display. Note: not all frameworks supports this. (Works in: Bootstrap and Foundation)</li>
    <li>When using the "inline" option, an extra boolean option ("<strong>inlineHideInput</strong>") is available to hide the original input field.</li>
    <li>If "mode" is set to either "multiple" or "range", only string data type is supported. Also the result from these is returned as a string, not an array.</li>
  </ul></p>
  <div id="form"></div>
  <script type="text/javascript">

  // Handlebars helper for displaying timestamps in human frindly format
  Handlebars.registerHelper("TimeStampToDateTime", function(ts) {
    return ts ? new Date(ts * 1000) : 'empty';
  });

  var options = {
    "theme": "bootstrap3",
    "template": "handlebars",
    "iconlib": "bootstrap3",
    "schema": {
      "title": "datetime editor examples",
      "id": "test",
      "type": "object",
      "format": "grid",
      "options": {
        "disable_edit_json": false,
        "disable_properties": false
      },
      "properties": {
        "sdate": {
          "type": "string",
          "format": "date",
          "title": "Date (String)",
          "description": "Standard date field",
          "options": {
            "grid_columns": 4,
            "placeholder": "Enter date"
          }
        },
        "stime": {
          "type": "string",
          "format": "time",
          "title": "Time (String)",
          "description": "Standard time field",
          "options": {
            "grid_columns": 4,
            "placeholder": "Enter time"
          }
        },
        "sdatetime": {
          "type": "string",
          "format": "datetime-local",
          "title": "Datetime (String)",
          "description": "Standard datetime-local field",
          "options": {
            "grid_columns": 4,
            "placeholder": "YYYY-MM-DD HH:SS"
          }
        },

        "fsdate": {
          "type": "string",
          "format": "date",
          "title": "Date (String)",
          "description": "Standard date field with flatpickr",
          "options": {
            "grid_columns": 4,
            "placeholder": "Enter date",
            "flatpickr": {
              "inlineHideInput": true,
              "wrap": true,
              "allowInput": true
            }
          }
        },
        "fstime": {
          "type": "string",
          "format": "time",
          "title": "Time (String)",
          "description": "Standard time field with flatpickr",
          "options": {
            "grid_columns": 4,
            "placeholder": "Enter time",
            "flatpickr": {
              "wrap": true,
              "showClearButton": false,
              "inlineHideInput": true,
              "defaultHour": 7,
              "defaultMinute": 19,
              "enableSeconds": true,
              "hourIncrement": 2,
              "minuteIncrement": 3,
              "time_24hr": true,
              "allowInput": true
            }
          }
        },
        "fsdatetime": {
          "type": "string",
          "format": "datetime-local",
          "title": "Datetime (String)",
          "description": "Standard datetime-local field with flatpickr",
          "options": {
            "grid_columns": 4,
            "placeholder": "Enter datetime",
            "flatpickr": {
              "wrap": true,
              "time_24hr": true,
              "allowInput": true
            }
          }
        },

        "idate": {
          "type": "integer",
          "format": "date",
          "title": "Date (Integer)",
          "description": "Integer date field",
          "options": {
            "grid_columns": 4,
            "placeholder": "Enter date"
          }
        },
        "itime": {
          "type": "integer",
          "format": "time",
          "title": "Time (Integer)",
          "description": "Integer time field",
          "options": {
            "grid_columns": 4,
            "placeholder": "Enter time"
          }
        },
        "idatetime": {
          "type": "integer",
          "format": "datetime-local",
          "title": "Datetime (Integer)",
          "description": "Integer datetime-local field",
          "options": {
            "grid_columns": 4,
            "placeholder": "Enter datetime"
          }
        },

        "fidate": {
          "type": "integer",
          "format": "date",
          "title": "Date (Integer)",
          "description": "Integer date field with flatpickr",
          "options": {
            "grid_columns": 4,
            "placeholder": "Enter date",
            "flatpickr": {
              "wrap": true,
              "time_24hr": true,
              "allowInput": true
            }
          }
        },
        "fitime": {
          "type": "integer",
          "format": "time",
          "title": "Time (Integer)",
          "description": "Integer time field with flatpickr",
          "options": {
            "grid_columns": 4,
            "placeholder": "Enter time",
            "flatpickr": {
              "wrap": true,
              "time_24hr": true,
              "allowInput": true
            }
          }
        },
        "fidatetime": {
          "type": "integer",
          "format": "datetime-local",
          "title": "Datetime (Integer)",
          "description": "Integer datetime-local field with flatpickr",
          "options": {
            "grid_columns": 4,
            "placeholder": "Enter datetime",
            "flatpickr": {
              "wrap": true,
              "time_24hr": true,
              "allowInput": true
            }
          }
        },

        "fisdatetime": {
          "type": "string",
          "format": "datetime-local",
          "title": "Datetime (String)",
          "description": "Standard datetime-local field with inline flatpickr",
          "options": {
            "grid_columns": 4,
            "placeholder": "Enter datetime",
            "flatpickr": {
              "inline": true,
              "time_24hr": true
            }
          }
        },
        "fisdate": {
          "type": "string",
          "format": "date",
          "title": "Date (String)",
          "description": "Standard date field with inline flatpickr and hidden input",
          "options": {
            "grid_columns": 4,
            "placeholder": "Enter datetime",
            "flatpickr": {
              "inlineHideInput": true,
              "inline": true,
              "time_24hr": true
            }
          }
        },

      }
    }
  }

  var element = document.getElementById('form');
  var editor = new JSONEditor(element, options);

  </script>
</body>

</html>