bare-script 3.8.1 → 3.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -9
- package/lib/include/args.bare +10 -10
- package/lib/include/baredoc.bare +313 -0
- package/lib/include/dataLineChart.bare +90 -0
- package/lib/include/dataTable.bare +3 -3
- package/lib/include/diff.bare +3 -3
- package/lib/include/forms.bare +1 -1
- package/lib/include/markdownUp.bare +310 -1
- package/lib/include/pager.bare +6 -6
- package/lib/include/unittest.bare +1 -1
- package/lib/include/unittestMock.bare +1 -1
- package/lib/library.js +113 -113
- package/package.json +4 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Licensed under the MIT License
|
|
2
|
-
# https://github.com/craigahobbs/
|
|
2
|
+
# https://github.com/craigahobbs/bare-script/blob/main/LICENSE
|
|
3
3
|
|
|
4
4
|
include <dataTable.bare>
|
|
5
5
|
|
|
@@ -28,6 +28,11 @@ markdownUpState = { \
|
|
|
28
28
|
#
|
|
29
29
|
|
|
30
30
|
|
|
31
|
+
# $function: dataLineChart
|
|
32
|
+
# $group: markdownUp.bare: data
|
|
33
|
+
# $doc: Draw a line chart
|
|
34
|
+
# $arg data: The data array
|
|
35
|
+
# $arg lineChart: The [line chart model](model.html#var.vName='LineChart')
|
|
31
36
|
function dataLineChart(data, lineChart):
|
|
32
37
|
width = objectGet(lineChart, 'width', 640)
|
|
33
38
|
height = objectGet(lineChart, 'height', 320)
|
|
@@ -37,6 +42,11 @@ function dataLineChart(data, lineChart):
|
|
|
37
42
|
endfunction
|
|
38
43
|
|
|
39
44
|
|
|
45
|
+
# $function: dataTable
|
|
46
|
+
# $group: markdownUp.bare: data
|
|
47
|
+
# $doc: Draw a data table
|
|
48
|
+
# $arg data: The data array
|
|
49
|
+
# $arg dataTable: Optional (default is null). The [data table model](model.html#var.vName='DataTable').
|
|
40
50
|
function dataTable(data, model):
|
|
41
51
|
lines = dataTableMarkdown(data, model)
|
|
42
52
|
if lines:
|
|
@@ -52,31 +62,93 @@ endfunction
|
|
|
52
62
|
#
|
|
53
63
|
|
|
54
64
|
|
|
65
|
+
# $function: documentFontSize
|
|
66
|
+
# $group: markdownUp.bare: document
|
|
67
|
+
# $doc: Get the document font size
|
|
68
|
+
# $return: The document font size, in pixels
|
|
55
69
|
function documentFontSize():
|
|
56
70
|
return markdownUpDefaultFontSizePx
|
|
57
71
|
endfunction
|
|
58
72
|
|
|
59
73
|
|
|
74
|
+
# $function: documentInputValue
|
|
75
|
+
# $group: markdownUp.bare: document
|
|
76
|
+
# $doc: Get an input element's value
|
|
77
|
+
# $arg id: The input element ID
|
|
78
|
+
# $return: The input element value or null if the element does not exist
|
|
60
79
|
function documentInputValue():
|
|
61
80
|
endfunction
|
|
62
81
|
|
|
63
82
|
|
|
83
|
+
# $function: documentSetFocus
|
|
84
|
+
# $group: markdownUp.bare: document
|
|
85
|
+
# $doc: Set focus to an element
|
|
86
|
+
# $arg id: The element ID
|
|
64
87
|
function documentSetFocus():
|
|
65
88
|
endfunction
|
|
66
89
|
|
|
67
90
|
|
|
91
|
+
# $function: documentSetKeyDown
|
|
92
|
+
# $group: markdownUp.bare: document
|
|
93
|
+
# $doc: Set the document keydown event handler. For example:
|
|
94
|
+
# $doc:
|
|
95
|
+
# $doc: ```barescript
|
|
96
|
+
# $doc: function myAppMain():
|
|
97
|
+
# $doc: myAppRender()
|
|
98
|
+
# $doc: documentSetKeyDown(myAppKeyDown)
|
|
99
|
+
# $doc: endfunction
|
|
100
|
+
# $doc:
|
|
101
|
+
# $doc: function myAppRender(key):
|
|
102
|
+
# $doc: markdownPrint( \
|
|
103
|
+
# $doc: '# KeyDown Test', \
|
|
104
|
+
# $doc: '', \
|
|
105
|
+
# $doc: if(key, '**Key pressed:** "' + key + '"', '*No key pressed yet.*') \
|
|
106
|
+
# $doc: )
|
|
107
|
+
# $doc: endfunction
|
|
108
|
+
# $doc:
|
|
109
|
+
# $doc: function myAppKeyDown(event):
|
|
110
|
+
# $doc: key = objectGet(event, 'key')
|
|
111
|
+
# $doc: myAppRender(key)
|
|
112
|
+
# $doc: endfunction
|
|
113
|
+
# $doc:
|
|
114
|
+
# $doc: myAppMain()
|
|
115
|
+
# $doc: ```
|
|
116
|
+
# $arg callback: The keydown event callback function, which takes a single `event` object that has
|
|
117
|
+
# $arg callback: the following attributes:
|
|
118
|
+
# $arg callback: - `key` - The key value (e.g., "a", "Enter", "ArrowUp")
|
|
119
|
+
# $arg callback: - `code` - The physical key code (e.g., "KeyA", "Enter")
|
|
120
|
+
# $arg callback: - `keyCode` - The legacy numeric code (e.g., 65 for 'a')
|
|
121
|
+
# $arg callback: - `ctrlKey` - If true, the control key is pressed
|
|
122
|
+
# $arg callback: - `altKey` - If true, the alt key is pressed
|
|
123
|
+
# $arg callback: - `shiftKey` - If true, the shift key is pressed
|
|
124
|
+
# $arg callback: - `metaKey` - If true, the cmd key is pressed
|
|
125
|
+
# $arg callback: - `repeat` - If true, the key is held down
|
|
126
|
+
# $arg callback: - `location` - 0=standard, 1=left, 2=right
|
|
68
127
|
function documentSetKeyDown():
|
|
69
128
|
endfunction
|
|
70
129
|
|
|
71
130
|
|
|
131
|
+
# $function: documentSetReset
|
|
132
|
+
# $group: markdownUp.bare: document
|
|
133
|
+
# $doc: Set the document reset element
|
|
134
|
+
# $arg id: The element ID
|
|
72
135
|
function documentSetReset():
|
|
73
136
|
endfunction
|
|
74
137
|
|
|
75
138
|
|
|
139
|
+
# $function: documentSetTitle
|
|
140
|
+
# $group: markdownUp.bare: document
|
|
141
|
+
# $doc: Set the document title
|
|
142
|
+
# $arg title: The document title string
|
|
76
143
|
function documentSetTitle():
|
|
77
144
|
endfunction
|
|
78
145
|
|
|
79
146
|
|
|
147
|
+
# $function: documentURL
|
|
148
|
+
# $group: markdownUp.bare: document
|
|
149
|
+
# $doc: Fix-up relative URLs
|
|
150
|
+
# $arg url: The URL
|
|
151
|
+
# $return: The fixed-up URL
|
|
80
152
|
function documentURL(url):
|
|
81
153
|
return url
|
|
82
154
|
endfunction
|
|
@@ -87,43 +159,100 @@ endfunction
|
|
|
87
159
|
#
|
|
88
160
|
|
|
89
161
|
|
|
162
|
+
# $function: drawArc
|
|
163
|
+
# $group: markdownUp.bare: draw
|
|
164
|
+
# $doc: Draw an arc curve from the current point to the end point
|
|
165
|
+
# $arg rx: The arc ellipse's x-radius
|
|
166
|
+
# $arg ry: The arc ellipse's y-radius
|
|
167
|
+
# $arg angle: The rotation (in degrees) of the ellipse relative to the x-axis
|
|
168
|
+
# $arg largeArcFlag: Either large arc (1) or small arc (0)
|
|
169
|
+
# $arg sweepFlag: Either clockwise turning arc (1) or counterclockwise turning arc (0)
|
|
170
|
+
# $arg x: The x-coordinate of the end point
|
|
171
|
+
# $arg y: The y-coordinate of the end point
|
|
90
172
|
function drawArc():
|
|
91
173
|
endfunction
|
|
92
174
|
|
|
93
175
|
|
|
176
|
+
# $function: drawCircle
|
|
177
|
+
# $group: markdownUp.bare: draw
|
|
178
|
+
# $doc: Draw a circle
|
|
179
|
+
# $arg cx: The x-coordinate of the center of the circle
|
|
180
|
+
# $arg cy: The y-coordinate of the center of the circle
|
|
181
|
+
# $arg r: The radius of the circle
|
|
94
182
|
function drawCircle():
|
|
95
183
|
endfunction
|
|
96
184
|
|
|
97
185
|
|
|
186
|
+
# $function: drawClose
|
|
187
|
+
# $group: markdownUp.bare: draw
|
|
188
|
+
# $doc: Close the current drawing path
|
|
98
189
|
function drawClose():
|
|
99
190
|
endfunction
|
|
100
191
|
|
|
101
192
|
|
|
193
|
+
# $function: drawEllipse
|
|
194
|
+
# $group: markdownUp.bare: draw
|
|
195
|
+
# $doc: Draw an ellipse
|
|
196
|
+
# $arg cx: The x-coordinate of the center of the ellipse
|
|
197
|
+
# $arg cy: The y-coordinate of the center of the ellipse
|
|
198
|
+
# $arg rx: The x-radius of the ellipse
|
|
199
|
+
# $arg ry: The y-radius of the ellipse
|
|
102
200
|
function drawEllipse():
|
|
103
201
|
endfunction
|
|
104
202
|
|
|
105
203
|
|
|
204
|
+
# $function: drawHLine
|
|
205
|
+
# $group: markdownUp.bare: draw
|
|
206
|
+
# $doc: Draw a horizontal line from the current point to the end point
|
|
207
|
+
# $arg x: The x-coordinate of the end point
|
|
106
208
|
function drawHLine():
|
|
107
209
|
endfunction
|
|
108
210
|
|
|
109
211
|
|
|
212
|
+
# $function: drawHeight
|
|
213
|
+
# $group: markdownUp.bare: draw
|
|
214
|
+
# $doc: Get the current drawing's height
|
|
215
|
+
# $return: The current drawing's height
|
|
110
216
|
function drawHeight():
|
|
111
217
|
return objectGet(markdownUpState, 'drawingHeight')
|
|
112
218
|
endfunction
|
|
113
219
|
|
|
114
220
|
|
|
221
|
+
# $function: drawImage
|
|
222
|
+
# $group: markdownUp.bare: draw
|
|
223
|
+
# $doc: Draw an image
|
|
224
|
+
# $arg x: The x-coordinate of the center of the image
|
|
225
|
+
# $arg y: The y-coordinate of the center of the image
|
|
226
|
+
# $arg width: The width of the image
|
|
227
|
+
# $arg height: The height of the image
|
|
228
|
+
# $arg href: The image resource URL
|
|
115
229
|
function drawImage():
|
|
116
230
|
endfunction
|
|
117
231
|
|
|
118
232
|
|
|
233
|
+
# $function: drawLine
|
|
234
|
+
# $group: markdownUp.bare: draw
|
|
235
|
+
# $doc: Draw a line from the current point to the end point
|
|
236
|
+
# $arg x: The x-coordinate of the end point
|
|
237
|
+
# $arg y: The y-coordinate of the end point
|
|
119
238
|
function drawLine():
|
|
120
239
|
endfunction
|
|
121
240
|
|
|
122
241
|
|
|
242
|
+
# $function: drawMove
|
|
243
|
+
# $group: markdownUp.bare: draw
|
|
244
|
+
# $doc: Move the path's drawing point
|
|
245
|
+
# $arg x: The x-coordinate of the new drawing point
|
|
246
|
+
# $arg y: The y-coordinate of the new drawing point
|
|
123
247
|
function drawMove():
|
|
124
248
|
endfunction
|
|
125
249
|
|
|
126
250
|
|
|
251
|
+
# $function: drawNew
|
|
252
|
+
# $group: markdownUp.bare: draw
|
|
253
|
+
# $doc: Create a new drawing
|
|
254
|
+
# $arg width: The width of the drawing
|
|
255
|
+
# $arg height: The height of the drawing
|
|
127
256
|
function drawNew(width, height):
|
|
128
257
|
objectSet(markdownUpState, 'drawingWidth', width)
|
|
129
258
|
objectSet(markdownUpState, 'drawingHeight', height)
|
|
@@ -132,26 +261,71 @@ function drawNew(width, height):
|
|
|
132
261
|
endfunction
|
|
133
262
|
|
|
134
263
|
|
|
264
|
+
# $function: drawOnClick
|
|
265
|
+
# $group: markdownUp.bare: draw
|
|
266
|
+
# $doc: Set the most recent drawing object's on-click event handler
|
|
267
|
+
# $arg callback: The on-click event callback function (x, y)
|
|
135
268
|
function drawOnClick():
|
|
136
269
|
endfunction
|
|
137
270
|
|
|
138
271
|
|
|
272
|
+
# $function: drawPathRect
|
|
273
|
+
# $group: markdownUp.bare: draw
|
|
274
|
+
# $doc: Draw a rectangle as a path
|
|
275
|
+
# $arg x: The x-coordinate of the top-left of the rectangle
|
|
276
|
+
# $arg y: The y-coordinate of the top-left of the rectangle
|
|
277
|
+
# $arg width: The width of the rectangle
|
|
278
|
+
# $arg height: The height of the rectangle
|
|
139
279
|
function drawPathRect():
|
|
140
280
|
endfunction
|
|
141
281
|
|
|
142
282
|
|
|
283
|
+
# $function: drawRect
|
|
284
|
+
# $group: markdownUp.bare: draw
|
|
285
|
+
# $doc: Draw a rectangle
|
|
286
|
+
# $arg x: The x-coordinate of the top-left of the rectangle
|
|
287
|
+
# $arg y: The y-coordinate of the top-left of the rectangle
|
|
288
|
+
# $arg width: The width of the rectangle
|
|
289
|
+
# $arg height: The height of the rectangle
|
|
290
|
+
# $arg rx: Optional (default is null). The horizontal corner radius of the rectangle.
|
|
291
|
+
# $arg ry: Optional (default is null). The vertical corner radius of the rectangle.
|
|
143
292
|
function drawRect():
|
|
144
293
|
endfunction
|
|
145
294
|
|
|
146
295
|
|
|
296
|
+
# $function: drawStyle
|
|
297
|
+
# $group: markdownUp.bare: draw
|
|
298
|
+
# $doc: Set the current drawing styles
|
|
299
|
+
# $arg stroke: Optional (default is 'black'). The stroke color.
|
|
300
|
+
# $arg strokeWidth: Optional (default is 1). The stroke width.
|
|
301
|
+
# $arg fill: Optional (default is 'none'). The fill color.
|
|
302
|
+
# $arg strokeDashArray: Optional (default is 'none'). The stroke
|
|
303
|
+
# $arg strokeDashArray: [dash array](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray#usage_notes).
|
|
147
304
|
function drawStyle():
|
|
148
305
|
endfunction
|
|
149
306
|
|
|
150
307
|
|
|
308
|
+
# $function: drawText
|
|
309
|
+
# $group: markdownUp.bare: draw
|
|
310
|
+
# $doc: Draw text
|
|
311
|
+
# $arg text: The text to draw
|
|
312
|
+
# $arg x: The x-coordinate of the text
|
|
313
|
+
# $arg y: The y-coordinate of the text
|
|
314
|
+
# $arg textAnchor: Optional (default is 'middle'). The
|
|
315
|
+
# $arg textAnchor: [text anchor](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/text-anchor#usage_notes) style.
|
|
316
|
+
# $arg dominantBaseline: Optional (default is 'middle'). The
|
|
317
|
+
# $arg dominantBaseline: [dominant baseline](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/dominant-baseline#usage_notes)
|
|
318
|
+
# $arg dominantBaseline: style.
|
|
151
319
|
function drawText():
|
|
152
320
|
endfunction
|
|
153
321
|
|
|
154
322
|
|
|
323
|
+
# $function: drawTextHeight
|
|
324
|
+
# $group: markdownUp.bare: draw
|
|
325
|
+
# $doc: Compute the text's height to fit the width
|
|
326
|
+
# $arg text: The text
|
|
327
|
+
# $arg width: The width of the text. If 0, the default font size (in pixels) is returned.
|
|
328
|
+
# $return: The text's height, in pixels
|
|
155
329
|
function drawTextHeight(text, width):
|
|
156
330
|
if width > 0:
|
|
157
331
|
return width / (markdownUpFontWidthRatio * stringLength(text))
|
|
@@ -160,20 +334,42 @@ function drawTextHeight(text, width):
|
|
|
160
334
|
endfunction
|
|
161
335
|
|
|
162
336
|
|
|
337
|
+
# $function: drawTextStyle
|
|
338
|
+
# $group: markdownUp.bare: draw
|
|
339
|
+
# $doc: Set the current text drawing styles
|
|
340
|
+
# $arg fontSizePx: Optional (default is null, the default font size). The text font size, in pixels.
|
|
341
|
+
# $arg textFill: Optional (default is 'black'). The text fill color.
|
|
342
|
+
# $arg bold: Optional (default is false). If true, text is bold.
|
|
343
|
+
# $arg italic: Optional (default is false). If true, text is italic.
|
|
344
|
+
# $arg fontFamily: Optional (default is null, the default font family). The text font family.
|
|
163
345
|
function drawTextStyle(fontSizePx):
|
|
164
346
|
objectSet(markdownUpState, 'drawingFontSizePx', if(fontSizePx != null, fontSizePx, markdownUpDefaultFontSizePx))
|
|
165
347
|
endfunction
|
|
166
348
|
|
|
167
349
|
|
|
350
|
+
# $function: drawTextWidth
|
|
351
|
+
# $group: markdownUp.bare: draw
|
|
352
|
+
# $doc: Compute the text's width
|
|
353
|
+
# $arg text: The text
|
|
354
|
+
# $arg fontSizePx: The text font size, in pixels
|
|
355
|
+
# $return: The text's width, in pixels
|
|
168
356
|
function drawTextWidth(text, fontSizePx):
|
|
169
357
|
return markdownUpFontWidthRatio * fontSizePx * stringLength(text)
|
|
170
358
|
endfunction
|
|
171
359
|
|
|
172
360
|
|
|
361
|
+
# $function: drawVLine
|
|
362
|
+
# $group: markdownUp.bare: draw
|
|
363
|
+
# $doc: Draw a vertical line from the current point to the end point
|
|
364
|
+
# $arg y: The y-coordinate of the end point
|
|
173
365
|
function drawVLine():
|
|
174
366
|
endfunction
|
|
175
367
|
|
|
176
368
|
|
|
369
|
+
# $function: drawWidth
|
|
370
|
+
# $group: markdownUp.bare: draw
|
|
371
|
+
# $doc: Get the current drawing's width
|
|
372
|
+
# $return: The current drawing's width
|
|
177
373
|
function drawWidth():
|
|
178
374
|
return objectGet(markdownUpState, 'drawingWidth')
|
|
179
375
|
endfunction
|
|
@@ -184,6 +380,16 @@ endfunction
|
|
|
184
380
|
#
|
|
185
381
|
|
|
186
382
|
|
|
383
|
+
# $function: elementModelRender
|
|
384
|
+
# $group: markdownUp.bare: elementModel
|
|
385
|
+
# $doc: Render an [element model](https://github.com/craigahobbs/element-model#readme)
|
|
386
|
+
# $doc:
|
|
387
|
+
# $doc: **Note:** Element model "callback" members are a map of event name (e.g., "click") to
|
|
388
|
+
# $doc: event callback function. The following events have callback arguments:
|
|
389
|
+
# $doc: - **keydown** - keyCode
|
|
390
|
+
# $doc: - **keypress** - keyCode
|
|
391
|
+
# $doc: - **keyup** - keyCode
|
|
392
|
+
# $arg element: The [element model](https://github.com/craigahobbs/element-model#readme)
|
|
187
393
|
function elementModelRender():
|
|
188
394
|
endfunction
|
|
189
395
|
|
|
@@ -193,21 +399,38 @@ endfunction
|
|
|
193
399
|
#
|
|
194
400
|
|
|
195
401
|
|
|
402
|
+
# $function: localStorageClear
|
|
403
|
+
# $group: markdownUp.bare: localStorage
|
|
404
|
+
# $doc: Clear all keys from the browser's local storage
|
|
196
405
|
function localStorageClear():
|
|
197
406
|
objectSet(markdownUpState, 'localStorage', {})
|
|
198
407
|
endfunction
|
|
199
408
|
|
|
200
409
|
|
|
410
|
+
# $function: localStorageGet
|
|
411
|
+
# $group: markdownUp.bare: localStorage
|
|
412
|
+
# $doc: Get a browser local storage key's value
|
|
413
|
+
# $arg key: The key string
|
|
414
|
+
# $return: The local storage value string or null if the key does not exist
|
|
201
415
|
function localStorageGet(key):
|
|
202
416
|
return objectGet(objectGet(markdownUpState, 'localStorage'), key)
|
|
203
417
|
endfunction
|
|
204
418
|
|
|
205
419
|
|
|
420
|
+
# $function: localStorageRemove
|
|
421
|
+
# $group: markdownUp.bare: localStorage
|
|
422
|
+
# $doc: Remove a browser local storage key
|
|
423
|
+
# $arg key: The key string
|
|
206
424
|
function localStorageRemove(key):
|
|
207
425
|
objectDelete(objectGet(markdownUpState, 'localStorage'), key)
|
|
208
426
|
endfunction
|
|
209
427
|
|
|
210
428
|
|
|
429
|
+
# $function: localStorageSet
|
|
430
|
+
# $group: markdownUp.bare: localStorage
|
|
431
|
+
# $doc: Set a browser local storage key's value
|
|
432
|
+
# $arg key: The key string
|
|
433
|
+
# $arg value: The value string
|
|
211
434
|
function localStorageSet(key, value):
|
|
212
435
|
objectSet(objectGet(markdownUpState, 'localStorage'), key, value)
|
|
213
436
|
endfunction
|
|
@@ -218,6 +441,11 @@ endfunction
|
|
|
218
441
|
#
|
|
219
442
|
|
|
220
443
|
|
|
444
|
+
# $function: markdownEscape
|
|
445
|
+
# $group: markdownUp.bare: markdown
|
|
446
|
+
# $doc: Escape text for inclusion in Markdown text
|
|
447
|
+
# $arg text: The text
|
|
448
|
+
# $return: The escaped text
|
|
221
449
|
function markdownEscape(text):
|
|
222
450
|
return regexReplace(markdownUp_markdownEscapeRegex, text, '\\$1')
|
|
223
451
|
endfunction
|
|
@@ -225,6 +453,11 @@ endfunction
|
|
|
225
453
|
markdownUp_markdownEscapeRegex = regexNew('([\\\\[\\]()<>"\'*_~`#=+|-])')
|
|
226
454
|
|
|
227
455
|
|
|
456
|
+
# $function: markdownHeaderId
|
|
457
|
+
# $group: markdownUp.bare: markdown
|
|
458
|
+
# $doc: Compute the Markdown header element ID for some text
|
|
459
|
+
# $arg text: The text
|
|
460
|
+
# $return: The header element ID
|
|
228
461
|
function markdownHeaderId(text):
|
|
229
462
|
result = stringLower(text)
|
|
230
463
|
result = regexReplace(markdownUp_markdownHeaderId_start, result, '')
|
|
@@ -239,10 +472,19 @@ markdownUp_markdownHeaderId_remove = regexNew('[\'"]')
|
|
|
239
472
|
markdownUp_markdownHeaderId_dash = regexNew('[^a-z0-9]+')
|
|
240
473
|
|
|
241
474
|
|
|
475
|
+
# $function: markdownParse
|
|
476
|
+
# $group: markdownUp.bare: markdown
|
|
477
|
+
# $doc: Parse Markdown text
|
|
478
|
+
# $arg lines...: The Markdown text lines (may contain nested arrays of un-split lines)
|
|
479
|
+
# $return: The [Markdown model](https://craigahobbs.github.io/markdown-model/model/#var.vName='Markdown')
|
|
242
480
|
function markdownParse():
|
|
243
481
|
endfunction
|
|
244
482
|
|
|
245
483
|
|
|
484
|
+
# $function: markdownPrint
|
|
485
|
+
# $group: markdownUp.bare: markdown
|
|
486
|
+
# $doc: Render Markdown text
|
|
487
|
+
# $arg lines...: The Markdown text lines (may contain nested arrays of un-split lines)
|
|
246
488
|
function markdownPrint(lines...):
|
|
247
489
|
markdownUp_markdownPrintHelper(lines)
|
|
248
490
|
endfunction
|
|
@@ -258,6 +500,11 @@ function markdownUp_markdownPrintHelper(lines):
|
|
|
258
500
|
endfunction
|
|
259
501
|
|
|
260
502
|
|
|
503
|
+
# $function: markdownTitle
|
|
504
|
+
# $group: markdownUp.bare: markdown
|
|
505
|
+
# $doc: Compute the title of a [Markdown model](https://craigahobbs.github.io/markdown-model/model/#var.vName='Markdown')
|
|
506
|
+
# $arg markdownModel: The [Markdown model](https://craigahobbs.github.io/markdown-model/model/#var.vName='Markdown')
|
|
507
|
+
# $return: The Markdown title or null if there is no title
|
|
261
508
|
function markdownTitle():
|
|
262
509
|
endfunction
|
|
263
510
|
|
|
@@ -267,6 +514,16 @@ endfunction
|
|
|
267
514
|
#
|
|
268
515
|
|
|
269
516
|
|
|
517
|
+
# $function: schemaElements
|
|
518
|
+
# $group: markdownUp.bare: schema
|
|
519
|
+
# $doc: Get a schema type's documentation [element model](https://github.com/craigahobbs/element-model#readme).
|
|
520
|
+
# $doc: Render the element model with the [elementModelRender](#var.vName='elementModelRender') function.
|
|
521
|
+
# $arg types: The [type model](https://craigahobbs.github.io/schema-markdown-doc/doc/#var.vName='Types')
|
|
522
|
+
# $arg typeName: The type name
|
|
523
|
+
# $arg actionURLs: Optional (default is null). The
|
|
524
|
+
# $arg actionURLs: [action URL overrides](https://craigahobbs.github.io/schema-markdown-doc/doc/#var.vName='ActionURL').
|
|
525
|
+
# $arg actionCustom: Optional (default is false). If true, the action has a custom response.
|
|
526
|
+
# $return: The schema type's documentation [element model](https://github.com/craigahobbs/element-model#readme)
|
|
270
527
|
function schemaElements(types, typeName):
|
|
271
528
|
userType = objectGet(types, typeName)
|
|
272
529
|
userTypeKey = arrayGet(objectKeys(userType), 0)
|
|
@@ -286,21 +543,38 @@ endfunction
|
|
|
286
543
|
#
|
|
287
544
|
|
|
288
545
|
|
|
546
|
+
# $function: sessionStorageClear
|
|
547
|
+
# $group: markdownUp.bare: sessionStorage
|
|
548
|
+
# $doc: Clear all keys from the browser's session storage
|
|
289
549
|
function sessionStorageClear():
|
|
290
550
|
objectSet(markdownUpState, 'sessionStorage', {})
|
|
291
551
|
endfunction
|
|
292
552
|
|
|
293
553
|
|
|
554
|
+
# $function: sessionStorageGet
|
|
555
|
+
# $group: markdownUp.bare: sessionStorage
|
|
556
|
+
# $doc: Get a browser session storage key's value
|
|
557
|
+
# $arg key: The key string
|
|
558
|
+
# $return: The session storage value string or null if the key does not exist
|
|
294
559
|
function sessionStorageGet(key):
|
|
295
560
|
return objectGet(objectGet(markdownUpState, 'sessionStorage'), key)
|
|
296
561
|
endfunction
|
|
297
562
|
|
|
298
563
|
|
|
564
|
+
# $function: sessionStorageRemove
|
|
565
|
+
# $group: markdownUp.bare: sessionStorage
|
|
566
|
+
# $doc: Remove a browser session storage key
|
|
567
|
+
# $arg key: The key string
|
|
299
568
|
function sessionStorageRemove(key):
|
|
300
569
|
objectDelete(objectGet(markdownUpState, 'sessionStorage'), key)
|
|
301
570
|
endfunction
|
|
302
571
|
|
|
303
572
|
|
|
573
|
+
# $function: sessionStorageSet
|
|
574
|
+
# $group: markdownUp.bare: sessionStorage
|
|
575
|
+
# $doc: Set a browser session storage key's value
|
|
576
|
+
# $arg key: The key string
|
|
577
|
+
# $arg value: The value string
|
|
304
578
|
function sessionStorageSet(key, value):
|
|
305
579
|
objectSet(objectGet(markdownUpState, 'sessionStorage'), key, value)
|
|
306
580
|
endfunction
|
|
@@ -311,6 +585,12 @@ endfunction
|
|
|
311
585
|
#
|
|
312
586
|
|
|
313
587
|
|
|
588
|
+
# $function: urlObjectCreate
|
|
589
|
+
# $group: markdownUp.bare: url
|
|
590
|
+
# $doc: Create an object URL (i.e. a file download URL)
|
|
591
|
+
# $arg data: The object data string
|
|
592
|
+
# $arg contentType: Optional (default is "text/plain"). The object content type.
|
|
593
|
+
# $return: The object URL string
|
|
314
594
|
function urlObjectCreate(data, contentType):
|
|
315
595
|
return 'blob:' + urlEncode(contentType) + '-' + urlEncode(if(stringLength(data) < 20, data, stringSlice(data, 0, 20)))
|
|
316
596
|
endfunction
|
|
@@ -321,33 +601,62 @@ endfunction
|
|
|
321
601
|
#
|
|
322
602
|
|
|
323
603
|
|
|
604
|
+
# $function: windowClipboardRead
|
|
605
|
+
# $group: markdownUp.bare: window
|
|
606
|
+
# $doc: Read text from the clipboard
|
|
607
|
+
# $return: The clipboard text
|
|
324
608
|
function windowClipboardRead():
|
|
325
609
|
return objectGet(markdownUpState, 'windowClipboard')
|
|
326
610
|
endfunction
|
|
327
611
|
|
|
328
612
|
|
|
613
|
+
# $function: windowClipboardWrite
|
|
614
|
+
# $group: markdownUp.bare: window
|
|
615
|
+
# $doc: Write text to the clipboard
|
|
616
|
+
# $arg text: The text to write
|
|
329
617
|
function windowClipboardWrite(text):
|
|
330
618
|
return objectSet(markdownUpState, 'windowClipboard', text)
|
|
331
619
|
endfunction
|
|
332
620
|
|
|
333
621
|
|
|
622
|
+
# $function: windowHeight
|
|
623
|
+
# $group: markdownUp.bare: window
|
|
624
|
+
# $doc: Get the browser window's height
|
|
625
|
+
# $return: The browser window's height
|
|
334
626
|
function windowHeight():
|
|
335
627
|
return markdownUpWindowHeight
|
|
336
628
|
endfunction
|
|
337
629
|
|
|
338
630
|
|
|
631
|
+
# $function: windowSetLocation
|
|
632
|
+
# $group: markdownUp.bare: window
|
|
633
|
+
# $doc: Navigate the browser window to a location URL
|
|
634
|
+
# $arg url: The new location URL
|
|
339
635
|
function windowSetLocation():
|
|
340
636
|
endfunction
|
|
341
637
|
|
|
342
638
|
|
|
639
|
+
# $function: windowSetResize
|
|
640
|
+
# $group: markdownUp.bare: window
|
|
641
|
+
# $doc: Set the browser window resize event handler
|
|
642
|
+
# $arg callback: The window resize callback function
|
|
343
643
|
function windowSetResize():
|
|
344
644
|
endfunction
|
|
345
645
|
|
|
346
646
|
|
|
647
|
+
# $function: windowSetTimeout
|
|
648
|
+
# $group: markdownUp.bare: window
|
|
649
|
+
# $doc: Set the browser window timeout event handler
|
|
650
|
+
# $arg callback: The window timeout callback function
|
|
651
|
+
# $arg delay: The delay, in milliseconds, to ellapse before calling the timeout
|
|
347
652
|
function windowSetTimeout():
|
|
348
653
|
endfunction
|
|
349
654
|
|
|
350
655
|
|
|
656
|
+
# $function: windowWidth
|
|
657
|
+
# $group: markdownUp.bare: window
|
|
658
|
+
# $doc: Get the browser window's width
|
|
659
|
+
# $return: The browser window's width
|
|
351
660
|
function windowWidth():
|
|
352
661
|
return markdownUpWindowWidth
|
|
353
662
|
endfunction
|
package/lib/include/pager.bare
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Licensed under the MIT License
|
|
2
|
-
# https://github.com/craigahobbs/
|
|
2
|
+
# https://github.com/craigahobbs/bare-script/blob/main/LICENSE
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
include <args.bare>
|
|
@@ -7,7 +7,7 @@ include <args.bare>
|
|
|
7
7
|
|
|
8
8
|
# The pager model
|
|
9
9
|
pagerTypes = schemaParse( \
|
|
10
|
-
'group "pager.bare"', \
|
|
10
|
+
'group "<pager.bare>"', \
|
|
11
11
|
'', \
|
|
12
12
|
'', \
|
|
13
13
|
'# A pager application model', \
|
|
@@ -71,8 +71,8 @@ pagerTypes = schemaParse( \
|
|
|
71
71
|
# $function: pagerValidate
|
|
72
72
|
# $group: pager.bare
|
|
73
73
|
# $doc: Validate a pager model
|
|
74
|
-
# $arg pagerModel: The [pager model](
|
|
75
|
-
# $return: The validated [pager model](
|
|
74
|
+
# $arg pagerModel: The [pager model](model.html#var.vName='Pager')
|
|
75
|
+
# $return: The validated [pager model](model.html#var.vName='Pager') or null if validation fails
|
|
76
76
|
function pagerValidate(pagerModel):
|
|
77
77
|
return schemaValidate(pagerTypes, 'Pager', pagerModel)
|
|
78
78
|
endfunction
|
|
@@ -81,9 +81,9 @@ endfunction
|
|
|
81
81
|
# $function: pagerMain
|
|
82
82
|
# $group: pager.bare
|
|
83
83
|
# $doc: The pager application main entry point
|
|
84
|
-
# $arg pagerModel: The [pager model](
|
|
84
|
+
# $arg pagerModel: The [pager model](model.html#var.vName='Pager')
|
|
85
85
|
# $arg options: The pager application options. The following options are available:
|
|
86
|
-
# $arg options: - **arguments** - The [arguments model](
|
|
86
|
+
# $arg options: - **arguments** - The [arguments model](model.html#var.vName='ArgsArguments').
|
|
87
87
|
# $arg options: Must contain a string argument named "page".
|
|
88
88
|
# $arg options: - **hideMenu** - Hide the menu links
|
|
89
89
|
# $arg options: - **hideNav** - Hide the navigation links
|