<commit_before>'use strict';
const app = require('app');
const fs = require('fs');
const path = require('path');
const ipc = require('ipc');
const BrowserWindow = require('browser-window');
const Menu = require('menu');
const appMenu = require('./menu');

// report crashes to the Electron project
require('crash-reporter').start();

// adds debug features like hotkeys for triggering dev tools and reload
require('electron-debug')();

let windows = [];
let settingsWindow = null;

function createTeamWindow(team) {
	const win = new BrowserWindow({
		title: team,
		'min-width': 800,
		'min-height': 600,
		'web-preferences': {
			// fails without this because of CommonJS script detection
			'node-integration': false
		}
	});

	win.loadUrl('https://' + team + '.hipchat.com');

	return win;
}

function createSettingsWindow() {
	settingsWindow = new BrowserWindow({
		title: app.getName(),
		width: 400,
		height: 300,
		show: false
	});

	settingsWindow.loadUrl('file://' + path.join(__dirname, 'settings.html'));
	settingsWindow.on('closed', function () {
		settingsWindow = null;
	});

	return settingsWindow;
}

function openAllTeamWindows(settings) {
	settings.teams.forEach(function(team, index){
		windows.push(createTeamWindow(team, index));
	});
}

app.on('window-all-closed', () => {
	if (process.platform !== 'darwin') {
		app.quit();
	}
});

app.on('ready', () => {
	Menu.setApplicationMenu(appMenu);

	const settingsFile = path.join(app.getPath('userData'), 'settings.json');

	// Default settings
	let settings = {
		teams: ['www']
	};

	fs.access(settingsFile, fs.F_OK, function (err) {
		// Create settings file if it doesn't exist.
		if (err) {
			fs.writeFileSync(settingsFile, JSON.stringify(settings), 'utf8');
		} else {
			let file = fs.readFileSync(settingsFile, 'utf8');
			settings = JSON.parse(file);
		}

		openAllTeamWindows(settings);

		settingsWindow = createSettingsWindow();
		settingsWindow.webContents.on('did-finish-load', function() {
			settingsWindow.webContents.send('settings-message', settings);
		});
		settingsWindow.show();

		ipc.on('settings-save', function (event, teams) {
			settings.teams = teams;
			fs.writeFileSync(settingsFile, JSON.stringify(settings), 'utf8');

			// Close all windows, and open them again. Not super clean but...
			settingsWindow.hide();
			windows.forEach(function (w) {
				w.close();
			});
			windows = [];
			openAllTeamWindows(settings);
		});
	});
});
<commit_msg>Reset window title<commit_after>'use strict';
const app = require('app');
const fs = require('fs');
const path = require('path');
const ipc = require('ipc');
const BrowserWindow = require('browser-window');
const Menu = require('menu');
const appMenu = require('./menu');

// report crashes to the Electron project
require('crash-reporter').start();

// adds debug features like hotkeys for triggering dev tools and reload
require('electron-debug')();

let windows = [];
let settingsWindow = null;

function createTeamWindow(team) {
	const win = new BrowserWindow({
		'min-width': 800,
		'min-height': 600,
		'web-preferences': {
			// fails without this because of CommonJS script detection
			'node-integration': false
		}
	});

	win.loadUrl('https://' + team + '.hipchat.com');
	win.webContents.on('did-finish-load', () => {
		win.setTitle(team);
	});

	return win;
}

function createSettingsWindow() {
	settingsWindow = new BrowserWindow({
		title: app.getName(),
		width: 400,
		height: 300,
		show: false
	});

	settingsWindow.loadUrl('file://' + path.join(__dirname, 'settings.html'));
	settingsWindow.on('closed', function () {
		settingsWindow = null;
	});

	return settingsWindow;
}

function openAllTeamWindows(settings) {
	settings.teams.forEach(function(team, index){
		windows.push(createTeamWindow(team, index));
	});
}

app.on('window-all-closed', () => {
	if (process.platform !== 'darwin') {
		app.quit();
	}
});

app.on('ready', () => {
	Menu.setApplicationMenu(appMenu);

	const settingsFile = path.join(app.getPath('userData'), 'settings.json');

	// Default settings
	let settings = {
		teams: ['www']
	};

	fs.access(settingsFile, fs.F_OK, function (err) {
		// Create settings file if it doesn't exist.
		if (err) {
			fs.writeFileSync(settingsFile, JSON.stringify(settings), 'utf8');
		} else {
			let file = fs.readFileSync(settingsFile, 'utf8');
			settings = JSON.parse(file);
		}

		openAllTeamWindows(settings);

		settingsWindow = createSettingsWindow();
		settingsWindow.webContents.on('did-finish-load', function() {
			settingsWindow.webContents.send('settings-message', settings);
		});
		settingsWindow.show();

		ipc.on('settings-save', function (event, teams) {
			settings.teams = teams;
			fs.writeFileSync(settingsFile, JSON.stringify(settings), 'utf8');

			// Close all windows, and open them again. Not super clean but...
			settingsWindow.hide();
			windows.forEach(function (w) {
				w.close();
			});
			windows = [];
			openAllTeamWindows(settings);
		});
	});
});

{'fraction_non_alphanumeric': 0.16767432486900444, 'fraction_numerical': 0.006045949214026602, 'mean_word_length': 4.382863340563992, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '429557', 'n_tokens_mistral': 1717, 'n_tokens_neox': 1538, 'n_words': 356}