<commit_before>// Here is the starting point for code of your own application.
// All stuff below is just to show you how it works. You can delete all of it.

// Modules which you authored in this project are intended to be
// imported through new ES6 syntax.
import { greet } from './hello_world/hello_world';

// Node.js modules and those from npm
// are required the same way as always.
var os = require('os');
var remote = require('remote');
var dialog = remote.require('dialog');
var app = remote.require('app');

var jetpack = require('fs-jetpack');
var Mustache = require('mustache');
window.jQuery = window.$ = require('jquery');
window.Hammer = require('hammerjs');

$(document).ready(() => {

    setup.render();
    !navigator.onLine ? setup.offlineModal() : null;

});

let project = {
    projectDir: null,
    npm: null,
    bower: null,
    composer: null,
    start: function(){

        this.checkManagerFiles() ? alert('Have same manager files !') :
            setup.noManagerFilesModal();

    },
    checkManagerFiles: function(){
        return !!(this.npm || this.bower || this.composer);
    }
};

const setup = {

    template: $('#setup').html(),

    name: localStorage.getItem('name'),

    setName: name => localStorage.setItem('name', name),

    render: function() {

        $('#target').html(Mustache.render(this.template));

        !navigator.onLine ? this.offlineChecker() :
            this.name ?  this.sayHello() : this.termsModal();

        $('#container').delay(500).fadeIn(1000);
        this.bindEvents();

    },

    bindEvents: function() {

        $('#btnDisagree').on('click', () => app.quit());

        $('#btnAgree').on('click',
            () => {
                $('#agreeModal').closeModal();
                this.nameModal();
            });

        $('#btnContinue').on('click',
            () => {
                $('#nameModal').closeModal();
                this.setName($('#firstName').val());
                this.sayHello();
            });

        $('#selectFolder').on('click', () => {
            setup.setProjectFolder();
            this.setManagerFiles();
            project.start();
        });

    },

    termsModal: function () {
        $('#agreeModal').openModal({
            dismissible: false
        });
    },

    nameModal: function() {
        $('#nameModal').openModal({
            dismissible: false
        });
    },

    offlineChecker: function(){

        $('#offline').openModal({
            dismissible: false
        });

        const check = setInterval(() => {
            console.log('Checking');
            if(navigator.onLine){
                $('#offline').closeModal();
                this.render();
                clearInterval(check);
            }
        }, 1000);

    },

    noManagerFilesModal: function(){
        $('#noManagerFiles').openModal();
    },

    sayHello: function() {

        const now = new Date();
        const hour = now.getHours();
        const greeting = hour < 12 ? 'morning' :
            hour >= 12 && hour <= 17 ? 'afternoon' :
                hour >= 12 && hour <= 17 ? 'evening' : 'job';

        const msg = name => `Hello ${name}, good ${greeting}! `;

        setTimeout(() => {
            Materialize.toast(msg(this.name), 2000, 'black-text white');
        }, 1000);

    },

    setProjectFolder: function(){
        project.projectDir = dialog.showOpenDialog(<commit_msg>Fix hello msg.<commit_after>// Here is the starting point for code of your own application.
// All stuff below is just to show you how it works. You can delete all of it.

// Modules which you authored in this project are intended to be
// imported through new ES6 syntax.
import { greet } from './hello_world/hello_world';

// Node.js modules and those from npm
// are required the same way as always.
var os = require('os');
var remote = require('remote');
var dialog = remote.require('dialog');
var app = remote.require('app');

var jetpack = require('fs-jetpack');
var Mustache = require('mustache');
window.jQuery = window.$ = require('jquery');
window.Hammer = require('hammerjs');

$(document).ready(() => {

    setup.render();
    !navigator.onLine ? setup.offlineModal() : null;

});

let project = {
    projectDir: null,
    npm: null,
    bower: null,
    composer: null,
    start: function(){

        this.checkManagerFiles() ? alert('Have same manager files !') :
            setup.noManagerFilesModal();

    },
    checkManagerFiles: function(){
        return !!(this.npm || this.bower || this.composer);
    }
};

const setup = {

    template: $('#setup').html(),

    name: localStorage.getItem('name'),

    render: function() {

        $('#target').html(Mustache.render(this.template));

        !navigator.onLine ? this.offlineChecker() :
            this.name ?  this.sayHello() : this.termsModal();

        $('#container').delay(500).fadeIn(1000);
        this.bindEvents();

    },

    bindEvents: function() {

        $('#btnDisagree').on('click', () => app.quit());

        $('#btnAgree').on('click',
            () => {
                $('#agreeModal').closeModal();
                this.nameModal();
            });

        $('#btnContinue').on('click',
            () => {
                $('#nameModal').closeModal();
                localStorage.setItem('name', $('#firstName').val());
                this.sayHello();
            });

        $('#selectFolder').on('click', () => {
            setup.setProjectFolder();
            this.setManagerFiles();
            project.start();
        });

    },

    termsModal: function () {
        $('#agreeModal').openModal({
            dismissible: false
        });
    },

    nameModal: function() {
        $('#nameModal').openModal({
            dismissible: false
        });
    },

    offlineChecker: function(){

        $('#offline').openModal({
            dismissible: false
        });

        const check = setInterval(() => {
            console.log('Checking');
            if(navigator.onLine){
                $('#offline').closeModal();
                this.render();
                clearInterval(check);
            }
        }, 1000);

    },

    noManagerFilesModal: function(){
        $('#noManagerFiles').openModal();
    },

    sayHello: function() {

        setTimeout(() => {

            const now = new Date();
            const hour = now.getHours();
            const greeting = hour < 12 ? 'morning' :
                hour >= 12 && hour <= 17 ? 'afternoon' :
                    hour >= 12 && hour <= 17 ? 'evening' : 'job';

            const msg = name => `Hello ${name}, good ${greeting}! `;

            Materialize.toast(msg(localStorage.getItem('name')), 2000, 'black-text white');

        }, 1000);

    },

    setProjectFolder: function(){
        project.projectDir = dialog.showOpenDialog(
{'fraction_non_alphanumeric': 0.16851311953352768, 'fraction_numerical': 0.008746355685131196, 'mean_word_length': 2.0766816143497757, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 24, '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': '6359516', 'n_tokens_mistral': 1980, 'n_tokens_neox': 1850, 'n_words': 434}