<commit_before>var app = require("app");
var BrowserWindow = require("browser-window");
var Dialog = require("dialog");

var fs = require("fs");

var ipc = require("ipc");

var win = null;

app.on("window-all-closed", function() {
    app.quit();
});

app.on("ready", function() {
    win = new BrowserWindow({
        width: 1024,
        height: 600,
        frame: false,
        resizable: false
    });

    win.loadUrl("file://" + __dirname + "/browser/app.html");

    win.webContents.on("did-finish-load", function() {
        win.setTitle(app.getName());
    });

    win.on("closed", function() {
        win = null;
    });
});

ipc.on("gw2-find-path", function(event, knownPath) {    
    fs.exists(knownPath, function(knownPathStillValid) {
        if(knownPathStillValid) {
            console.log("known path: " + knownPath + " is valid");
            event.sender.send("gw2-find-path-reply", knownPath);

            return;
        }

        // TODO: this isn't OS X friendly yet
        // We don't know where the Gw2.exe is atm...
        // Maybe at the default location?
        var path = "C:\\Program Files (x86)\\Guild Wars 2\\Gw2.exe";

        fs.exists(path, function(executableExists) {
            if(executableExists) {
                console.log("path at default location found");
                event.sender.send("gw2-find-path-reply", path);

                return;
            }

            // Not at the default location... user needs to tell us him/herself where it is...
            Dialog.showMessageBox(win, {
                type: "info",
                title: "dynamics: Select Gw2.exe",
                buttons: ["Close"],
                message: "dynamics couldn't find your Guild Wars 2 executable (Gw2.exe). Please select it now!"
            });

            path = Dialog.showOpenDialog({
                title: "Select Gw2.exe",
                defaultPath: "C:\\Program Files (x86)\\",
                properties: ["openFile"],
                filters: [
                    {
                        name: "Executable",
                        extensions: ["exe"]
                    }
                ]
            });

            console.log("selected path: " + path);
            event.sender.send("gw2-find-path-reply", path);
        });
    });
});<commit_msg>made everything a bit more OS X friendly<commit_after>var app = require("app");
var BrowserWindow = require("browser-window");
var Dialog = require("dialog");

var fs = require("fs");

var ipc = require("ipc");

var packageJson = require("./package.json");

var win = null;

var osValues = {
    darwin: {
        executableName: "GuildWars2.app",
        defaultPath: "/Applications/GuildWars2.app",
        defaultSearchPath: "/Applications"
    },

    win32: {
        executableName: "Gw2.exe",
        defaultPath: "C:\\Program Files (x86)\\Guild Wars 2\\Gw2.exe",
        defaultSearchPath: "C:\\Program Files (x86)\\"
    }
}

app.on("window-all-closed", function() {
    app.quit();
});

app.on("ready", function() {
    win = new BrowserWindow({
        width: 1024,
        height: 600,
        frame: false,
        resizable: false
    });

    win.loadUrl("file://" + __dirname + "/browser/app.html");

    win.webContents.on("did-finish-load", function() {
        win.setTitle(app.getName());
    });

    win.on("closed", function() {
        win = null;
    });
});

ipc.on("gw2-find-path", function(event, knownPath) {
    fs.exists(knownPath, function(knownPathStillValid) {
        if(knownPathStillValid) {
            console.log("known path: " + knownPath + " is valid");
            event.sender.send("gw2-find-path-reply", knownPath);

            return;
        }

        var values = osValues[process.platform];

        // We don't know where the Gw2.exe is atm...
        // Maybe at the default location?
        var path = values.defaultPath;

        fs.exists(path, function(executableExists) {
            if(executableExists) {
                console.log("path at default location found");
                event.sender.send("gw2-find-path-reply", path);

                return;
            }

            // Not at the default location... user needs to tell us him/herself where it is...
            Dialog.showMessageBox(win, {
                type: "info",
                title: packageJson.name + ": Select " + values.executableName,
                buttons: ["Close"],
                message: packageJson.name + " couldn't find your Guild Wars 2 executable (" + values.executableName + "). Please select it now!"
            });

            path = Dialog.showOpenDialog({
                title: packageJson.name + ": Select " + values.executableName,
                defaultPath: values.defaultSearchPath,
                properties: ["openFile"],
                filters: [
                    {
                        name: "Executable",
                        extensions: ["exe"]
                    }
                ]
            });

            console.log("selected path: " + path);
            event.sender.send("gw2-find-path-reply", path);
        });
    });
});

ipc.on("gw2-add-account", function(event) {
});
{'fraction_non_alphanumeric': 0.14434180138568128, 'fraction_numerical': 0.009045419553502694, 'mean_word_length': 1.7628920786815523, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, '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': '3156583', 'n_tokens_mistral': 1551, 'n_tokens_neox': 1440, 'n_words': 333}