Dir tree

Developer
Size
3,169 Kb
Views
4,048

How do I make an dir tree?

What is a dir tree? How do you make a dir tree? This script and codes were developed by IEkiller on 18 January 2023, Wednesday.

Dir tree Previews

Dir tree - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>dir tree</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="wrap"></div> <script src='https://libs.baidu.com/jquery/1.9.0/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Dir tree - Script Codes CSS Codes

ul,li,dl,dt,dd{ list-style: none; margin:0; padding:0; } dl{ padding-left: 20px; } .wrap{ display: inline-block; } .wrap>dl{ background: #efefef; padding: 20px; } .wrap dt{ display: block; } dt{ position: relative; cursor: pointer; /*background: #999;*/ } b{ background: #999; } em{ font-style: normal; } dt:before{ content: '-'; width: 20px; text-align: center; display: inline-block; color:#990; font-size: 20px; position: absolute; left:-25px; } .isShow:before{ content: '+'; } .textmenu{ position: fixed; left: 0; top: 0; /*width: 100px;*/ border: 1px solid #999; box-shadow: 2px 2px 5px #666; padding:10px; display: none; background: #eee; } .textmenu a{ color: #666; text-decoration: none; font-size: 12px; } .menuItem{ padding: 2px; border-bottom: 1px dashed #aaa; cursor: pointer; } .menuItem.last{ border-bottom: 0; } .textFile{ cursor: default; } .textFile em{ color: #09c; }

Dir tree - Script Codes JS Codes

$(function(){ var data = [ { name: 'fma', data: [ { name: 'page', data: [ { name: 'layout', data: [ 'laout.tpl', 'lemt.tpl', 'ss', 'sadsad', { name: 'hehe', data: [ '111', '222', { name: 'hehe', data: [ '111', '222', { name: 'hehe', data: [ '111', '222' ] } ] } ] } ] } ] } ] }, { name: 'fuck', data: [] }, 'aaa.txt' ]; $('.wrap').on('click', 'dt', function(e){ $(this).next('dd').slideToggle(100); $(this).toggleClass('isShow'); // e.stopPropagation(); }); $('.wrap').on('contextmenu', 'b', function(e){ $('.textmenu').remove(); drawTextMenu(); $('.textmenu').css({'display':'block', 'left':e.clientX, 'top':e.clientY}); gLiName = $(this).find('em').text(); return false; }); $('.wrap').on('contextmenu', '.textFile', function(e){ $('.textmenu').remove(); drawTextMenu('file'); $('.textmenu').css({'display':'block', 'left':e.clientX, 'top':e.clientY}); gLiName = $(this).find('em').text(); return false; }); $('body').on('contextmenu', function(){ $('.textmenu').remove(); return false; }); $('body').on('click', '*', function(e){ $('.textmenu').remove(); }); $('body').on('click', '.textmenu li', function(){ var th = $(this).attr('_type'); switch(th){ case 'newFolder': delwithFile('folder'); break; case 'newFile': delwithFile('file'); break; case 'del': delFile(); break; default: break; } }); function drawList(){ var str = ''; var gLiName =''; fallback(data); function fallback(data){ str +='<dl>' if(data.length > 0){ for(var i=0, l=data.length; i<l; i++){ if( (typeof data[i]).toLowerCase() != 'string'){ str+='<dt><b><em>'+data[i].name+'</em></b></dt><dd>'; fallback(data[i].data); str +='</dd>' }else{ str +='<dd class="textFile"><em>'+data[i]+'</em></dd>'; } } }else{ str +='<dd>[null]</dd>'; } str +='</dl>' } // console.log(str); $('.wrap').html(str); } function drawTextMenu(type){ var str = ''; if(type !== 'file'){ str ='<li class="menuItem" _type="newFolder"><a href="javascript:;">新建文件夹</a></li>'+ '<li class="menuItem" _type="newFile"><a href="javascript:;">新建文件</a></li>'; } str += '<li class="menuItem last" _type="del"><a href="javascript:;">删除</a></li>'; $('body').append('<ul class="textmenu">'+ str + '</ul>'); } function delwithFile(type){ $('.textmenu').hide(); var strName = window.prompt(); if(!strName){ return false; } getName(data); function getName(da){ for(var i=0, l=da.length; i<l; i++){ if((typeof da[i]).toLowerCase() != 'string'){ if(da[i].name == gLiName){ if(type == 'folder'){ da[i].data.push({name:strName, data:[]}); }else if(type == 'file'){ da[i].data.push(strName); } drawList(); }else{ getName(da[i].data); } } } } } function delFile(){ $('.textmenu').hide(); getName(data); function getName(da){ for(var i=0, l=da.length; i<l; i++){ if(da[i] == gLiName || (!!da[i] && da[i].name == gLiName) ){ da.splice(i,1); drawList(); }else{ da[i] && da[i].data && getName(da[i].data); } } } } drawList();
})
Dir tree - Script Codes
Dir tree - Script Codes
Home Page Home
Developer IEkiller
Username win7killer
Uploaded January 18, 2023
Rating 3
Size 3,169 Kb
Views 4,048
Do you need developer help for Dir tree?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

IEkiller (win7killer) Script Codes
Create amazing web content with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!