Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const checkOSVersion = () => bowser.osversion;
const checkOSMajorVersion = () => parseInt(bowser.osversion, 10);
const checkBrowserVersion = () => bowser.version;
const checkBrowserMajorVersion = () => parseInt(bowser.version, 10);
const checkDevicePixelRatio = () => window.devicePixelRatio;
const checkFacebook = () => /fban|fbav/.test(ua);
const checkTwitter = () => /twitter/.test(ua);
const checkInstagram = () => /instagram/.test(ua);
const checkPinterest = () => /pinterest/.test(ua);
// Bot flags
const isBot = checkBot();
// OS flags
const isiOS = bowser.ios === true;
const isAndroid = bowser.android === true;
const isFirefoxOS = bowser.firefoxos === true;
const isWindowsPhone = bowser.windowsphone === true;
const isBlackberry = bowser.blackberry === true;
const isMac = bowser.mac === true;
const isWindows = bowser.windows === true;
const isLinux = bowser.linux === true;
const isChromeOS = bowser.chromeos === true;
// Device flags
const isPhone = bowser.mobile === true;
const isTablet = bowser.tablet === true;
const isMobile = isPhone || isTablet;
const isDesktop = !isMobile;
const isiPhone = isiOS && bowser.iphone === true;
const isiPad = isiOS && bowser.ipad === true;
const isiPod = isiOS && bowser.ipod === true;
var browser = require('bowser'),
debug = require('debug')('rtcninja'),
debugerror = require('debug')('rtcninja:ERROR'),
version = require('./version'),
Adapter = require('./Adapter'),
RTCPeerConnection = require('./RTCPeerConnection'),
// Internal vars.
called = false;
debugerror.log = console.warn.bind(console);
debug('version %s', version);
debug('detected browser: %s %s [mobile:%s, tablet:%s, android:%s, ios:%s]',
browser.name, browser.version, !!browser.mobile, !!browser.tablet,
!!browser.android, !!browser.ios);
// Constructor.
function rtcninja(options) {
// Load adapter
var iface = Adapter(options || {}); // jshint ignore:line
called = true;
// Expose RTCPeerConnection class.
rtcninja.RTCPeerConnection = RTCPeerConnection;
// Expose WebRTC API and utils.
rtcninja.getUserMedia = iface.getUserMedia;
rtcninja.mediaDevices = iface.mediaDevices;
function Adapter(options) {
// Chrome desktop, Chrome Android, Opera desktop, Opera Android, Android native browser
// or generic Webkit browser.
if (
(isDesktop && browser.chrome && browserVersion >= 32) ||
(browser.android && browser.chrome && browserVersion >= 39) ||
(isDesktop && browser.opera && browserVersion >= 27) ||
(browser.android && browser.opera && browserVersion >= 24) ||
(browser.android && browser.webkit && !browser.chrome && browserVersion >= 37) ||
(virtNavigator.webkitGetUserMedia && virtGlobal.webkitRTCPeerConnection)
) {
hasWebRTC = true;
getUserMedia = virtNavigator.webkitGetUserMedia.bind(virtNavigator);
mediaDevices = virtNavigator.mediaDevices;
RTCPeerConnection = virtGlobal.webkitRTCPeerConnection;
RTCSessionDescription = virtGlobal.RTCSessionDescription;
RTCIceCandidate = virtGlobal.RTCIceCandidate;
MediaStreamTrack = virtGlobal.MediaStreamTrack;
if (MediaStreamTrack && MediaStreamTrack.getSources) {
getMediaDevices = MediaStreamTrack.getSources.bind(MediaStreamTrack);
} else if (virtNavigator.getMediaDevices) {
getMediaDevices = virtNavigator.getMediaDevices.bind(virtNavigator);
function Adapter(options) {
// Chrome desktop, Chrome Android, Opera desktop, Opera Android, Android native browser
// or generic Webkit browser.
if (
(isDesktop && browser.chrome && browserVersion >= 32) ||
(browser.android && browser.chrome && browserVersion >= 39) ||
(isDesktop && browser.opera && browserVersion >= 27) ||
(browser.android && browser.opera && browserVersion >= 24) ||
(browser.android && browser.webkit && !browser.chrome && browserVersion >= 37) ||
(virtNavigator.webkitGetUserMedia && virtGlobal.webkitRTCPeerConnection)
) {
hasWebRTC = true;
getUserMedia = virtNavigator.webkitGetUserMedia.bind(virtNavigator);
RTCPeerConnection = virtGlobal.webkitRTCPeerConnection;
RTCSessionDescription = virtGlobal.RTCSessionDescription;
RTCIceCandidate = virtGlobal.RTCIceCandidate;
MediaStreamTrack = virtGlobal.MediaStreamTrack;
if (MediaStreamTrack && MediaStreamTrack.getSources) {
getMediaDevices = MediaStreamTrack.getSources.bind(MediaStreamTrack);
} else if (virtNavigator.getMediaDevices) {
getMediaDevices = virtNavigator.getMediaDevices.bind(virtNavigator);
}
function Adapter(options) {
// Chrome desktop, Chrome Android, Opera desktop, Opera Android, Android native browser
// or generic Webkit browser.
if (
(isDesktop && browser.chrome && browserVersion >= 32) ||
(browser.android && browser.chrome && browserVersion >= 39) ||
(isDesktop && browser.opera && browserVersion >= 27) ||
(browser.android && browser.opera && browserVersion >= 24) ||
(browser.android && browser.webkit && !browser.chrome && browserVersion >= 37) ||
(virtNavigator.webkitGetUserMedia && virtGlobal.webkitRTCPeerConnection)
) {
hasWebRTC = true;
getUserMedia = virtNavigator.webkitGetUserMedia.bind(virtNavigator);
mediaDevices = virtNavigator.mediaDevices;
RTCPeerConnection = virtGlobal.webkitRTCPeerConnection;
RTCSessionDescription = virtGlobal.RTCSessionDescription;
RTCIceCandidate = virtGlobal.RTCIceCandidate;
MediaStreamTrack = virtGlobal.MediaStreamTrack;
if (MediaStreamTrack && MediaStreamTrack.getSources) {
getMediaDevices = MediaStreamTrack.getSources.bind(MediaStreamTrack);
} else if (virtNavigator.getMediaDevices) {
getMediaDevices = virtNavigator.getMediaDevices.bind(virtNavigator);
adjustSize: function(){
var statusBarHeight = SS('#additional-notification-container').height() + 10;
if(browser.android){
_.debounce(function(){
// ToDo: find better way
var messagingAreaHeight = $('body').height() - SS('#messaging .col-header').height();
if(Settings.options.showTitlebar == false){
messagingAreaHeight = $('body').height();
}
var textBoxHeight = SS('#text-message-box-container').height();
SS('#additional-notification-container').css('bottom',textBoxHeight);
SS('#messaging-content').height(messagingAreaHeight);
SS('#messages').height(messagingAreaHeight - textBoxHeight - statusBarHeight);
playBTN.addEventListener ( "click", handlePlayToggle );
loopBTN.addEventListener ( "click", handleLoopToggle );
recordBTN.addEventListener ( "click", handleRecordToggle );
tempoSlider.addEventListener ( "input", handleTempoChange );
metronomeToggle.addEventListener( "click", handleMetronomeToggle );
settingsToggle.addEventListener ( "click", handleSettingsToggle );
currentPositionInput.addEventListener( "focus", handleCurrentPositionInteraction );
currentPositionInput.addEventListener( "change", handleCurrentPositionInteraction );
currentPositionInput.addEventListener( "blur", handleCurrentPositionInteraction );
document.querySelector( "#patternBack" ).addEventListener( "click", handlePatternNavBack );
document.querySelector( "#patternNext" ).addEventListener( "click", handlePatternNavNext );
// for desktop/laptop devices we enable record mode (for keyboard input)
// if a MIDI device is connected on a mobile device, it is enabled again
if ( !Bowser.ios && !Bowser.android )
recordBTN.classList.remove( "disabled" );
});
constructor(props: TooltipperProps, context: any) {
super(props, context);
this.state = {
isHovering: false,
mobile: bowser.ios || bowser.android || bowser.windowsphone,
};
}
function initSpeed_() {
if (!bowser.android) {
$root.addClass(CLASSES.SPEED_ENABLED);
$speedButtons.show();
}
}