<commit_before>Lightbox = Class.create({
  initialize: function(formUrl, saveUrl, redirectUrl) {
    this.formUrl = formUrl;
    this.saveUrl = saveUrl;
    this.redirectUrl = redirectUrl;
    this.formData = "";
    this.loadedForms = new Object();
    this.lbinit();
    this.lbShow();
    this.lbLoadForm(formUrl);
  },

  lbShow: function() {
    this.lbLoading();
    toggleClass($('lb-bg'), 'hidden');
    toggleClass($('lb-align'), 'hidden');
    this.resizeBackground();
    if(browser.isIE6x) {
      $$('select').each(function(item) {
        if (item.up('#lb')) {
          return;
        }
        item._x_originalVisibility = item.style['visibility'];
        item.setStyle({visibility: 'hidden'});
      });
    }
  },

  lbHide: function() {
    toggleClass($('lb-bg'), 'hidden');
    toggleClass($('lb-align'), 'hidden');
    if(browser.isIE6x) {
      $$('select').each(function(item) {
        item.setStyle({visibility: item._x_originalVisibility});
      });
    }
  },

  lbLoading: function() {
    if(this.currentUrl) {
      this.loadedForms[this.currentUrl] = $('lb-content').firstChild.cloneNode(true);
    }
    $('lb-content').innerHTML = this.getWaiting();
  },

  lbLoadForm: function(url) {
    this.currentUrl = url;
    if(this.loadedForms[url]) {
      $('lb-content').innerHTML = '';
      this.lbPlaceContentInDocument(this.loadedForms[url], $('lb-content'));
      this.form = c.getElementsByTagName('form')[0];
    } else {
      new Ajax.Request(url, {onSuccess: this.lbFormDataLoaded.bind(this)});
    }
  },

  lbFormDataLoaded: function(transport) {
    var responseContent = document.createElement('div');
    responseContent.innerHTML = transport.responseText;
    $('lb-content').innerHTML = '';
    this.lbPlaceContentInDocument(responseContent, $('lb-content'), 
      function() {
        this.resizeBackground();
      }.bind(this)
    );
    this.form = $('lb-content').getElementsByTagName('form')[0];
  },

  /**
   * Some elements such as script elements are treated specially by the browser and not loaded if they are deep in a
   * DOM tree which is added to the document with Javascript.
   * However if each of these elements are placed in the tree individually, the loading works but execution must stop
   * while scripts are loading otherwise an inline script may be executed before a reference script which it depends on.
   * This function ends and is restarted by a callback each time a script is done loading.
   *
   * @param content A DOM node containing th econtent to place in the document.
   * @param whereToPlace A DOM node in the document inwhich to place the content.
   * @param onComplete A function to run when this is completely finished, note that this function will return before it
   *                   is complete, it will be restarted later by a callback.
   */
  lbPlaceContentInDocument: function(content, whereToPlace, onComplete) {
    // First clear already existing listeners because we will be firing a dom:loaded event for the 
    // benefit of listeners we may be adding.
    document.stopObserving('dom:loaded');

    var scripts = Array.from(content.getElementsByTagName('script'));
    // Opera doesn't render stylesheets unless we expressly place them.
    var links = Array.from(content.getElementsByTagName('link'));
    var styles = Array.from(content.getElementsByTagName('style'));
    var treatSpecially = links.concat(scripts, styles).flatten();

    // Clone all elements in treatSpecially and remove them from the content DOM tree.
    var clones = [];
    for (var i = 0; i < treatSpecially.length; i++) {
      clones[i] = document.createElement(treatSpecially[i].tagName);
      var attributes = treatSpecially[i].attributes;
      for(var j = 0; j < attributes.length; j++) {
        // In IE7 the attributes are there but are empty even if they aren't there.
        // and apparently IE refuses to parse content in a script element if there is a src attribute.
        if (attributes[j].value != "") {
          clones[i].setAttribute(attributes[j].name, attributes[j].value);
        }
      }
      try {
        clones[i].innerHTML = treatSpecially[i].innerHTML;<commit_msg>XWIKI-7061: Unable to add users to a group on IE9<commit_after>Lightbox = Class.create({
  initialize: function(formUrl, saveUrl, redirectUrl) {
    this.formUrl = formUrl;
    this.saveUrl = saveUrl;
    this.redirectUrl = redirectUrl;
    this.formData = "";
    this.loadedForms = new Object();
    this.lbinit();
    this.lbShow();
    this.lbLoadForm(formUrl);
  },

  lbShow: function() {
    this.lbLoading();
    toggleClass($('lb-bg'), 'hidden');
    toggleClass($('lb-align'), 'hidden');
    this.resizeBackground();
    if(browser.isIE6x) {
      $$('select').each(function(item) {
        if (item.up('#lb')) {
          return;
        }
        item._x_originalVisibility = item.style['visibility'];
        item.setStyle({visibility: 'hidden'});
      });
    }
  },

  lbHide: function() {
    toggleClass($('lb-bg'), 'hidden');
    toggleClass($('lb-align'), 'hidden');
    if(browser.isIE6x) {
      $$('select').each(function(item) {
        item.setStyle({visibility: item._x_originalVisibility});
      });
    }
  },

  lbLoading: function() {
    if(this.currentUrl) {
      this.loadedForms[this.currentUrl] = $('lb-content').firstChild.cloneNode(true);
    }
    $('lb-content').innerHTML = this.getWaiting();
  },

  lbLoadForm: function(url) {
    this.currentUrl = url;
    if(this.loadedForms[url]) {
      $('lb-content').innerHTML = '';
      this.lbPlaceContentInDocument(this.loadedForms[url], $('lb-content'));
      this.form = c.getElementsByTagName('form')[0];
    } else {
      new Ajax.Request(url, {onSuccess: this.lbFormDataLoaded.bind(this)});
    }
  },

  lbFormDataLoaded: function(transport) {
    var responseContent = document.createElement('div');
    responseContent.innerHTML = transport.responseText;
    $('lb-content').innerHTML = '';
    this.lbPlaceContentInDocument(responseContent, $('lb-content'), 
      function() {
        this.resizeBackground();
      }.bind(this)
    );
    this.form = $('lb-content').getElementsByTagName('form')[0];
  },

  /**
   * Some elements such as script elements are treated specially by the browser and not loaded if they are deep in a
   * DOM tree which is added to the document with Javascript.
   * However if each of these elements are placed in the tree individually, the loading works but execution must stop
   * while scripts are loading otherwise an inline script may be executed before a reference script which it depends on.
   * This function ends and is restarted by a callback each time a script is done loading.
   *
   * @param content A DOM node containing th econtent to place in the document.
   * @param whereToPlace A DOM node in the document inwhich to place the content.
   * @param onComplete A function to run when this is completely finished, note that this function will return before it
   *                   is complete, it will be restarted later by a callback.
   */
  lbPlaceContentInDocument: function(content, whereToPlace, onComplete) {
    // First clear already existing listeners because we will be firing a dom:loaded event for the 
    // benefit of listeners we may be adding.
    document.stopObserving('dom:loaded');

    var scripts = Array.from(content.getElementsByTagName('script'));
    // Opera doesn't render stylesheets unless we expressly place them.
    var links = Array.from(content.getElementsByTagName('link'));
    var styles = Array.from(content.getElementsByTagName('style'));
    var treatSpecially = links.concat(scripts, styles).flatten();

    // Clone all elements in treatSpecially and remove them from the content DOM tree.
    var clones = [];
    for (var i = 0; i < treatSpecially.length; i++) {
      clones[i] = document.createElement(treatSpecially[i].tagName);
      var attributes = treatSpecially[i].attributes;
      for(var j = 0; j < attributes.length; j++) {
        // In IE7 the attributes are there but are empty even if they aren't there.
        // and apparently IE refuses to parse content in a script element if there is a src attribute.
        if (attributes[j].value != "") {
          clones[i].setAttribute(attributes[j].name, attributes[j].value);
        }
      }
      try {
        var cloneContent = treatSpecially[i].innerHTML;
        if (cloneContent.startsWith('//<![CDATA[') && cloneContent.endsWith('//]]>')) {
          // IE drops the entire CDATA section when we set the inner HTML of the clone. In order to preserve the code we
          // have to unwrap it.
          cloneContent = cloneContent.substring(11, cloneContent.length - 5);
        }
        clones[i].innerHTML = cloneContent;
{'fraction_non_alphanumeric': 0.12596722803823396, 'fraction_numerical': 0.0025034137460172965, 'mean_word_length': 3.1575212866603595, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 4, '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': '7155646', 'n_tokens_mistral': 2513, 'n_tokens_neox': 2443, 'n_words': 730}