Created
November 5, 2018 14:47
-
-
Save Rhincodon/ea80338ca4fe6d329cf2b6b173ecfd46 to your computer and use it in GitHub Desktop.
presenter.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener("DOMContentLoaded", function () { | |
var CONFIG = { | |
FPVERSION: "9.0.0", | |
COURSE_WIDTH: "100%", | |
COURSE_HEIGHT: "100%", | |
TARGET: "PresenterContent", | |
SWFOBJ_NAME: 'Presenter', | |
REDIRECT_URL: "http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" | |
} | |
function swfLoadEvent(e, fn) { | |
//Ensure fn is a valid function | |
if(typeof fn !== "function"){ return false; } | |
//This timeout ensures we don't try to access PercentLoaded too soon | |
var initialTimeout = setTimeout(function (){ | |
//Ensure Flash Player's PercentLoaded method is available and returns a value | |
if(typeof e.ref.PercentLoaded !== "undefined" && typeof e.ref.PercentLoaded() === 'number'){ | |
//Set up a timer to periodically check value of PercentLoaded | |
var loadCheckInterval = setInterval(function (){ | |
//Once value == 100 (fully loaded) we can do whatever we want | |
if(e.ref.PercentLoaded() === 100){ | |
//Execute function | |
fn(); | |
//Clear timer | |
clearInterval(loadCheckInterval); | |
} | |
}, 1500); | |
} | |
}, 200); | |
} | |
function showFlash(swf) { | |
var el = document.getElementById("PresenterContent"); | |
var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); | |
if (window.chrome || isSafari) { | |
swfobject.ua.pv = [100, 0, 0]; | |
} | |
swfobject.embedSWF(swf, el, CONFIG.COURSE_WIDTH, CONFIG.COURSE_HEIGHT, CONFIG.FPVERSION, null, null, { | |
quality: 'high', | |
menu: 'false', | |
wmode: 'opaque', | |
AllowScriptAccess: 'always' | |
}, { | |
name: CONFIG.SWFOBJ_NAME, | |
redirectUrl: CONFIG.REDIRECT_URL | |
}, function (e) { | |
el.focus(); | |
swfLoadEvent(e, function() { | |
// Убираем Load класс с элемента с presenter | |
}); | |
}); | |
} | |
showFlash('viewer.swf'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment