npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ember-device-detection

v1.0.2

Published

Ember device detection is an Ember addon for client-side device detection and a wrapper of the UA parser library. It makes it easy to render different views or url redirection based on device type, operating system, browser and media queries.

Downloads

2

Readme

ember-device-detection

Ember device detection is an Ember addon for client-side device detection and a wrapper of the UA parser library. It makes it easy to render different views or url redirection based on 4 device criteria:

and without needing special server-side configuration, saving the time and effort required to do user agent string parsing.

Philosophy

The idea behind a ember-device-detection is simple: As you build an mvp or prototyping an application, you might not implemented a browser or multi device compatibility yet. To avoid a bad user experience, it would be great to redirect a user if his/her device is not supported by your application yet. It can be a redirection to another page or serving a different html view. Thus, you avoid receiving hundreds of bugs caused by users entering your app with an incompatible device or browser.

Setup

ember install ember-device-detection

Usage

And add merely a <link> tag to your <head> section in your main index.html file :

  <link rel="alternate" criteria="value" href="url" id="id">

For example, it is how your index.html will look like:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Your app</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="alternate" href="https://qonto.eu/en/iphone" id="phone" os="ios">
  <link rel="alternate" href="/tablet.html" id="tablet" type="tablet">  
  <link rel="alternate" href="https://qonto.eu/en" id="phone" browser="chrome"> 
  <link rel="alternate" href="https://qonto.eu/en/other" id="phone" media="only screen and (max-device-width: 640px)">

  {{content-for "head"}}

  <link rel="stylesheet" href="{{rootURL}}assets/vendor.css">
  <link rel="stylesheet" href="{{rootURL}}assets/yourapp.css">

  {{content-for "head-footer"}}
</head>
<body>

  {{content-for "body"}}

  <script src="{{rootURL}}assets/vendor.js"></script>
  <script src="{{rootURL}}assets/yourapp.js"></script>

  {{content-for "body-footer"}}
</body>
</html>

~~ OR ~~

If you want to keep your index.html clean, in your app's ember-cli-build.js, define inlineContent options on your app instance

var app = new EmberApp(defaults, {
  inlineContent: {
    'device' : {
      content: '<link rel="alternate" href="https://qonto.eu/en/iphone" id="phone" os="ios">'
    }
  }
});

Then in your index.html file, use the content-for helper in your <head> tag with a references to the keys in your options:

  <!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Your app</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    
    {{content-for 'device'}}
    
    <link rel="stylesheet" href="{{rootURL}}assets/vendor.css">
    <link rel="stylesheet" href="{{rootURL}}assets/yourapp.css">

    {{content-for "head-footer"}}
  </head>
  <body>

    {{content-for "body"}}

    <script src="{{rootURL}}assets/vendor.js"></script>
    <script src="{{rootURL}}assets/yourapp.js"></script>

    {{content-for "body-footer"}}
  </body>

To learn more about this implementation, please visit ember-cli-inline-content

Operating system criteria

os attribute must match one of these value listed below:

  <link rel="alternate" os="value" href="url" id="id">
# Possible 'value'
AIX, Amiga OS, Android, Arch, Bada, BeOS, BlackBerry, CentOS, Chromium OS, Contiki,
Fedora, Firefox OS, FreeBSD, Debian, DragonFly, Gentoo, GNU, Haiku, Hurd, iOS, 
Joli, Linpus, Linux, Mac OS, Mageia, Mandriva, MeeGo, Minix, Mint, Morph OS, NetBSD, 
Nintendo, OpenBSD, OpenVMS, OS/2, Palm, PC-BSD, PCLinuxOS, Plan9, Playstation, QNX, RedHat, 
RIM Tablet OS, RISC OS, Sailfish, Series40, Slackware, Solaris, SUSE, Symbian, Tizen, 
Ubuntu, UNIX, VectorLinux, WebOS, Windows [Phone/Mobile], Zenwalk

Device type criteria

type attribute must match one of these value listed below:

  <link rel="alternate" type="value" href="url" id="id">
# Possible 'value'
console, mobile, tablet, smarttv, wearable, embedded

Browser criteria

browser attribute must match one of these value listed below:

  <link rel="alternate" browser="value" href="url" id="id">
# Possible 'value'
Amaya, Android Browser, Arora, Avant, Baidu, Blazer, Bolt, Bowser, Camino, Chimera, 
Chrome [WebView], Chromium, Comodo Dragon, Conkeror, Dillo, Dolphin, Doris, Edge, 
Epiphany, Fennec, Firebird, Firefox, Flock, GoBrowser, iCab, ICE Browser, IceApe, 
IceCat, IceDragon, Iceweasel, IE[Mobile], Iron, Jasmine, K-Meleon, Konqueror, Kindle, 
Links, Lunascape, Lynx, Maemo, Maxthon, Midori, Minimo, MIUI Browser, [Mobile] Safari, 
Mosaic, Mozilla, Netfront, Netscape, NetSurf, Nokia, OmniWeb, Opera [Mini/Mobi/Tablet], 
PhantomJS, Phoenix, Polaris, QQBrowser, RockMelt, Silk, Skyfire, SeaMonkey, Sleipnir, 
SlimBrowser, Swiftfox, Tizen, UCBrowser, Vivaldi, w3m, WeChat, Yandex

Media queries criteria

media queries attribute must match one of these value listed below:

  <link rel="alternate" media="value" href="url" id="id">
# Possible 'value'
only screen and (touch-enabled: 0),
only screen and (max-device-width: 640px),
only screen and (min-device-width: 641px,
...any valid media query type

Installation

  • git clone <repository-url> this repository
  • cd ember-device-detection
  • npm install

Running

Running Tests

  • npm test (Runs ember try:each to test your addon against multiple Ember versions)
  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit https://ember-cli.com/.