const checkManufacturer = function() { let man = 'unknown'; if (md.phone()) { man = md.phone(); } else if (md.tablet()) { man = md.tablet(); } return man.toLowerCase(); };
render() { const md = new MobileDetect(global.navigator.userAgent); const styles = require('./CommentsList.scss'); const comments = this.props.data; return ( <div> {md.phone() === null && this.props.notShowing > 0 && <LoadMoreComments count={this.props.notShowing} showAll={this.props.showAll} /> } <ul className={styles.comments}> {comments.slice(this.props.notShowing, comments.length).map((comment, i) => { return ( <Comment key={i} data={comment} react={this.props.react} /> ); })} </ul> </div> ); }
router.get('/', function(req, res) { var md = new MobileDetect(req.headers['user-agent']); if (md.phone()) { res.sendFile(path.join(__dirname, '../../phone.html')); return; } res.sendFile(path.join(__dirname, '../../desktop.html')); });
server.get('/', (req, res) => { const mobileDetect = new MobileDetect(req.headers['user-agent']); res.render('index', { main: ReactDOMServer.renderToString( <Main mobile={mobileDetect.phone() !== null} />) }); });
exports.notfound = function( req, res ) { var mobileDetect = new MobileDetect( req.headers[ 'user-agent' ] ); res.render( '404', { sharingInfo: {}, mobile: mobileDetect.mobile(), phone: mobileDetect.phone(), tablet: mobileDetect.tablet() } ); };
Promise.all( [ p1, p2, p3, p4, p5, p6, p7 ] ).then( function( values ) { var sharedSubmissionInfo = req.session.sharedSubmissionInfo; req.session.sharedSubmissionInfo = null; var props = { sharingInfo: getDefaultSharingInfo(), imageSubmissions: values[ 0 ], giphySubmissions: values[ 1 ], videoSubmissions: values[ 2 ], textSubmissions: values[ 3 ], tweetSubmissions: values[ 4 ], soundSubmissions: values[ 5 ], chatHistory: values[ 6 ], sharedSubmission: sharedSubmissionInfo }; if ( !isSpider ) { var mobileDetect = new MobileDetect( req.headers[ 'user-agent' ] ); props.mobile = mobileDetect.mobile(); props.phone = mobileDetect.phone(); props.tablet = mobileDetect.tablet(); var query = url.parse( req.url, true ).query; if ( query.debug === 'true' ) { props.debug = true; } if ( query.usegl === 'true' ) { props.usegl = true; } if ( query.usegl === 'false' || props.mobile || getBrowserName( req ) === 'IE' || getBrowserName( req ) === 'Firefox' ) { props.usegl = false; } if ( getBrowserName( req ) === 'IE' ) { props.ie = true; } if ( getBrowserName( req ) === 'Firefox' ) { props.ff = true; } } res.render( 'index', props ); } );
detect() { let md = new MobileDetect(window.navigator.userAgent) Env.desktop = false Env.mobile = !!md.mobile() Env.phone = !!md.phone() Env.tablet = !!md.tablet() Env.ios = (md.mobile() == 'iPhone' == true || md.tablet() == 'iPad' == true)?true:false // Detect IOS Safari const ios = this.iOSversion() if(typeof ios !== 'undefined') { Env.$html.classList.add(`ios${ios[0]}`) } if(md.mobile() == 'iPhone') { Env.$html.classList.add(`iphone`) } if(navigator.vendor === 'Apple Computer, Inc.') { Env.$html.classList.add(`safari`) } // if(Env.mobile == false) Env.desktop = true Env.ie11 = !!navigator.userAgent.match(/Trident\/7\./) if(Env.ie11 == true) Env.$html.classList.add('ie11') Env.edge = (window.navigator.userAgent.indexOf("Edge") > -1)?true:false if(Env.edge == true) Env.$html.classList.add('edge') Env.mobileCSS = false if((Env.tablet == true && (window.innerWidth < window.innerHeight)) || Env.phone == true) Env.mobileCSS = true Env.$html.classList.remove('desktop') Env.$html.classList.remove('tablet') Env.$html.classList.remove('mobile') if(Env.desktop == true) { Env.$html.classList.add('desktop') } if(Env.phone == true) { Env.$html.classList.add('mobile') } if(Env.tablet == true) { Env.$html.classList.add('tablet') } }
function devicize( req , options ){ var device, varsession = varSession(req), stored = varsession.get("devicize"); options = options || {"P":"P", "T":"T", "D":"D"}; if (stored) { device = stored; } else { var MobileDetect = require('mobile-detect'); var md = new MobileDetect(req.headers['user-agent']); device = md.phone() ? "P" : (md.tablet() ? "T":"D") varsession.set("devicize",device); } if (options.promise) return getPromise(device); else return options[device] || ""; }
function render( { data, props } ) { try { // Setting up static, global navigator object to pass user agent to material-ui. Since the function is synchronous, // it is OK to do so. global.navigator = { userAgent: req.headers[ 'user-agent' ] } // Also, set width to emulate phone, tablet or desktop const md = new MobileDetect( req.headers[ 'user-agent' ] ) let innerWidth if( md.phone( ) ) innerWidth = 700 // Will qualify as SMALL else if( md.tablet( ) ) innerWidth = 900 // Will qualify as MEDIUM else innerWidth = 1100 // Will qualify as LARGE global.window = { innerWidth: innerWidth } // Also set global location for the leftNav global.location = { pathname: req.originalUrl }; // Get the react output HTML const reactOutput = ReactDOMServer.renderToString( IsomorphicRouter.render(props) ); const helmet = Helmet.rewind( ); res.render( path.resolve( __dirname, 'renderOnServer.ejs' ), { preloadedData: JSON.stringify(data).replace(/\//g, '\\/'), assetsPath: assetsPath, reactOutput, title: helmet.title, meta: helmet.meta, link: helmet.link, isomorphicVars: isoVars, NODE_ENV: process.env.NODE_ENV, } ); } catch( err ) { serveFailure( 'error', res, 'renderOnServer render funcion failed', err ) } }
constructor(container) { this.container = container; this.md = new MobileDetect(window.navigator.userAgent); this.isMobile = (!!this.md.phone() || !!this.md.tablet()); }
import MobileDetect from 'mobile-detect'; const md = new MobileDetect(window.navigator.userAgent); module.exports = { facebookCode: '124712768157561', isCordova: !!window.isCordova, isPhone: md.phone(), smartsupp: 'ec822e14065c4cd2e91e7b4b63632849edd76247', kronoos: { hosts: [ 'kronoos', 'painel.kronoos.com' ] }, icheques: { hosts: [ 'icheques', 'painel.icheques.com.br' ] }, instantSearchDelay: 500, /* ms */ animatedShowTable: 300, hideAutocomplete: 300, iugu: { token: '44176a3c-50ec-4c45-b092-1d957813d22d' }, maps: 'AIzaSyDTl6qSuj1qFV6nh4tymwma-JeHl3pLnz0', oauthKey: 'AYY0iBNDo95aIcw--iWIqa71ZJs', checkoutUrl: 'https://irql.bipbop.com.br/api/checkout.html', googleAnalyticsId: 'UA-36688252-3', /* Universal Analytics */
// @flow import MobileDetect from 'mobile-detect'; /* Trivial case */ // $ExpectError MobileDetect.foo(); const detect = new MobileDetect(''); detect.mobile(); detect.mobileGrade(); detect.os(); detect.phone(); detect.tablet(); detect.userAgent(); detect.userAgents(); detect.version('Mobile'); detect.versionStr('Mobile'); // $ExpectError detect.foo();