<commit_before>/**
 * Represents a directory or a file in {HermesFileTree}
 * 
 * @class hermes.Node
 * @augments {enyo.Node}
 */

enyo.kind({
	name: "hermes.Node",
	kind: "Node",
	events: {
		onItemDown: "",
		onItemDragstart: "",
		onItemDragenter: "",
		onItemDragover: "",
		onItemDragleave: "",
		onItemDrop: "",
		onItemDragend: "",
		onFileClick: "",
		onFolderClick: "",
		onFileDblClick: "",
		onAdjustScroll: ""
	},
	published: {
		service: null,
		
		// allows subnodes to be draggable or not (not per default).
		dragAllowed: false
	},
	handlers: {
		ondown: "down",
		ondragstart: "dragstart",
		ondragenter: "dragenter",
		ondragover: "dragover",
		ondragleave: "dragleave",
		ondrop: "drop",
		ondragend: "dragend"
	},
	attributes: {
		dropTarget: "true"
	},
	
	// expandable nodes may only be opened by tapping the icon; tapping the content label
	// will fire the nodeTap event, but will not expand the node.
	onlyIconExpands: true,
	
	debug: false,
	
	/** @private */
	down: function(inSender, inEvent) {
		this.doItemDown(inEvent);
		return true;
	},
	/** @private */
	dragstart: function(inSender, inEvent) {
		if(!inEvent.dataTransfer) {
			return true;
		}
		
		this.doItemDragstart(inEvent);
		return true;
	},
	/** @private */
	dragenter: function(inSender, inEvent) {
		if (!inEvent.dataTransfer) {
			return true;
		}
		
		this.doItemDragenter(inEvent);
		return true;
	},
	/** @private */
	dragover: function(inSender, inEvent) {
		if (!inEvent.dataTransfer) {
			return true;
		}
		
		this.doItemDragover(inEvent);
		return true;
	},
	/** @private */
	dragleave: function(inSender, inEvent) {
		if (!inEvent.dataTransfer) {
			return true;
		}
		
		this.doItemDragleave(inEvent);
		return true;
	},
	/** @private */
	drop: function(inSender, inEvent) {
		if (!inEvent.dataTransfer) {
			return true;
		}
		
		this.doItemDrop(inEvent);
		return true;
	},
	/** @private */
	dragend: function(inSender, inEvent) {
		if (!inEvent.dataTransfer) {
			return true;
		}
		
		this.doItemDragend(inEvent);
		return true;
	},
	
	// Note: this function does not recurse
	updateNodes: function() {
		this.startLoading(this);
		if (this.debug) this.log(this) ;
		return this.service.listFiles(this.file && this.file.id)
			.response(this, function(inSender, inFiles) {
				var sortedFiles = inFiles.sort(this.fileNameSort) ;
				if (inFiles && !this.showing) {
					this.show();
				}

				if (this.debug) this.log("updating node content of ", this.name, this," with ", sortedFiles ) ;
				this.updateNodeContent(sortedFiles);
				this.render() ;
			})
			.response(this, function() {
				this.stopLoading();
			})
			.error(this, function() {
				this.stopLoading();
			})
			;
	},
	startLoading: function() {
		this.$.extra.setContent('&nbsp;<img src="' + enyo.path.rewrite("$services/assets/images/busy.gif") + '"/>');
	},
	stopLoading: function() {
		this.$.extra.setContent("");
	},
	updateNodeContent: function(files) {
		var i = 0, rfiles, tfiles, res, modified = 0, newControl, k = 0, nfiles;
		
		if (this.debug) this.log( "updateNodeContent on", this ) ;
<commit_msg>ENYO-1336: code cleaning<commit_after>/**
 * Represents a directory or a file in {HermesFileTree}
 * 
 * @class hermes.Node
 * @augments {enyo.Node}
 */

enyo.kind({
	name: "hermes.Node",
	kind: "Node",
	events: {
		onItemDown: "",
		onItemDragstart: "",
		onItemDragenter: "",
		onItemDragover: "",
		onItemDragleave: "",
		onItemDrop: "",
		onItemDragend: "",
		onFileClick: "",
		onFolderClick: "",
		onFileDblClick: "",
		onAdjustScroll: ""
	},
	published: {
		service: null,
		
		// allows subnodes to be draggable or not (not per default).
		dragAllowed: false
	},
	handlers: {
		ondown: "down",
		ondragstart: "dragstart",
		ondragenter: "dragenter",
		ondragover: "dragover",
		ondragleave: "dragleave",
		ondrop: "drop",
		ondragend: "dragend"
	},
	attributes: {
		dropTarget: "true"
	},
	
	// expandable nodes may only be opened by tapping the icon; tapping the content label
	// will fire the nodeTap event, but will not expand the node.
	onlyIconExpands: true,
	
	debug: false,
	
	/** @private */
	down: function(inSender, inEvent) {
		this.doItemDown(inEvent);
		return true;
	},
	/** @private */
	dragstart: function(inSender, inEvent) {
		if(!inEvent.dataTransfer) {
			return true;
		}
		
		this.doItemDragstart(inEvent);
		return true;
	},
	/** @private */
	dragenter: function(inSender, inEvent) {
		if (!inEvent.dataTransfer) {
			return true;
		}
		
		this.doItemDragenter(inEvent);
		return true;
	},
	/** @private */
	dragover: function(inSender, inEvent) {
		if (!inEvent.dataTransfer) {
			return true;
		}
		
		this.doItemDragover(inEvent);
		return true;
	},
	/** @private */
	dragleave: function(inSender, inEvent) {
		if (!inEvent.dataTransfer) {
			return true;
		}
		
		this.doItemDragleave(inEvent);
		return true;
	},
	/** @private */
	drop: function(inSender, inEvent) {
		if (!inEvent.dataTransfer) {
			return true;
		}
		
		this.doItemDrop(inEvent);
		return true;
	},
	/** @private */
	dragend: function(inSender, inEvent) {
		if (!inEvent.dataTransfer) {
			return true;
		}
		
		this.doItemDragend(inEvent);
		return true;
	},
	
	// Note: this function does not recurse
	updateNodes: function() {
		this.startLoading(this);
		if (this.debug) this.log(this) ;
		return this.service.listFiles(this.file && this.file.id)
			.response(this, function(inSender, inFiles) {
				var sortedFiles = inFiles.sort(this.fileNameSort) ;
				if (inFiles && !this.showing) {
					this.show();
				}

				if (this.debug) this.log("updating node content of ", this.name, this," with ", sortedFiles ) ;
				this.updateNodeContent(sortedFiles);
				this.render() ;
			})
			.response(this, function() {
				this.stopLoading();
			})
			.error(this, function() {
				this.stopLoading();
			})
			;
	},
	startLoading: function() {
		this.$.extra.setContent('&nbsp;<img src="' + enyo.path.rewrite("$services/assets/images/busy.gif") + '"/>');
	},
	stopLoading: function() {
		this.$.extra.setContent("");
	},
	updateNodeContent: function(files) {
		var i = 0, rfiles, tfiles, res, newControl, k = 0, nfiles;
		
		if (this.debug) this.log( "updateNodeContent on", this ) ;

{'fraction_non_alphanumeric': 0.1589253924583266, 'fraction_numerical': 0.0014565463667260074, 'mean_word_length': 3.50109249817917, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7032753', 'n_tokens_mistral': 2490, 'n_tokens_neox': 2196, 'n_words': 470}