|
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | +<!DOCTYPE html> |
| 5 | + |
| 6 | + |
| 7 | +<html lang=en> |
| 8 | + |
| 9 | + <head> |
| 10 | + <meta charset=utf-8> |
| 11 | + |
| 12 | + <title> |
| 13 | + html component : |
| 14 | + </title> |
| 15 | + |
| 16 | + <meta name=description content=''> |
| 17 | + |
| 18 | + <base href='https://ext-code.com/html-components/list/dir-tree/'> |
| 19 | + <link rel=canonical href='https://ext-code.com/html-components/list/dir-tree/dir-tree.html'> |
| 20 | + |
| 21 | + <meta name=viewport content='width=device-width, initial-scale=1'> |
| 22 | + <link rel=icon href='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAMAAAAM7l6QAAAAaVBMVEVHcExfpvhYpPxapPtZo/lZpfxYpPtZpfxjp/Rxsv1ZpPpZpPtZpPpZpfxbpPheqPxcpvxorf1jqvxoputao/lbpPhmrP1ZpPtYo/tZo/hZpPtZpPqcyf+Rw/6Xxv+KwP6EvP53tf19uf1CLkbiAAAAHHRSTlMADp1YNLp7swf+YpU/wizc0vrpAiIX84VvHKlK4cmJ4wAAAVdJREFUKM+1ktmShCAMRVU2ARFxb5tF/f+PHIK92j1vM6myKuQYkns1y/4i8mEof6dlobX4hWHc09GtzfVSDZ/0qlvNg/Wr0SO7nOmlWb2zEN55Lj+WUsFat3O+ems3+g2HViLBuLfbdKaz8X5EkMnNBl2961tMsOuSanXr7N6iHOL+klqt3Y8r8yZuwRtGCCPyxgl3di0ODdrZYGgdA5H8wLXk1rUVpBQykeqY5Q/dcXgjajyNcfRNN2Z9P3TJbhKnB96OWzSHzzesCSGyThOjodEyeOxWpJZsEHioKcGxW4zc7LEzbCNv8KtoCit3SFwX40NLq7l+8wSRu3fEGLC7r/p07mDxYXl8gZ7RWBGKKXEcJ0GJzB8XFdH2SuESK/AAN5Ocri/2A5Yga5ZJ9+nPi7hk0FgBebr2xN2S8NJ9wxIhBZtShRCi5IRREQO2FpAUc5n9e/wA3jcXGxBAlmMAAAAASUVORK5CYII='> |
| 23 | + |
| 24 | + |
| 25 | + <script src='https://ajaxorg.github.io/ace-builds/src-noconflict/ace.js'></script> |
| 26 | + <script src='https://cdn.jsdelivr.net/npm/markdown-it/dist/markdown-it.min.js'></script> |
| 27 | + <link rel=stylesheet href='/css/github-markdown-light.css'> |
| 28 | + |
| 29 | + |
| 30 | + <script src='https://libs.ext-code.com/js/dom/component/v2.0/component.js?hdr'></script> |
| 31 | + |
| 32 | + <script> |
| 33 | + |
| 34 | + var df=true,did='html' |
| 35 | + ; |
| 36 | + |
| 37 | + var base = 'https://libs.ext-code.com/html/'; |
| 38 | + var component = 'dir-tree'; |
| 39 | + |
| 40 | + var ace; |
| 41 | + var md; |
| 42 | + var dirtree; |
| 43 | + var snippet; |
| 44 | + var editor; |
| 45 | + var log; |
| 46 | + |
| 47 | + |
| 48 | + async function init(){ |
| 49 | + console.log('init'); |
| 50 | + |
| 51 | + md = markdownit(); |
| 52 | + |
| 53 | + await load(); |
| 54 | + |
| 55 | + dirtree = mod['dir-tree']; |
| 56 | + snippet = mod['snippet-html-console']; |
| 57 | + editor = mod['web-editor']; |
| 58 | + log = mod['log-mod']; |
| 59 | + |
| 60 | + |
| 61 | + await mod.auto(); |
| 62 | + |
| 63 | + |
| 64 | + initdom(); |
| 65 | + |
| 66 | + |
| 67 | + }//init |
| 68 | + |
| 69 | + |
| 70 | + async function load(){ |
| 71 | + |
| 72 | + var {error,txt} = await get(base+component+'/readme.md'); |
| 73 | + |
| 74 | + if(error){ |
| 75 | + md_txt = error; |
| 76 | + }else{ |
| 77 | + md_txt = txt; |
| 78 | + } |
| 79 | + |
| 80 | + }//load |
| 81 | + |
| 82 | + |
| 83 | + </script> |
| 84 | + |
| 85 | + <style> |
| 86 | + |
| 87 | + |
| 88 | + html |
| 89 | + {height:100%;font-family:arial} |
| 90 | + |
| 91 | + |
| 92 | + body |
| 93 | + {/*height:calc(100% - 40px);*/display:flex;flex-direction:column;gap:20px;align-items:center;margin:20px;padding-bottom:200px} |
| 94 | + |
| 95 | + |
| 96 | + body>* |
| 97 | + {max-width:1400px;width:100%;padding:0 20px;} |
| 98 | + |
| 99 | + [component],config |
| 100 | + {display:none} |
| 101 | + |
| 102 | + input |
| 103 | + {font-size:16px;padding:5px 10px} |
| 104 | + input[type=button] |
| 105 | + {cursor:pointer} |
| 106 | + input[type=checkbox] |
| 107 | + {width:15px;height:15px;margin:0} |
| 108 | + |
| 109 | + |
| 110 | + #demo-tree |
| 111 | + {margin:20px 0;height:auto !important;overflow:visible;box-sizing:border-box;outline:none;border-radius:5px; |
| 112 | + border:none !important; |
| 113 | + /*border:1px solid lightgray !important;*/ |
| 114 | + } |
| 115 | + |
| 116 | + #view-hdr |
| 117 | + {padding:10px;font-weight:bold;background:rgba(173,216,230,0.5);border:1px solid lightgray;border-radius:5px} |
| 118 | + |
| 119 | + #view |
| 120 | + {border:1px solid lightgray;border-radius:5px;padding:10px} |
| 121 | + web-editor |
| 122 | + {} |
| 123 | + |
| 124 | + |
| 125 | + .wunderbaum .wb-expander |
| 126 | + {opacity:1 !important;transition:none !important} |
| 127 | + .wb-row |
| 128 | + {cursor:pointer} |
| 129 | + |
| 130 | + |
| 131 | + .icon |
| 132 | + {border:1px solid gray;border-radius:3px;box-sizing:border-box;width:30px;height:30px;cursor:pointer} |
| 133 | + .spc |
| 134 | + {flex:1;max-width:200px} |
| 135 | + |
| 136 | + |
| 137 | + </style> |
| 138 | + |
| 139 | + </head> |
| 140 | + |
| 141 | + <body> |
| 142 | + |
| 143 | + |
| 144 | + <html-components-hdr v2.0 component=grp1> |
| 145 | + <h2 class=title style='top:20px'>dir-tree</h2> |
| 146 | + <time slot=date datetime=2026-01-08>08 Jan 2026</time> |
| 147 | + </html-components-hdr> |
| 148 | + |
| 149 | + |
| 150 | + <div id=readme class=markdown-body></div> |
| 151 | + |
| 152 | + <hr> |
| 153 | + |
| 154 | + <section> |
| 155 | + |
| 156 | + <h3> |
| 157 | + files |
| 158 | + </h3> |
| 159 | + |
| 160 | + <dir-tree component></dir-tree> |
| 161 | + |
| 162 | + </section> |
| 163 | + |
| 164 | + <div id=view-hdr> |
| 165 | + </div> |
| 166 | + |
| 167 | + <div id=view style='display:none'> |
| 168 | + <snippet-html-console component></snippet-html-console> |
| 169 | + <web-editor component fullsize></web-editor> |
| 170 | + </div> |
| 171 | + |
| 172 | + |
| 173 | + <log-mod component></log-mod> |
| 174 | + |
| 175 | + </body> |
| 176 | + |
| 177 | + <script> |
| 178 | + |
| 179 | + |
| 180 | + var md_txt; |
| 181 | + var cache = {}; |
| 182 | + |
| 183 | + |
| 184 | + var callback = {}; |
| 185 | + var show = {}; |
| 186 | + |
| 187 | + |
| 188 | + |
| 189 | + var files = { |
| 190 | + 'source' : { |
| 191 | + 'latest' : null, |
| 192 | + }, |
| 193 | + 'examples' : { |
| 194 | + 'dir-tree-min.html' : null, |
| 195 | + 'dir-tree-simple.html' : null, |
| 196 | + }, |
| 197 | + }; |
| 198 | + |
| 199 | + |
| 200 | + |
| 201 | + //: |
| 202 | + |
| 203 | + |
| 204 | + async function initdom(){ |
| 205 | + debug('initdom'); |
| 206 | + |
| 207 | + var html = md.render(md_txt); |
| 208 | + $('#readme').innerHTML = html; |
| 209 | + |
| 210 | + |
| 211 | + var node = $('#demo-tree'); |
| 212 | + |
| 213 | + files = dirtree.build(files); |
| 214 | + dirtree.display(files,{callback}); |
| 215 | + |
| 216 | + |
| 217 | + await show.examples('dir-tree-min.html'); |
| 218 | + $('#view').style.display = ''; |
| 219 | + |
| 220 | + |
| 221 | + }//initdom |
| 222 | + |
| 223 | + |
| 224 | + //: |
| 225 | + |
| 226 | + |
| 227 | + callback.file = function(name,o){ |
| 228 | + |
| 229 | + var par = o.parent.name; |
| 230 | + debug(par,name); |
| 231 | + switch(par){ |
| 232 | + |
| 233 | + case 'source' : show.source(name); break; |
| 234 | + case 'examples' : show.examples(name); break; |
| 235 | + |
| 236 | + }//switch |
| 237 | + |
| 238 | + }//show |
| 239 | + |
| 240 | + |
| 241 | + show.source = async function(file){ |
| 242 | + |
| 243 | + $('#view-hdr').textContent = 'source : '+file; |
| 244 | + $('web-editor').style.display = ''; |
| 245 | + $('snippet-html-console').style.display = 'none'; |
| 246 | + |
| 247 | + var url = base+component+'/'; |
| 248 | + if(file=='latest'){ |
| 249 | + url += `${component}.html`; |
| 250 | + }else{ |
| 251 | + url += `${file}/${component}-${file}.html`; |
| 252 | + } |
| 253 | + |
| 254 | + var {txt} = await get(url); |
| 255 | + if(!txt)return; |
| 256 | + editor.setvalue(txt); |
| 257 | + editor.filename(file); |
| 258 | + |
| 259 | + }//source |
| 260 | + |
| 261 | + |
| 262 | + show.examples = async function(file){ |
| 263 | + |
| 264 | + $('#view-hdr').textContent = 'examples : '+file; |
| 265 | + $('web-editor').style.display = 'none'; |
| 266 | + $('snippet-html-console').style.display = ''; |
| 267 | + |
| 268 | + var url = base+component+'/examples/'+file; |
| 269 | + var {txt} = await get(url); |
| 270 | + if(!txt)return; |
| 271 | + |
| 272 | + snippet.editor.setvalue(txt); |
| 273 | + snippet.editor.filename(file); |
| 274 | + snippet.clear(); |
| 275 | + |
| 276 | + }//example |
| 277 | + |
| 278 | + |
| 279 | + async function get(url){ |
| 280 | + debug('get',url); |
| 281 | + if(cache[url]){ |
| 282 | + debug('cache'); |
| 283 | + return {txt:cache[url]}; |
| 284 | + } |
| 285 | + |
| 286 | + var err; |
| 287 | + try{ |
| 288 | + |
| 289 | + var res = await fetch(url); |
| 290 | + |
| 291 | + }//try |
| 292 | + catch(err2){ |
| 293 | + |
| 294 | + err = err2; |
| 295 | + |
| 296 | + }//catch |
| 297 | + if(err){ |
| 298 | + var error = err.toString(); |
| 299 | + log.red(error); |
| 300 | + return {error}; |
| 301 | + } |
| 302 | + if(!res.ok){ |
| 303 | + var error = await res.text(); |
| 304 | + log.red(error); |
| 305 | + return {error}; |
| 306 | + } |
| 307 | + |
| 308 | + var txt = await res.text(); |
| 309 | + cache[url] = txt; |
| 310 | + return {txt}; |
| 311 | + |
| 312 | + }//get |
| 313 | + |
| 314 | + |
| 315 | + |
| 316 | + |
| 317 | + |
| 318 | + |
| 319 | + </script> |
| 320 | + |
| 321 | +</html> |
| 322 | + |
| 323 | + |
0 commit comments