<commit_before>/* jslint node: true */
'use strict';

//	ENiGMA½
const MenuModule		= require('../core/menu_module.js').MenuModule;
const ViewController	= require('../core/view_controller.js').ViewController;
const ansi				= require('../core/ansi_term.js');
const theme				= require('../core/theme.js');
const FileEntry			= require('../core/file_entry.js');
const stringFormat		= require('../core/string_format.js');
const FileArea			= require('../core/file_base_area.js');
const Errors			= require('../core/enig_error.js').Errors;
const ErrNotEnabled		= require('../core/enig_error.js').ErrorReasons.NotEnabled;
const ArchiveUtil		= require('../core/archive_util.js');
const Config			= require('../core/config.js').config;
const DownloadQueue		= require('../core/download_queue.js');
const FileAreaWeb		= require('../core/file_area_web.js');
const FileBaseFilters	= require('../core/file_base_filter.js');
const resolveMimeType	= require('../core/mime_util.js').resolveMimeType;
const isAnsi			= require('../core/string_util.js').isAnsi;

//	deps
const async				= require('async');
const _					= require('lodash');
const moment			= require('moment');

exports.moduleInfo = {
	name	: 'File Area List',
	desc	: 'Lists contents of file an file area',
	author	: 'NuSkooler',
};

const FormIds = {
	browse			: 0,
	details			: 1,
	detailsGeneral	: 2,
	detailsNfo		: 3,
	detailsFileList	: 4,
};

const MciViewIds = {
	browse	: {
		desc				: 1,
		navMenu				: 2,

		customRangeStart	: 10,	//	10+ = customs
	},
	details	: {
		navMenu				: 1,
		infoXyTop			: 2,	//	%XY starting position for info area
		infoXyBottom		: 3,

		customRangeStart	: 10,	//	10+ = customs
	},
	detailsGeneral : {
		customRangeStart	: 10, //	10+ = customs
	},
	detailsNfo : {
		nfo		: 1,

		customRangeStart	: 10,	//	10+ = customs
	},
	detailsFileList : {
		fileList	: 1,

		customRangeStart	: 10,	//	10+ = customs
	},
};

