<commit_before>// Foundation JavaScript
// Documentation can be found at: http://foundation.zurb.com/docs
$(document).foundation();

var io = new RocketIO().connect();

function filelist_expand_dir(entryElem, container) {
    $.getJSON("/api/lsdir/" + entryElem.dataset.path,
	      function(jsonData, status, jqxhr) {
		  container.empty()
		  for (var i = 0; i < jsonData.length; i++) {
		      var entry = jsonData[i];
		      var elem = $('<li>', {class: "js-filelist-" + entry.type});
		      var child_ul = $('<ul>');
		      var anch = $('<a>', {id: entry.id,
					   "data-path": entry.path,
					   "data-type": entry.type,
					   "data-name": entry.name,
					   text: entry.name,
					   class: "js-filelist-" + entry.type,
					   click: function(e){
					       if (e.target.dataset.type == "dir") {
						   filelist_expand_dir(e.target, $(e.target.nextSibling));
					       } else {
						   // filelist_open_file(e.target.dataset.path);
						   wm.create(e.target.dataset.path);
					       }
					   }});
		      var save_link = $('<a>', {href: "/save/" + entry.path})
		      save_link.append($('<img>', {src: "/assets/img/disk.png"}));

		      elem.append(anch);
		      if (entry.type != "dir") {
			  elem.append("&nbsp;");
			  elem.append(save_link);
		      }
		      elem.append(child_ul);<commit_msg>directory open/close action<commit_after>// Foundation JavaScript
// Documentation can be found at: http://foundation.zurb.com/docs
$(document).foundation();

var io = new RocketIO().connect();

function __filelist_click_handler_builder(jq_child_ul) {
    return function(e){
	if (e.target.dataset.type == "dir") {
	    if (e.target.dataset.opened == "false") {
		e.target.dataset.opened = "true";
		filelist_expand_dir(e.target, $(e.target.nextSibling));
	    } else {
		e.target.dataset.opened = "false";
		jq_child_ul.empty();
	    }
	} else {
	    // filelist_open_file(e.target.dataset.path);
	    wm.create(e.target.dataset.path);
	}
    };
}

function filelist_expand_dir(entryElem, container) {
    $.getJSON("/api/lsdir/" + entryElem.dataset.path,
	      function(jsonData, status, jqxhr) {
		  container.empty()
		  for (var i = 0; i < jsonData.length; i++) {
		      var entry = jsonData[i];
		      var elem = $('<li>', {class: "js-filelist-" + entry.type});
		      var child_ul = $('<ul>');
		      var anch = $('<a>', {id: entry.id,
					   "data-path": entry.path,
					   "data-type": entry.type,
					   "data-name": entry.name,
					   "data-opened": "false",
					   text: entry.name,
					   class: "js-filelist-" + entry.type,
					   click: __filelist_click_handler_builder(child_ul)});
		      var save_link = $('<a>', {href: "/save/" + entry.path})
		      save_link.append($('<img>', {src: "/assets/img/disk.png"}));

		      elem.append(anch);
		      if (entry.type != "dir") {
			  elem.append("&nbsp;");
			  elem.append(save_link);
		      }
		      elem.append(child_ul);
{'fraction_non_alphanumeric': 0.18547562222979885, 'fraction_numerical': 0.0006818956699624957, 'mean_word_length': 2.5650060753341433, 'pattern_counts': {'":': 7, '<': 15, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3343530', 'n_tokens_mistral': 1166, 'n_tokens_neox': 985, 'n_words': 184}