Commit 584ed43a authored by Remy Sharp's avatar Remy Sharp
Browse files

Detect iOS < 8 and remove step 2

parent d2e27279
......@@ -51,18 +51,11 @@ var uploadItButton = $('#upload-it-button');
var videoPreview = $('#video-preview');
var videoButton = $('#video-button');
var video = $('#video-preview video');
var uploadButtonText = $('#upload-it-button-text');
// Initial state of UI elements.
video.disabled = true;
on(video, 'error', function(err){
// Nothing to see here...
console.log(err);
// Will throw a MediaError code 4
console.log(video.error);
});
// I'd like to use .dataset but better coverage this way
videoPreview.setAttribute('data-disabled', true);
uploadItButton.disabled = true;
......@@ -74,6 +67,38 @@ messageDisplay.style.display = 'none';
// (RS: no, disabled isn't a video attribute)
video.src = '';
// RS: this breaks my heart a little...but it doesn't suprise me.
var crapiOS = (function () {
return true;
var ua = navigator.userAgent;
if (ua.indexOf('Mozilla/5.0 (iP') !== 0) {
return false;
}
// we're iOS based (iPad or iPhone), so let's continue...
// makes searching a little more consistent
ua = ua.replace(/ iPhone/ig, '');
if (ua.indexOf('CPU OS 8_') !== -1) {
// then we're iOS8, and it's okay, finally a decent OS...
return false;
}
// yep, I'm having to do full user agent sniffing. Reason: iOS7 (and below)
// support the fundamentals of what we're trying to do here, specifically
// blob support & video, AND YET, if you put a blob as a video's source,
// you can't actually play it. Seriously. Try it yourself: https://jsbin.com/giyope/2/
// So, we use stupid UA sniffing, and abort part of the UI due to crappy
// Apple iOS systems
return true;
})();
if (crapiOS) {
videoPreview.style.display = 'none';
uploadButtonText.innerHTML = '2. Upload it';
}
//
// Warn if a mobile browser cannot be detected. This doesn’t disable or
// change any functionality (we might be wrong) but it also will
......@@ -133,9 +158,6 @@ function previewVideo(file) {
//
var displayMessage = function(message) {
// var progressBar = document.getElementById('upload-progress');
// var messageDisplay = document.getElementById('message');
console.log('displayMessage: ' + message);
progressBar.style.display = 'none';
......@@ -155,13 +177,13 @@ uploadItButton.addEventListener('click', function(evt) {
// Show the progress
var uploadButtonText = document.getElementById('upload-it-button-text')
uploadButtonText.innerHTML = '3. Uploading…'
var step = crapiOS ? 2 : 3;
uploadButtonText.innerHTML = step + '. Uploading…'
progressBar.style.display = 'block';
var formData = new FormData();
var file = document.getElementById('video-upload').files[0];
var file = $('#video-upload').files[0];
//
// Check the file type and upload if correct and validate for 50MB limit.
......@@ -197,7 +219,7 @@ uploadItButton.addEventListener('click', function(evt) {
if (e.lengthComputable) {
var percentage = (e.loaded / e.total) * 100;
var uploadProgress = document.getElementById('upload-progress');
var uploadProgress = $('#upload-progress');
uploadProgress.value = percentage;
console.log('Upload progress: ' + percentage);
......@@ -217,10 +239,7 @@ uploadItButton.addEventListener('click', function(evt) {
//
// Reset and disable the Upload It button.
//
var uploadButtonText = document.getElementById('upload-it-button-text')
uploadButtonText.innerHTML = '3. Upload it'
var uploadItButton = document.getElementById('upload-it-button');
uploadButtonText.innerHTML = step + '. Upload it';
uploadItButton.disabled = true;
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment