You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* - boxes / id / index and arbitrary attributes are applied where appropriate
5375
+
*
5376
+
* This function mutates the DOM: it appends created elements to tempTag (or the
5377
+
* element referenced by tempTag if an id string is passed), may append a CSP meta
5378
+
* tag when header is present, and triggers domContentLoad() after insertion.
5379
+
*
5380
+
* @param {Object} value - JSON template describing the element and its children.
5381
+
* Keys and supported directives are documented above.
5382
+
* @param {HTMLElement|string} tempTag - Container element or the id of a container
5383
+
* to append generated content into.
5384
+
* @param {HTMLElement} [root] - Optional root element used for header processing;
5385
+
* defaults to tempTag when omitted.
5386
+
* @param {*} [id] - Optional identifier passed through to nested processing (unused
5387
+
* by most templates).
5388
+
* @returns {HTMLElement|undefined} The container element (tempTag as an HTMLElement)
5389
+
* after appending the generated content, or
5390
+
* undefined if required inputs are missing.
5365
5391
*/
5366
5392
functionmodala(value,tempTag,root,id){
5367
5393
if(typeof(tempTag)=="string"){
@@ -5798,6 +5824,21 @@ function fileOrder(elem) {
5798
5824
}
5799
5825
5800
5826
5827
+
/**
5828
+
* Parse an HTML string and convert the first top-level element into a JSON-like tree.
5829
+
*
5830
+
* The returned object represents the element structure with these fields:
5831
+
* - tagName: lower-cased tag name (e.g., "div")
5832
+
* - attributes: an object mapping attribute names to values
5833
+
* - children: an array of child nodes where element children are nested objects (same shape)
5834
+
* and text nodes are represented as { type: 'text', content: '...' }.
5835
+
*
5836
+
* Only the first child of the parsed document body is converted (i.e., the top-level element
5837
+
* produced by parsing `htmlString`). Empty text nodes are skipped.
5838
+
*
5839
+
* @param {string} htmlString - HTML markup to parse (must contain at least one top-level element).
5840
+
* @returns {{tagName: string, attributes: Object<string,string>, children: Array<Object>|Array>} A JSON-like representation of the first top-level element.
* Attaches global pipe listeners and processes CSV-for-each elements under a root node.
5891
+
*
5892
+
* Adds capturing listeners for 'click' and custom 'inline' events on the provided root element. When an event
5893
+
* targets an element that is eligible (has the 'mouse' class or an id) and hasn't already been wired, the element
5894
+
* is marked as having a pipe listener, passed through the `pipes` processor, and—if it has an `inline` attribute—
5895
+
* registered in `dotPipe.matrix` and executed via `dotPipe.runInline`.
5896
+
*
5897
+
* Additionally, scans for `<csv-foreach>` elements within the root and invokes `processCsvForeach` for any
5898
+
* unprocessed instances, marking them with the `processed` class to avoid duplicate work.
5899
+
*
5900
+
* @param {Document|Element} [rootElem=document] - Root node to attach listeners to and to scan for `<csv-foreach>` elements.
5901
+
*/
5839
5902
functionaddPipe(rootElem=document){
5840
5903
// Global listeners for clicks or custom 'inline' events
5841
5904
['click','inline'].forEach(eventType=>{
@@ -5898,7 +5961,15 @@ function addPipe(rootElem = document) {
5898
5961
// }
5899
5962
// });
5900
5963
5901
-
// }
5964
+
/**
5965
+
* Ensure an element has a click handler that invokes the pipe dispatcher and then triggers a DOM re-scan.
5966
+
*
5967
+
* Attaches a click listener to the provided element that calls pipes(elem). Attempts to remove a previous click listener first
5968
+
* (note: removal relies on identical function reference). After wiring the listener, calls domContentLoad(true) to reprocess
5969
+
* dynamic/custom tags within the document.
5970
+
*
5971
+
* @param {Element} elem - The DOM element to bind the click handler to; nothing is done if the element has no id.
5972
+
*/
5902
5973
5903
5974
functionflashClickListener(elem){
5904
5975
if(elem.id){
@@ -5952,6 +6023,22 @@ function sortNodesByName(selector) {
5952
6023
}
5953
6024
5954
6025
6026
+
/**
6027
+
* Execute a set of declarative UI actions described by an element's attributes and classes.
6028
+
*
6029
+
* Inspects the provided DOM element for dotPipe-specific attributes and class markers (e.g., `ajax`, `modal`, `inline`, `insert`, `query`, `headers`, `download`, `clear-node`, `turn`, `x-toggle`, `set`, `get`, `remove`, carousel controls, redirect, etc.) and performs the corresponding side-effectful operations:
6030
+
* - Triggers registered callbacks and inline macros.
6031
+
* - Performs navigation/AJAX loads via `navigate` for `ajax` attributes (supports multiple `file:target:limit` parts).
6032
+
* - Opens links or modals, starts/stops carousels, rotates lists, toggles classes, sets/removes attributes, clears or removes nodes, and initiates downloads.
6033
+
* - Parses `query` and `headers` attributes into request data used by AJAX navigation.
6034
+
* - Honors `disabled`, `clear-node`, and `redirect` semantics and returns early when appropriate.
6035
+
*
6036
+
* Most actions mutate the DOM, initiate network requests, or trigger other global behaviors; this function does not return a value.
6037
+
*
6038
+
* @param {Element} elem - The element whose attributes/classes define the actions to perform.
6039
+
* @param {boolean} [stop=false] - Reserved/unused in current implementation; callers may pass true to indicate higher-level flow control (no effect here).
6040
+
* @returns {void}
6041
+
*/
5955
6042
functionpipes(elem,stop=false){
5956
6043
5957
6044
varquery="";
@@ -6237,6 +6324,40 @@ function displayColoredJson(elementId, jsonObj) {
* Install event listeners and initialize per-root dynamic handlers for dotPipe elements.
5883
+
*
5884
+
* Attaches capture-phase listeners for "click" and custom "inline" events on the provided root (default: document).
5885
+
* When an event originates from an unprocessed element that either has class "mouse" or an id, this will:
5886
+
* - mark the element as having a pipe listener,
5887
+
* - invoke pipes(target) to perform standard pipe processing,
5888
+
* - if the element has an `inline` attribute, ensure a dotPipe.matrix entry for it and run dotPipe.runInline for that entry.
5889
+
*
5890
+
* Additionally scans the root for <csv-foreach> elements and runs processCsvForeach on any not already processed, marking them with the "processed" class.
5891
+
*
5892
+
* Note: This function mutates global state (adds listeners, updates dotPipe.matrix, and may fetch/insert content via pipes/runInline).
5893
+
*
5894
+
* @param {Element|Document} [rootElem=document] - Root element under which listeners are attached and child custom tags are initialized.
5895
+
*/
5839
5896
functionaddPipe(rootElem=document){
5840
5897
// Global listeners for clicks or custom 'inline' events
5841
5898
['click','inline'].forEach(eventType=>{
@@ -5898,7 +5955,14 @@ function addPipe(rootElem = document) {
5898
5955
// }
5899
5956
// });
5900
5957
5901
-
// }
5958
+
/**
5959
+
* Ensure an element runs the pipe processing on click and refreshes dotPipe processing.
5960
+
*
5961
+
* If the provided element has an `id`, a click listener is attached that calls `pipes(elem)` when clicked.
5962
+
* After (re)binding, `domContentLoad(true)` is invoked to (re)process dotPipe-supported elements.
5963
+
*
5964
+
* @param {HTMLElement} elem - The target element; must be a DOM element (typically with an `id`) to receive the click binding.
5965
+
*/
5902
5966
5903
5967
functionflashClickListener(elem){
5904
5968
if(elem.id){
@@ -5952,6 +6016,24 @@ function sortNodesByName(selector) {
5952
6016
}
5953
6017
5954
6018
6019
+
/**
6020
+
* Process a custom dotPipe element and perform its configured actions (AJAX loads, navigation, modal rendering, DOM mutations, downloads, carousel controls, toggles, attribute ops, etc.).
6021
+
*
6022
+
* This inspects attributes and classes on the provided element and executes the corresponding behavior:
6023
+
* - Triggers callback functions named by the `callback` attribute.
6024
+
* - Performs navigation/AJAX loads when `ajax` is present (may call `navigate` or create cloned loaders).
6025
+
* - Opens links for `<lnk>` elements, triggers downloads for elements with class `download`.
6026
+
* - Handles modal lists via `modal` and carousel controls / stepping via carousel-related classes.
6027
+
* - Applies simple DOM operations driven by attributes: `display`, `turn`, `x-toggle`, `set`, `get`, `delete`, `remove`, `headers`, `query`, `form-class`, `file-order`, and `clear-node`.
6028
+
* - Invokes dotPipe inline macro registration/run when encountering inline content during `turn` processing.
6029
+
* - Early-returns for disabled elements or after actions that replace responsibility (e.g., carousel start, download, redirect).
6030
+
*
6031
+
* Note: The function mutates the DOM, may call global helpers (dotPipe, navigate, modalList, shiftFilesLeft/Right, carousel, fileOrder, etc.), and may change window.location. It does not return a value.
6032
+
*
6033
+
* @param {HTMLElement} elem - The element to process; expected to be a custom dotPipe tag or decorated element.
6034
+
* @param {boolean} [stop=false] - Optional flag (currently unused) reserved for future control of processing flow.
6035
+
* @returns {void}
6036
+
*/
5955
6037
functionpipes(elem,stop=false){
5956
6038
5957
6039
varquery="";
@@ -6237,6 +6319,28 @@ function displayColoredJson(elementId, jsonObj) {
* Send an AJAX request built from an element's `ajax` attribute and injects the response into the DOM.
6324
+
*
6325
+
* Builds a query string (optionally augmented by formAJAX when `classname` matches), encodes it,
6326
+
* applies AJAX options via setAJAXOpts, issues an XMLHttpRequest to the URL from the element's
6327
+
* `ajax` attribute, and handles the response according to classes on the element:
6328
+
* - `strict-json`: replaces document.body with the raw JSON response if it's valid JSON.
6329
+
* - `json`: pretty-prints JSON into the target `insert` element and calls domContentLoad.
6330
+
* - `text-html`: inserts response as HTML into the `insert` element.
6331
+
* - `plain-text`: inserts response as text into the `insert` element.
6332
+
* - `tree-view`: parses JSON and renders it via renderTree into the element with elem.id.
6333
+
* - `modala`: parses JSON and renders modala content into the element named by `insert`, supporting multi-box behavior.
6334
+
* - default: injects raw response into the `insert` element when no special class or callback is present.
6335
+
*
6336
+
* Side effects: performs network request, mutates DOM (inserts/replaces content), calls domContentLoad()
6337
+
* and flashClickListener(), and may log warnings for missing `insert` targets.
6338
+
*
6339
+
* @param {Element} elem - The source element containing attributes that control navigation (must have an `ajax` attribute; optional `insert`, and behavior-driving CSS classes).
6340
+
* @param {Map|Object|null} [opts=null] - AJAX option container passed to setAJAXOpts (method, headers, mode, etc.). If null, defaults are applied.
6341
+
* @param {string} [query=""] - Additional query string to append to the request URL (will be URI-encoded).
6342
+
* @param {string} [classname=""] - If non-empty, formAJAX(elem, classname) will be called and its output appended to the query string.
0 commit comments