<commit_before>'use strict';

const electron = require('electron');
const ipc = electron.ipcRenderer;
const webFrame = electron.webFrame;
const EnhancedNotification = require('../js/notification');

const UNREAD_COUNT_INTERVAL = 1000;

Notification = EnhancedNotification; // eslint-disable-line no-global-assign, no-native-reassign

Reflect.deleteProperty(global.Buffer); // http://electron.atom.io/docs/tutorial/security/#buffer-global

function isReactAppInitialized() {
  const reactRoot = document.querySelector('div[data-reactroot]');
  if (reactRoot === null) {
    return false;
  }
  return reactRoot.children.length !== 0;
}

function watchReactAppUntilInitialized(callback) {
  let count = 0;
  const interval = 500;
  const timeout = 30000;
  const timer = setInterval(() => {
    count += interval;
    if (isReactAppInitialized() || count >= timeout) { // assumed as webapp has been initialized.
      clearTimeout(timer);
      callback();
    }
  }, interval);
}

window.addEventListener('load', () => {
  if (document.getElementById('root') === null) {
    console.log('The guest is not assumed as mattermost-webapp');
    ipc.sendToHost('onGuestInitialized');
    return;
  }
  watchReactAppUntilInitialized(() => {
    ipc.sendToHost('onGuestInitialized');
  });
});

function hasClass(element, className) {
  var rclass = /[\t\r\n\f]/g;<commit_msg>Support React 16 of webapp for loading icon<commit_after>'use strict';

const electron = require('electron');
const ipc = electron.ipcRenderer;
const webFrame = electron.webFrame;
const EnhancedNotification = require('../js/notification');

const UNREAD_COUNT_INTERVAL = 1000;

Notification = EnhancedNotification; // eslint-disable-line no-global-assign, no-native-reassign

Reflect.deleteProperty(global.Buffer); // http://electron.atom.io/docs/tutorial/security/#buffer-global

function isReactAppInitialized() {
  const initializedRoot = document.querySelector('div[data-reactroot]') || document.querySelector('#root.channel-view');
  if (initializedRoot === null) {
    return false;
  }
  return initializedRoot.children.length !== 0;
}

function watchReactAppUntilInitialized(callback) {
  let count = 0;
  const interval = 500;
  const timeout = 30000;
  const timer = setInterval(() => {
    count += interval;
    if (isReactAppInitialized() || count >= timeout) { // assumed as webapp has been initialized.
      clearTimeout(timer);
      callback();
    }
  }, interval);
}

window.addEventListener('load', () => {
  if (document.getElementById('root') === null) {
    console.log('The guest is not assumed as mattermost-webapp');
    ipc.sendToHost('onGuestInitialized');
    return;
  }
  watchReactAppUntilInitialized(() => {
    ipc.sendToHost('onGuestInitialized');
  });
});

function hasClass(element, className) {
  var rclass = /[\t\r\n\f]/g;
{'fraction_non_alphanumeric': 0.14336158192090395, 'fraction_numerical': 0.01059322033898305, 'mean_word_length': 4.437619961612284, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '4648926', 'n_tokens_mistral': 860, 'n_tokens_neox': 840, 'n_words': 181}