Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Dependencies.
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;
export function isPushNotificationsSupported () {
if (Browser.ios || Browser.ipod || Browser.iphone || Browser.ipad)
return false;
if (Browser.msedge || Browser.msie)
return false;
/* Firefox on Android push notifications not supported until at least 48: https://bugzilla.mozilla.org/show_bug.cgi?id=1206207#c6 */
if (Browser.firefox && Number(Browser.version) < 48 && (Browser.mobile || Browser.tablet)) {
return false;
}
if (Browser.firefox && Number(Browser.version) >= 44)
return true;
if (Browser.safari && Number(Browser.version) >= 7.1)
return true;
// Android Chrome WebView
if (navigator.appVersion.match(/ wv/))
return false;
if (Browser.chrome && Number(Browser.version) >= 42)
return true;
// if current room changes to id, route to that room
// don't route if already there
// can only already be at this route if the app was loaded directly at this path (e.g. a user clicks a link to the room from their email)
const nextPath = `/room/${currentRoom}`;
if(!!currentRoom && window.location.pathname !== nextPath) {
browserHistory.push(nextPath);
}
}
});
// route configuration
export const routeConfig = [{
path: '/',
component: AppComponent,
indexRoute: {
component: (Browser.mobile || Browser.tablet) ?
HomeMobileComponent : HomeComponent,
},
onEnter: (nextState, replaceState) => {
analytics.page('home');
},
childRoutes: [{
path: '/room/:roomId',
component: RoomComponent,
onEnter: (nextState, replaceState, callback) => { // use a callback to make onEnter async
// subscribe to redux changes
let {users: {user}, rooms} = store.getState();
// if user logged in and new room, set current room
if(!!user && !user.loggingIn && (!rooms.current || rooms.current !== nextState.params.roomId)) {
store.dispatch(Actions.setCurrentRoom(nextState.params.roomId));
function isMobile () {
return bowser.mobile || bowser.tablet;
}
public set useNativeOnMobile(fallback:boolean) {
this._useNativeOnMobile = fallback;
const isOnMobile = bowser.mobile || bowser.tablet || isWebView(navigator.userAgent);
this.fallbackActive = this.useNativeOnMobile && isOnMobile;
}
imageUrl = '/bell/chrome-unblock.jpg';
}
else if (bowser.firefox)
imageUrl = '/bell/firefox-unblock.jpg';
else if (bowser.safari)
imageUrl = '/bell/safari-unblock.jpg';
else if (bowser.msedge)
imageUrl = '/bell/edge-unblock.png';
let instructionsHtml = '';
if (imageUrl) {
imageUrl = SdkEnvironment.getOneSignalApiUrl().origin + imageUrl;
instructionsHtml = `<a href="${imageUrl}"><img src="${imageUrl}"></a>`;
}
if ((bowser.mobile || bowser.tablet) && bowser.chrome) {
instructionsHtml = `<ol><li>Access <strong>Settings</strong> by tapping the three menu dots <strong>⋮</strong></li><li>Click <strong>Site settings</strong> under Advanced.</li><li>Click <strong>Notifications</strong>.</li><li>Find and click this entry for this website.</li><li>Click <strong>Notifications</strong> and set it to <strong>Allow</strong>.</li></ol>`;
}
contents = `<h1>${this.bell.options.text['dialog.blocked.title']}</h1><div class="divider"></div><div class="instructions"><p>${this.bell.options.text['dialog.blocked.message']}</p>${instructionsHtml}</div>${footer}`;
}
if (this.nestedContentSelector) {
addDomElement(this.nestedContentSelector, 'beforeend', contents);
}
if (this.subscribeButton) {
this.subscribeButton.addEventListener('click', () => {
/*
The welcome notification should only be shown if the user is
subscribing for the first time and resubscribing via the notify
button.
If permission is already granted, __doNotShowWelcomeNotification is
set to true to prevent showing a notification, but we actually want
const screenParam = getParameter("screen")
const resetPreferenceParam = getParameter("resetpref")
const forceCompatibilityWarningParam = getParameter("forcecompat")
this.serverUrl = serverUrlParam ? serverUrlParam : "http://circularrhythm.github.io/OfficialMusicServer"
this.debug = debugParam == "true"
this.musicList = null
this.localMusicList = []
this.localFileList = new Map()
this.preference = null
if(resetPreferenceParam) window.localStorage.removeItem("preference")
this.compatibilityWarning = []
if(!Bowser.chrome) this.compatibilityWarning.push("Incompatible browser is detected. Currently only Google Chrome is supported. The game may not work correctly in other browsers.")
if(Bowser.mobile && !Bowser.tablet) this.compatibilityWarning.push("Smartphone is detected. Playing this game with smartphones is discouraged.")
this.screenManager = new ScreenManager(this)
if(this.debug) {
if(forceCompatibilityWarningParam == "true") {
this.compatibilityWarning.push("Compatibility warning by debug parameter 1")
this.compatibilityWarning.push("Compatibility warning by debug parameter 2")
this.compatibilityWarning.push("Compatibility warning by debug parameter 3")
}
const testBmsonSetConfig = {
title: "TyTLE",
subtitle: "sub",
artist: "aRtjst",
subartists: ["sub"],
genre: "tesTgenre",
bpm: { initial: 125, min: 120, max: 150 },
const clientRequiresMarkdown = () => {
if (Meteor.isClient &&
window &&
window.navigator &&
window.navigator.userAgent) {
return (bowser.mobile || bowser.tablet)
}
return false
}