Skip to content

Instantly share code, notes, and snippets.

@zzggbb
Created October 17, 2014 04:21
Show Gist options
  • Select an option

  • Save zzggbb/738e72c94d099567a05b to your computer and use it in GitHub Desktop.

Select an option

Save zzggbb/738e72c94d099567a05b to your computer and use it in GitHub Desktop.
function create_file(file) {
return $('<li>').append($('<span>').attr('id','file').text(file));
}
function create_dir(dir) {
return $('<li>')
.append($('<span>').attr('id','dir').text(dir.name).click(function(){$(this).next().slideToggle()}))
.append($('<ul>')
.append(
dir.files.length > 0 ? dir.files.map(create_file) : null
).append(
dir.dirs.length > 0 ? dir.dirs.map(create_dir) : null
)
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment