More SRT subtitles

You can provide more SRT subtitles to let the users select the one they need.

<iframe id="video" width="100%" height="400" src="https://www.youtube.com/embed/fGPPfZIvtCw" frameborder="0" allowfullscreen="true"></iframe>
<select id="languages">
  <option value="en">English</option>
  <option value="hu">Hungarian</option>
</select>
<script src="static/vendor/youtube.external.subtitle/youtube.external.subtitle.js"></script>
<script src="static/vendor/subtitles-parser/subtitles.parser.js"></script>
<script>
  var loadSRT = function(url, callback) {
    var httpRequest = new XMLHttpRequest();

    httpRequest.onreadystatechange = function() {
      if (httpRequest.readyState === XMLHttpRequest.DONE) {
        var subtitles = parser.fromSrt(httpRequest.responseText, true);

        for (var i in subtitles) {
          subtitles[i] = {
            start : subtitles[i].startTime / 1000,
            end   : subtitles[i].endTime / 1000,
            text  : subtitles[i].text
          };
        }

        callback(subtitles);
      }
    };

    httpRequest.open('GET', url, true);
    httpRequest.send(null);
  };

  loadSRT('static/srt/kung_fu_panda_3_trailer.srt', function(subtitlesEn) {
    loadSRT('static/srt/kung_fu_panda_3_trailer_hu.srt', function(subtitlesHu) {
      var subtitles = {
        en: subtitlesEn,
        hu: subtitlesHu
      };

      var youtubeExternalSubtitle = new YoutubeExternalSubtitle.Subtitle(document.getElementById('video'), subtitles.en);

      document.getElementById('languages').addEventListener('change', function(e) {
        var language = this.value;

        youtubeExternalSubtitle.load(subtitles[language]);
      });
    });
  });
</script>