<commit_before>// Requires
var gui = require('nw.gui');
var path = require('path');

var Q = require('q');
var _ = require('underscore');

// Port allocation
var qClass = require('qpatch').qClass;
var harbor = qClass(require('harbor'));
var ports = new harbor(19000, 20000);

// Local requires
var codebox = require('../../index.js');


// IDEs
var instances = {};
var windows = {};

// DOM elements
var $directorySelector = $('#directory-selector');
var $projectList = $('#projects');
var $btnOpen = $("#open-new");


// Local storage
var storageGet = function(key, def) {
    try {
        return JSON.parse(localStorage[key]);
    } catch(err) {
        return localStorage[key] || def;
    }
};
var storageSet = function(key, value) {
    localStorage[key] = JSON.stringify(value);
};


// Update list of projects
var updateProjects = function() {
    var projects = storageGet("projects");
    $projectList.empty();

    if (projects.length === 0) {
        $projectList.append($("<div>", {
            'class': "empty-message",
            'text': "No recent folders"
        }));
    }


    projects.reverse().forEach(function(path) {
        var $project = $("<li>", {
            'class': "project",
            "project": path
        });
        $("<img>", {
            'src': "icons/folder.png",
            'class': 'project-icon'
        }).appendTo($project);
        $("<p>", {
            'text': path.split("/").pop(),
            'class': 'project-title'
        }).appendTo($project);
        $("<p>", {
            'text': path,
            'class': 'project-path'
        }).appendTo($project);

        $projectList.append($project);
    });

    return projects.length > 0;
};

// Add a path to the projects list
var addProject = function(path) {
    var projects = storageGet("projects");

    if (projects.indexOf(path) >= 0) return;

    projects.push(path);
    storageSet("projects", projects);
    updateProjects();
};

// Select new project
var selectPath = function() {
    $directorySelector.click();
};

var openWindow = function(url) {
    if (windows[url]) {
        windows[url].focus();
        return;
    }

    var win = gui.Window.open(url, {
        'title': "Codebox",
        'position': 'center',
        'width': 1024,
        'height': 768,
        'min_height': 400,
        'min_width': 400,
        'show':true,
        'toolbar': false,
        'frame': true
    });
    windows[url] = win;

    win.on("close", function() {
        windows[url] = null;<commit_msg>Maximize IDE windows<commit_after>// Requires
var gui = require('nw.gui');
var path = require('path');

var Q = require('q');
var _ = require('underscore');

// Port allocation
var qClass = require('qpatch').qClass;
var harbor = qClass(require('harbor'));
var ports = new harbor(19000, 20000);

// Local requires
var codebox = require('../../index.js');


// IDEs
var instances = {};
var windows = {};

// DOM elements
var $directorySelector = $('#directory-selector');
var $projectList = $('#projects');
var $btnOpen = $("#open-new");


// Local storage
var storageGet = function(key, def) {
    try {
        return JSON.parse(localStorage[key]);
    } catch(err) {
        return localStorage[key] || def;
    }
};
var storageSet = function(key, value) {
    localStorage[key] = JSON.stringify(value);
};


// Update list of projects
var updateProjects = function() {
    var projects = storageGet("projects");
    $projectList.empty();

    if (projects.length === 0) {
        $projectList.append($("<div>", {
            'class': "empty-message",
            'text': "No recent folders"
        }));
    }


    projects.reverse().forEach(function(path) {
        var $project = $("<li>", {
            'class': "project",
            "project": path
        });
        $("<img>", {
            'src': "icons/folder.png",
            'class': 'project-icon'
        }).appendTo($project);
        $("<p>", {
            'text': path.split("/").pop(),
            'class': 'project-title'
        }).appendTo($project);
        $("<p>", {
            'text': path,
            'class': 'project-path'
        }).appendTo($project);

        $projectList.append($project);
    });

    return projects.length > 0;
};

// Add a path to the projects list
var addProject = function(path) {
    var projects = storageGet("projects");

    if (projects.indexOf(path) >= 0) return;

    projects.push(path);
    storageSet("projects", projects);
    updateProjects();
};

// Select new project
var selectPath = function() {
    $directorySelector.click();
};

var openWindow = function(url) {
    if (windows[url]) {
        windows[url].focus();
        return;
    }

    var win = gui.Window.open(url, {
        'title': "Codebox",
        'position': 'center',
        'width': 1024,
        'height': 768,
        'min_height': 400,
        'min_width': 400,
        'show':true,
        'toolbar': false,
        'frame': true
    });
    win.maximize();
    windows[url] = win;

    win.on("close", function() {
        windows[url] = null;
{'fraction_non_alphanumeric': 0.18282329713721618, 'fraction_numerical': 0.010266535044422508, 'mean_word_length': 2.402283411685695, 'pattern_counts': {'":': 2, '<': 13, '<?xml version=': 0, '>': 17, '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': '3670529', 'n_tokens_mistral': 1582, 'n_tokens_neox': 1500, 'n_words': 358}