<commit_before>ngapp.service('progressService', function($q) {
    let service = this,
        closed;

    // helper functions
    let hideFunctions = function() {
        try {
            window.alert = () => {};
            window.confirm = () => {};
            logger.addCallback('error', service.progressError);
        } catch(x) {}
    };

    let restoreFunctions = function() {
        try {
            window.alert = window.Constructor.prototype.alert;
            window.confirm = window.Constructor.prototype.confirm;
            logger.removeCallback('error', service.progressError);
        } catch(x) {}
    };

    // api functions
    this.showProgress = function(progress) {
        closed = $q.defer();
        hideFunctions();
        ipcRenderer.send('show-progress', progress);
    };

    this.hideProgress = function() {
        ipcRenderer.send('hide-progress');
        restoreFunctions();
    };

    this.logMessage = function(message, level = 0) {
        ipcRenderer.send('log-message', [message, level]);
    };

    this.progressMessage = function(message) {
        ipcRenderer.send('progress-message', message);
    };

    this.progressError = function(message) {
        ipcRenderer.send('progress-error', message);
    };

    this.addProgress = function(num) {
        ipcRenderer.send('add-progress', num);
    };

    this.progressTitle = function(title) {
        ipcRenderer.send('progress-title', title);
    };

    this.allowClose = function() {
        ipcRenderer.send('allow-close');
    };

    this.onProgressClosed = (callback) => closed.then(callback);

    ipcRenderer.on('progress-hidden', () => closed.resolve(true));
});

ngapp.run(function(interApiService, progressService) {
    interApiService.publish('zeditScripting', {
        LogMessage: progressService.logMessage,
        ProgressMessage: progressService.progressMessage,
        AddProgress: progressService.addProgress,
        ProgressTitle: progressService.progressTitle
    });
});<commit_msg>fixed progressService bugs<commit_after>ngapp.service('progressService', function($q) {
    let service = this,
        originalAlert = window.alert,
        originalConfirm = window.confirm,
        closed;

    // helper functions
    let hideFunctions = function() {
        try {
            window.alert = () => {};
            window.confirm = () => {};
            logger.addCallback('error', service.progressError);
        } catch(x) {}
    };

    let restoreFunctions = function() {
        try {
            window.alert = originalAlert;
            window.confirm = originalConfirm;
            logger.removeCallback('error', service.progressError);
        } catch(x) {}
    };

    // api functions
    this.showProgress = function(progress) {
        closed = $q.defer();
        hideFunctions();
        ipcRenderer.send('show-progress', progress);
    };

    this.hideProgress = function() {
        ipcRenderer.send('hide-progress');
    };

    this.logMessage = function(message, level = 0) {
        ipcRenderer.send('log-message', [message, level]);
    };

    this.progressMessage = function(message) {
        ipcRenderer.send('progress-message', message);
    };

    this.progressError = function(message) {
        ipcRenderer.send('progress-error', message);
    };

    this.addProgress = function(num) {
        ipcRenderer.send('add-progress', num);
    };

    this.progressTitle = function(title) {
        ipcRenderer.send('progress-title', title);
    };

    this.allowClose = function() {
        ipcRenderer.send('allow-close');
    };

    this.onProgressClosed = (callback) => closed.then(callback);

    ipcRenderer.on('progress-hidden', function() {
        closed.resolve(true);
        restoreFunctions();
    });
});

ngapp.run(function(interApiService, progressService) {
    interApiService.publish('zeditScripting', {
        LogMessage: progressService.logMessage,
        ProgressMessage: progressService.progressMessage,
        AddProgress: progressService.addProgress,
        ProgressTitle: progressService.progressTitle
    });
});
{'fraction_non_alphanumeric': 0.13714981729598053, 'fraction_numerical': 0.00048721071863581, 'mean_word_length': 2.61443661971831, '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': '5820797', 'n_tokens_mistral': 1112, 'n_tokens_neox': 1083, 'n_words': 173}