<commit_before>/**
 * @license
 * Copyright 2016 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * @fileoverview Shaka Player demo, main section.
 *
 * @suppress {visibility} to work around compiler errors until we can
 *   refactor the demo into classes that talk via public method.  TODO
 */


/** @suppress {duplicate} */
var shakaDemo = shakaDemo || {};  // eslint-disable-line no-var


/** @private {?HTMLOptGroupElement} */
shakaDemo.offlineOptGroup_ = null;


/** @private {boolean} */
shakaDemo.offlineOperationInProgress_ = false;


/**
 * @param {boolean} canHide True to hide the progress value if there isn't an
 *   operation going.
 * @private
 */
shakaDemo.updateButtons_ = function(canHide) {
  let assetList = document.getElementById('assetList');
  let inProgress = shakaDemo.offlineOperationInProgress_;

  document.getElementById('progressDiv').style.display =
      canHide && !inProgress ? 'none' : 'block';

  let option = assetList.options[assetList.selectedIndex];
  let storedContent = option.storedContent;
  // True if there is no DRM or if the browser supports persistent licenses for
  // any given DRM system.
  let supportsDrm = !option.asset || !option.asset.drm ||
      !option.asset.drm.length || option.asset.drm.some(function(drm) {
        return shakaDemo.support_.drm[drm] &&
            shakaDemo.support_.drm[drm].persistentState;
      });

  // Only show when the custom asset option is selected.
  document.getElementById('offlineNameDiv').style.display =
      option.asset ? 'none' : 'block';

  let button = document.getElementById('storeDeleteButton');
  button.disabled = (inProgress || !supportsDrm || option.isStored);
  button.innerText = storedContent ? 'Delete' : 'Store';
  let helpText = document.getElementById('storeDeleteHelpText');
  if (inProgress) {
    helpText.textContent = 'Operation is in progress...';
  } else if (!supportsDrm) {
    helpText.textContent = 'This browser does not support persistent licenses.';
  } else if (button.disabled) {
    helpText.textContent = 'The asset is stored offline. ' +
        'Checkout the "Offline" section in the "Asset" list';
  } else {
    helpText.textContent = '';
  }
};


/** @private */
shakaDemo.setupOffline_ = function() {
  document.getElementById('storeDeleteButton')
      .addEventListener('click', shakaDemo.storeDeleteAsset_);
  document.getElementById('assetList')
      .addEventListener('change', shakaDemo.updateButtons_.bind(null, true));<commit_msg>Fix offline button to use textContent<commit_after>/**
 * @license
 * Copyright 2016 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * @fileoverview Shaka Player demo, main section.
 *
 * @suppress {visibility} to work around compiler errors until we can
 *   refactor the demo into classes that talk via public method.  TODO
 */


/** @suppress {duplicate} */
var shakaDemo = shakaDemo || {};  // eslint-disable-line no-var


/** @private {?HTMLOptGroupElement} */
shakaDemo.offlineOptGroup_ = null;


/** @private {boolean} */
shakaDemo.offlineOperationInProgress_ = false;


/**
 * @param {boolean} canHide True to hide the progress value if there isn't an
 *   operation going.
 * @private
 */
shakaDemo.updateButtons_ = function(canHide) {
  let assetList = document.getElementById('assetList');
  let inProgress = shakaDemo.offlineOperationInProgress_;

  document.getElementById('progressDiv').style.display =
      canHide && !inProgress ? 'none' : 'block';

  let option = assetList.options[assetList.selectedIndex];
  let storedContent = option.storedContent;
  // True if there is no DRM or if the browser supports persistent licenses for
  // any given DRM system.
  let supportsDrm = !option.asset || !option.asset.drm ||
      !option.asset.drm.length || option.asset.drm.some(function(drm) {
        return shakaDemo.support_.drm[drm] &&
            shakaDemo.support_.drm[drm].persistentState;
      });

  // Only show when the custom asset option is selected.
  document.getElementById('offlineNameDiv').style.display =
      option.asset ? 'none' : 'block';

  let button = document.getElementById('storeDeleteButton');
  button.disabled = (inProgress || !supportsDrm || option.isStored);
  button.textContent = storedContent ? 'Delete' : 'Store';
  let helpText = document.getElementById('storeDeleteHelpText');
  if (inProgress) {
    helpText.textContent = 'Operation is in progress...';
  } else if (!supportsDrm) {
    helpText.textContent = 'This browser does not support persistent licenses.';
  } else if (button.disabled) {
    helpText.textContent = 'The asset is stored offline. ' +
        'Checkout the "Offline" section in the "Asset" list';
  } else {
    helpText.textContent = '';
  }
};


/** @private */
shakaDemo.setupOffline_ = function() {
  document.getElementById('storeDeleteButton')
      .addEventListener('click', shakaDemo.storeDeleteAsset_);
  document.getElementById('assetList')
      .addEventListener('change', shakaDemo.updateButtons_.bind(null, true));
{'fraction_non_alphanumeric': 0.11533377395902181, 'fraction_numerical': 0.0026437541308658294, 'mean_word_length': 3.8893376413570273, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1514882', 'n_tokens_mistral': 1738, 'n_tokens_neox': 1660, 'n_words': 528}