exports.getModule = class FileAreaList extends MenuModule {

	constructor(options) {
		super(options);

		if(options.extraArgs) {
			this.filterCriteria	= options.extraArgs.filterCriteria;
			this.fileList		= options.fileList;
		}

		this.dlQueue = new DownloadQueue(this.client);

		if(!this.filterCriteria) {
			this.filterCriteria = FileBaseFilters.getActiveFilter(this.client);
		}

		if(_.isString(this.filterCriteria)) {
			this.filterCriteria = JSON.parse(this.filterCriteria);
		}

		if(_.has(options, 'lastMenuResult.value')) {
			this.lastMenuResultValue = options.lastMenuResult.value;
		}

		this.menuMethods = {
			nextFile : (formData, extraArgs, cb) => {		
				if(this.fileListPosition + 1 < this.fileList.length) {
					this.fileListPosition += 1;

					return this.displayBrowsePage(true, cb);	//	true=clerarScreen
				}

				return cb(null);
			},
			prevFile : (formData, extraArgs, cb) => {
				if(this.fileListPosition > 0) {
					--this.fileListPosition;

					return this.displayBrowsePage(true, cb);	//	true=clearScreen
				}

				return cb(null);
			},
			viewDetails : (formData, extraArgs, cb) => {
				this.viewControllers.browse.setFocus(false);
				return this.displayDetailsPage(cb);
			},
			detailsQuit : (formData, extraArgs, cb) => {
				this.viewControllers.details.setFocus(false);
				return this.displayBrowsePage(true, cb);	//	true=clearScreen
			},
			toggleQueue : (formData, extraArgs, cb) => {
				this.dlQueue.toggle(this.currentFileEntry);
				this.updateQueueIndicator();
				return cb(null);  
			},
			showWebDownloadLink : (formData, extraArgs, cb) => {
				return this.fetchAndDisplayWebDownloadLink(cb);
			},
			displayHelp : (formData, extraArgs, cb) => {
				return this.displayHelpPage(cb);
			}
		};
	}

	enter() {<commit_msg>Ensure VC's are detached when leaving details<commit_after>/* jslint node: true */
'use strict';

//	ENiGMA½
const MenuModule		= require('../core/menu_module.js').MenuModule;
const ViewController	= require('../core/view_controller.js').ViewController;
const ansi				= require('../core/ansi_term.js');
const theme				= require('../core/theme.js');
const FileEntry			= require('../core/file_entry.js');
const stringFormat		= require('../core/string_format.js');
const FileArea			= require('../core/file_base_area.js');
const Errors			= require('../core/enig_error.js').Errors;
const ErrNotEnabled		= require('../core/enig_error.js').ErrorReasons.NotEnabled;
const ArchiveUtil		= require('../core/archive_util.js');
const Config			= require('../core/config.js').config;
const DownloadQueue		= require('../core/download_queue.js');
const FileAreaWeb		= require('../core/file_area_web.js');
const FileBaseFilters	= require('../core/file_base_filter.js');
const resolveMimeType	= require('../core/mime_util.js').resolveMimeType;
const isAnsi			= require('../core/string_util.js').isAnsi;

//	deps
const async				= require('async');
const _					= require('lodash');
const moment			= require('moment');

exports.moduleInfo = {
	name	: 'File Area List',
	desc	: 'Lists contents of file an file area',
	author	: 'NuSkooler',
};

const FormIds = {
	browse			: 0,
	details			: 1,
	detailsGeneral	: 2,
	detailsNfo		: 3,
	detailsFileList	: 4,
};

const MciViewIds = {
	browse	: {
		desc				: 1,
		navMenu				: 2,

		customRangeStart	: 10,	//	10+ = customs
	},
	details	: {
		navMenu				: 1,
		infoXyTop			: 2,	//	%XY starting position for info area
		infoXyBottom		: 3,

		customRangeStart	: 10,	//	10+ = customs
	},
	detailsGeneral : {
		customRangeStart	: 10, //	10+ = customs
	},
	detailsNfo : {
		nfo		: 1,

		customRangeStart	: 10,	//	10+ = customs
	},
	detailsFileList : {
		fileList	: 1,

		customRangeStart	: 10,	//	10+ = customs
	},
};

exports.getModule = class FileAreaList extends MenuModule {

	constructor(options) {
		super(options);

		if(options.extraArgs) {
			this.filterCriteria	= options.extraArgs.filterCriteria;
			this.fileList		= options.fileList;
		}

		this.dlQueue = new DownloadQueue(this.client);

		if(!this.filterCriteria) {
			this.filterCriteria = FileBaseFilters.getActiveFilter(this.client);
		}

		if(_.isString(this.filterCriteria)) {
			this.filterCriteria = JSON.parse(this.filterCriteria);
		}

		if(_.has(options, 'lastMenuResult.value')) {
			this.lastMenuResultValue = options.lastMenuResult.value;
		}

		this.menuMethods = {
			nextFile : (formData, extraArgs, cb) => {		
				if(this.fileListPosition + 1 < this.fileList.length) {
					this.fileListPosition += 1;

					return this.displayBrowsePage(true, cb);	//	true=clerarScreen
				}

				return cb(null);
			},
			prevFile : (formData, extraArgs, cb) => {
				if(this.fileListPosition > 0) {
					--this.fileListPosition;

					return this.displayBrowsePage(true, cb);	//	true=clearScreen
				}

				return cb(null);
			},
			viewDetails : (formData, extraArgs, cb) => {
				this.viewControllers.browse.setFocus(false);
				return this.displayDetailsPage(cb);
			},
			detailsQuit : (formData, extraArgs, cb) => {
				[ 'detailsNfo', 'detailsFileList', 'details' ].forEach(n => {
					const vc = this.viewControllers[n];
					if(vc) {
						vc.detachClientEvents();
					}
				});

				return this.displayBrowsePage(true, cb);	//	true=clearScreen
			},
			toggleQueue : (formData, extraArgs, cb) => {
				this.dlQueue.toggle(this.currentFileEntry);
				this.updateQueueIndicator();
				return cb(null);  
			},
			showWebDownloadLink : (formData, extraArgs, cb) => {
				return this.fetchAndDisplayWebDownloadLink(cb);
			},
			displayHelp : (formData, extraArgs, cb) => {
				return this.displayHelpPage(cb);
			}
		};
	}

	enter() {
{'fraction_non_alphanumeric': 0.15296316070475174, 'fraction_numerical': 0.009343299519487454, 'mean_word_length': 3.4922062350119902, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5734506', 'n_tokens_mistral': 3041, 'n_tokens_neox': 2615, 'n_words': 472}