<commit_before>'use strict';

// loadingScreen.js: display a loading screen until communication with Siad has been established.
// if an available daemon is not running on the host,
// launch an instance of siad using config.js.

const remote = require('electron').remote;
const IPCRenderer = require('electron').ipcRenderer;
const Siad = require('sia.js');
const config = IPCRenderer.sendSync('config', 'siad');
Siad.configure(config);

const overlay = document.getElementsByClassName('overlay')[0];
const overlayText = overlay.getElementsByClassName('centered')[0].getElementsByTagName('p')[0];
overlayText.textContent = 'Loading Sia...';

const showError = function(error) {
	overlayText.textContent = 'A Sia-UI error has occured: ' + error;
};

// startUI starts a Sia UI instance using the given welcome message.
// calls initUI() after displaying a welcome message.
const startUI = function(welcomemsg, initUI) {
	// Display a welcome message, then initialize the ui
	overlayText.innerHTML = welcomemsg;
	initUI();
	overlay.style.display = 'none';
};

// startSiad configures and starts a Siad instance.
// callback is called on successful start.
const startSiad = function(callback) {
	Siad.configure(config, function(error) {
		if (error) {
			console.error(error);
			overlay.showError(error);
		} else {
			Siad.start(callback);
		}
	});
};

// Check if Siad is already running on this host.
// If it is, start the UI and display a welcome message to the user.
// Otherwise, start a new instance of Siad using config.js.
module.exports = function(initUI) {
	Siad.ifRunning(function() {
		config.detached = true;
		IPCRenderer.sendSync('config', 'siad', config);
		Siad.configure(config);
		startUI('Welcome back', initUI);
	}, function() {
		config.detached = false;
		IPCRenderer.sendSync('config', 'siad', config);
		startSiad(function(error) {
			if (error) {
				console.error(error);
			} else {
				startUI('Welcome to Sia', initUI);
			}<commit_msg>arrow functions<commit_after>'use strict';

// loadingScreen.js: display a loading screen until communication with Siad has been established.
// if an available daemon is not running on the host,
// launch an instance of siad using config.js.

const remote = require('electron').remote;
const IPCRenderer = require('electron').ipcRenderer;
const Siad = require('sia.js');
const config = IPCRenderer.sendSync('config', 'siad');
Siad.configure(config);

const overlay = document.getElementsByClassName('overlay')[0];
const overlayText = overlay.getElementsByClassName('centered')[0].getElementsByTagName('p')[0];
overlayText.textContent = 'Loading Sia...';

const showError = (error) => {
	overlayText.textContent = 'A Sia-UI error has occured: ' + error;
};

// startUI starts a Sia UI instance using the given welcome message.
// calls initUI() after displaying a welcome message.
const startUI = (welcomemsg, initUI) => {
	// Display a welcome message, then initialize the ui
	overlayText.innerHTML = welcomemsg;
	initUI();
	overlay.style.display = 'none';
};

// startSiad configures and starts a Siad instance.
// callback is called on successful start.
const startSiad = (callback) => {
	Siad.configure(config, (error) => {
		if (error) {
			console.error(error);
			overlay.showError(error);
		} else {
			Siad.start(callback);
		}
	});
};

// Check if Siad is already running on this host.
// If it is, start the UI and display a welcome message to the user.
// Otherwise, start a new instance of Siad using config.js.
module.exports = function(initUI) {
	Siad.ifRunning(() => {
		config.detached = true;
		IPCRenderer.sendSync('config', 'siad', config);
		Siad.configure(config);
		startUI('Welcome back', initUI);
	}, () => {
		config.detached = false;
		IPCRenderer.sendSync('config', 'siad', config);
		startSiad((error) => {
			if (error) {
				console.error(error);
			} else {
				startUI('Welcome to Sia', initUI);
			}
{'fraction_non_alphanumeric': 0.13285457809694792, 'fraction_numerical': 0.001538856116953065, 'mean_word_length': 4.4091539528432735, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '5692693', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1184, 'n_words': 364}