@@ -336,12 +336,12 @@ function renderTree(value, tempTag) {
336336 }
337337
338338 var temp = document . createElement ( value [ "tagname" ] || 'span' ) ;
339- temp . id = value [ "textContent" ] || value [ "label" ] || value . keyName ;
339+ temp . id = value [ "id" ] ;
340340 temp . classList . add ( 'tree-item' ) ;
341341
342- if ( value . icon ) {
342+ if ( value [ " icon" ] ) {
343343 let img = document . createElement ( 'img' ) ;
344- img . src = value . icon ;
344+ img . src = value [ " icon" ] ;
345345 img . style . marginRight = '5px' ;
346346 temp . appendChild ( img ) ;
347347 }
@@ -382,7 +382,75 @@ function renderTree(value, tempTag) {
382382
383383 return tempTag ;
384384}
385-
385+ // function renderTree(value, tempTag) {
386+ // if (typeof tempTag == "string") {
387+ // tempTag = document.getElementById(tempTag);
388+ // }
389+ // if (value == undefined) {
390+ // console.error("value of reference incorrect");
391+ // return;
392+ // }
393+
394+ // var temp = document.createElement(value["tagname"] || 'span');
395+ // temp.id = value["id"];
396+ // temp.classList.add('tree-item');
397+
398+ // // Create container for icon and text
399+ // const contentContainer = document.createElement('div');
400+ // contentContainer.style.display = 'flex';
401+ // contentContainer.style.alignItems = 'center';
402+ // contentContainer.style.gap = '5px';
403+
404+ // // Handle custom icon if specified
405+ // if (value["icon"]) {
406+ // const img = document.createElement('img');
407+ // img.src = value["icon"];
408+ // img.classList.add('tree-icon');
409+ // img.onerror = function () {
410+ // // Remove broken image if icon fails to load
411+ // this.remove();
412+ // };
413+ // contentContainer.appendChild(img);
414+ // }
415+
416+ // // Add text content
417+ // const textSpan = document.createElement('span');
418+ // textSpan.textContent = value.textContent || value.label;
419+ // contentContainer.appendChild(textSpan);
420+
421+ // temp.appendChild(contentContainer);
422+
423+ // // Check if item has children
424+ // const hasChildren = Object.entries(value).some(([k, v]) => v instanceof Object);
425+ // temp.setAttribute('data-has-children', hasChildren);
426+
427+ // Object.entries(value).forEach(([k, v]) => {
428+ // let keyName = (!isNaN(k.toString()) ? "data-" + k.toString() : k);
429+ // if (v instanceof Object) {
430+ // let subContainer = document.createElement('div');
431+ // subContainer.classList.add('sub-tree');
432+ // temp.appendChild(subContainer);
433+ // renderTree(v, subContainer);
434+ // temp.addEventListener('click', (e) => {
435+ // e.stopPropagation();
436+ // subContainer.style.display = subContainer.style.display === 'none' ? 'block' : 'none';
437+ // });
438+ // } else if (k.toLowerCase() != "tagname" && k.toLowerCase() != "textcontent" &&
439+ // k.toLowerCase() != "label" && k.toLowerCase() != "icon") {
440+ // temp.setAttribute(k, v);
441+ // }
442+ // });
443+
444+ // temp.addEventListener('click', (e) => {
445+ // e.stopPropagation();
446+ // document.querySelectorAll('.highlight').forEach(el => el.classList.remove('highlight'));
447+ // temp.classList.add('highlight');
448+ // pipes(temp);
449+ // });
450+
451+ // tempTag.appendChild(temp);
452+ // return tempTag;
453+ // }
386454/**
387455 * Recursively creates HTML elements based on a JSON object and appends them to the document head.
388456 *
@@ -1260,7 +1328,7 @@ function pipes(elem, stop = false) {
12601328 carousel ( elem , auto ) ;
12611329 return ;
12621330 }
1263- if ( elem . classList . contains ( "ajax-limit " ) ) {
1331+ if ( elem . hasAttribute ( "ajax" ) ) {
12641332 var parts = elem . getAttribute ( "ajax" ) . split ( ";" ) ;
12651333 parts . forEach ( ( part ) => {
12661334 var [ file , target , limit ] = part . split ( ":" ) ;
@@ -1325,20 +1393,22 @@ function formAJAX(elem, classname) {
13251393 // No, 'pipe' means it is generic. This means it is open season for all with this class
13261394 for ( var i = 0 ; i < document . getElementsByClassName ( classname ) . length ; i ++ ) {
13271395 var elem_value = document . getElementsByClassName ( classname ) [ i ] ;
1328- elem_qstring = elem_qstring + elem_value . name + "=" + elem_value . value + "&" ;
1329- // Multi-select box
13301396 if ( elem_value . hasOwnProperty ( "multiple" ) ) {
13311397 for ( var o of elem_value . options ) {
13321398 if ( o . selected ) {
1333- elem_qstring = elem_qstring + "&" + elem_value . getAttribute ( ' name' ) + "=" + o . getAttribute ( 'name' ) ;
1399+ elem_qstring = elem_qstring + elem_value . name + "=" + o . value + "&" ;
13341400 }
13351401 }
13361402 }
1403+ elem_qstring = elem_qstring + elem_value . name + "=" + elem_value . value + "&" ;
1404+ // Multi-select box
1405+
13371406 }
13381407 if ( elem . classList . contains ( "redirect" ) )
13391408 window . location . href = elem . getAttribute ( "ajax" ) + "?" + ( ( elem_qstring . length > 0 ) ? elem_qstring : "" ) ;
13401409 return ( elem_qstring ) ;
13411410}
1411+
13421412var pretty = 0 ;
13431413function prettifyJsonWithColors ( jsonObj ) {
13441414 const prettyJson = JSON . stringify ( jsonObj , null , 2 ) ;
@@ -1513,19 +1583,19 @@ function navigate(elem, opts = null, query = "", classname = "") {
15131583 insertElement . firstChild . remove ( ) ;
15141584 }
15151585 }
1516- var newContent = document . createElement ( 'div' ) ;
1517- modala ( allText , newContent ) ;
1586+ var newContent = elem . getAttribute ( "ajax" ) . split ( ':' ) [ 1 ] ?? elem . getAttribute ( "insert" ) ;
1587+ var newNode = document . createElement ( newContent ) ;
1588+ modala ( allText , newNode ) ;
15181589 domContentLoad ( )
15191590 flashClickListener ( elem ) ;
15201591 if ( elem . classList . contains ( "modala-multi-first" ) ) {
1521- insertElement . insertBefore ( newContent , insertElement . firstChild ) ;
1592+ insertElement . insertBefore ( newNode , insertElement . firstChild ) ;
15221593 } else {
1523- insertElement . appendChild ( newContent ) ;
1594+ insertElement . appendChild ( newNode ) ;
15241595 }
15251596 }
15261597 }
15271598 }
1528-
15291599 else if ( ! elem . classList . contains ( "json" ) && ! elem . hasAttribute ( "callback" ) ) {
15301600 rawFile . onreadystatechange = function ( ) {
15311601 if ( rawFile . readyState === 4 ) {
0 commit comments