<commit_before><script>
  (function() {
    // ################################

    var updateReadyInterval;
    var updatingFired;
    var downloadingInterval;
    var obsoleteInterval;
    var cleanUpTimer;

    applicationCache.addEventListener('updateready', onUpdateReadyEvent);
    applicationCache.addEventListener('cached', onInstalledEvent);
    applicationCache.addEventListener('obsolete', onObsoleteEvent);

    applicationCache.addEventListener('downloading', onDownloadingEvent);
    applicationCache.addEventListener('progress', onDownloadingEvent);

    switch (applicationCache.status) {
      case applicationCache.DOWNLOADING: {
        setTimeout(onDownloadingEvent, 1);
      } break;
      case applicationCache.OBSOLETE: {
        setTimeout(onObsoleteEvent, 1);
      } break;
      case applicationCache.UPDATEREADY: {
        setTimeout(onUpdateReadyEvent, 1);
      } break;

      default: {
        downloadingInterval = setInterval(function() {
          if (applicationCache.status === applicationCache.DOWNLOADING) {
            onDownloadingEvent();
          }
        }, 50);

        obsoleteInterval = setInterval(function() {
          if (applicationCache.status === applicationCache.OBSOLETE) {
            onObsoleteEvent();
          }
        }, 50);

        updateReadyInterval = setInterval(function() {
          if (applicationCache.status === applicationCache.UPDATEREADY) {
            onUpdateReadyEvent();
          }
        }, 50);
      }
    }

    cleanUpTimer = setTimeout(function() {
      cleanUp();
    }, 5000);

    // ###############################

    function onDownloadingEvent() {
      if (!updatingFired) {
        updatingFired = true;
        onUpdating();
      }

      downloadingCleanUp();
    }

    function onUpdateReadyEvent() {
      if (!updatingFired) {
        updatingFired = true;
        onUpdating();
        setTimeout(onUpdateReady, 1);
      } else {
        onUpdateReady();
      }

      cleanUp();
    }

    function onInstalledEvent() {
      onInstalled();
      cleanUp();
    }

    function onObsoleteEvent() {
      onUpdateFailed();
      setTimeout(onUninstalled, 1);
      cleanUp();
    }

    function downloadingCleanUp() {
      if (downloadingInterval) {
        clearInterval(downloadingInterval);
        downloadingInterval = null;
      }

      applicationCache.removeEventListener('downloading', onDownloadingEvent);
      applicationCache.removeEventListener('progress', onDownloadingEvent);
    }

    function cleanUp() {
      if (cleanUpTimer) {
        clearTimeout(cleanUpTimer);
        cleanUpTimer = null;
      }

      downloadingCleanUp();

      applicationCache.removeEventListener('updateready', onUpdateReadyEvent);
      applicationCache.removeEventListener('cached', onInstalledEvent);
      applicationCache.removeEventListener('obsolete', onObsoleteEvent);

      if (updateReadyInterval) {
        clearInterval(updateReadyInterval);
        updateReadyInterval = null;
      }

      if (obsoleteInterval) {
        clearInterval(obsoleteInterval);
        obsoleteInterval = null;
      }
    }

    // ################################
  }());<commit_msg>don't unregister event listeners, fixes AppCache on iPhone/iPad/Safari when updates take longer than 5 seconds<commit_after><script>
  (function() {
    // ################################

    var updateReadyInterval;
    var updatingFired;
    var downloadingInterval;
    var obsoleteInterval;
    var cleanUpTimer;

    applicationCache.addEventListener('updateready', onUpdateReadyEvent);
    applicationCache.addEventListener('cached', onInstalledEvent);
    applicationCache.addEventListener('obsolete', onObsoleteEvent);

    applicationCache.addEventListener('downloading', onDownloadingEvent);
    applicationCache.addEventListener('progress', onDownloadingEvent);

    switch (applicationCache.status) {
      case applicationCache.DOWNLOADING: {
        setTimeout(onDownloadingEvent, 1);
      } break;
      case applicationCache.OBSOLETE: {
        setTimeout(onObsoleteEvent, 1);
      } break;
      case applicationCache.UPDATEREADY: {
        setTimeout(onUpdateReadyEvent, 1);
      } break;

      default: {
        downloadingInterval = setInterval(function() {
          if (applicationCache.status === applicationCache.DOWNLOADING) {
            onDownloadingEvent();
          }
        }, 50);

        obsoleteInterval = setInterval(function() {
          if (applicationCache.status === applicationCache.OBSOLETE) {
            onObsoleteEvent();
          }
        }, 50);

        updateReadyInterval = setInterval(function() {
          if (applicationCache.status === applicationCache.UPDATEREADY) {
            onUpdateReadyEvent();
          }
        }, 50);
      }
    }

    cleanUpTimer = setTimeout(function() {
      cleanUp();
    }, 5000);

    // ###############################

    function onDownloadingEvent() {
      if (!updatingFired) {
        updatingFired = true;
        onUpdating();
      }

      downloadingCleanUp();
    }

    function onUpdateReadyEvent() {
      if (!updatingFired) {
        updatingFired = true;
        onUpdating();
        setTimeout(onUpdateReady, 1);
      } else {
        onUpdateReady();
      }

      cleanUp();
    }

    function onInstalledEvent() {
      onInstalled();
      cleanUp();
    }

    function onObsoleteEvent() {
      onUpdateFailed();
      setTimeout(onUninstalled, 1);
      cleanUp();
    }

    function downloadingCleanUp() {
      if (downloadingInterval) {
        clearInterval(downloadingInterval);
        downloadingInterval = null;
      }
    }

    function cleanUp() {
      if (cleanUpTimer) {
        clearTimeout(cleanUpTimer);
        cleanUpTimer = null;
      }

      downloadingCleanUp();

      if (updateReadyInterval) {
        clearInterval(updateReadyInterval);
        updateReadyInterval = null;
      }

      if (obsoleteInterval) {
        clearInterval(obsoleteInterval);
        obsoleteInterval = null;
      }
    }

    // ################################
  }());
{'fraction_non_alphanumeric': 0.13035655871769708, 'fraction_numerical': 0.005070330389270527, 'mean_word_length': 2.6226303317535544, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 31, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6780031', 'n_tokens_mistral': 1633, 'n_tokens_neox': 1555, 'n_words': 264}