<commit_before>/**
 * Created by JiaHao on 5/7/15.
 */

var ipc = require('ipc');

ipc.on('params', function(message) {

    var appArgs = JSON.parse(message);
    console.log(appArgs);
    document.title = appArgs.name;

    var webView = document.createElement('webview');

    webView.setAttribute('id', 'webView');
    webView.setAttribute('src', appArgs.targetUrl);
    webView.setAttribute('autosize', 'on');
    webView.setAttribute('minwidth', '100');
    webView.setAttribute('minheight', '100');

    webView.addEventListener('new-window', function(e) {
        require('shell').openExternal(e.url);
    });

    // We check for desktop notifications by listening to a title change in the webview
    // Not elegant, but it will have to do
    if (appArgs.badge) {
        webView.addEventListener('page-title-set', function(event) {
            ipc.send('notification-message', 'TITLE_CHANGED');
        });
    }

    var webViewDiv = document.getElementById('webViewDiv');
    webViewDiv.appendChild(webView);<commit_msg>Only set the title listener after the webview finishes loading<commit_after>/**
 * Created by JiaHao on 5/7/15.
 */

var ipc = require('ipc');

ipc.on('params', function(message) {

    var appArgs = JSON.parse(message);
    console.log(appArgs);
    document.title = appArgs.name;

    var webView = document.createElement('webview');

    webView.setAttribute('id', 'webView');
    webView.setAttribute('src', appArgs.targetUrl);
    webView.setAttribute('autosize', 'on');
    webView.setAttribute('minwidth', '100');
    webView.setAttribute('minheight', '100');

    webView.addEventListener('new-window', function(e) {
        require('shell').openExternal(e.url);
    });

    // We check for desktop notifications by listening to a title change in the webview
    // Not elegant, but it will have to do
    if (appArgs.badge) {
        webView.addEventListener('did-finish-load', function(e) {
            webView.addEventListener('page-title-set', function(event) {
                ipc.send('notification-message', 'TITLE_CHANGED');
            });
        });
    }

    var webViewDiv = document.getElementById('webViewDiv');
    webViewDiv.appendChild(webView);
{'fraction_non_alphanumeric': 0.1463525147258722, 'fraction_numerical': 0.009062075215224286, 'mean_word_length': 3.4248496993987976, 'pattern_counts': {'":': 0, '<': 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': '198802', 'n_tokens_mistral': 674, 'n_tokens_neox': 653, 'n_words': 140}