metamaps/metamaps

View on GitHub
app/assets/javascripts/homepageVimeoFallback.js.erb

Summary

Maintainability
Test Coverage
/* global $ */

$(document).ready(function() {
  if (window.location.pathname === '/') {
    $.ajax({
      type: 'GET',
      url: 'https://i.vimeocdn.com/video/',
      error: function(e) {
        $('.homeVideo').hide()
        $('.homeVideo').replaceWith($('<video/>', {
          poster: '<%= asset_path('metamaps-intro-poster.webp') %>',
          width: '560',
          height: '315',
          class: 'homeVideo',
          controls: ''
        }))
        $('.homeVideo').append($('<source/>', {
          src: 'https://metamaps.cc/videos/metamaps-intro.mp4',
          type: 'video/mp4'
        }))
        $('.homeVideo').append(
          '<p>You can watch our instruction video at ' +
          '<a href="https://metamaps.cc/videos/metamaps-intro.mp4">' +
          'https://metamaps.cc/videos/metamaps-intro.mp4</a>.'
        )
      }
    })
  }// if
})