Skip to content
This repository was archived by the owner on Jun 3, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions device_detection.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@
tablet: new Deps.Dependency,
phone: new Deps.Dependency,
desktop: new Deps.Dependency,
bot: new Deps.Dependency
bot: new Deps.Dependency,
chromecast: new Deps.Dependency
}

this._suffix = {
tv: '_tv',
tablet: '_tablet',
phone: '_phone',
desktop: '_desktop',
bot: '_bot'
bot: '_bot',
chromecast: '_chromecast'
}

this.emptyUserAgentDeviceType = 'desktop';
Expand Down Expand Up @@ -56,6 +58,10 @@
this.setSuffix('bot', suffix);
}

Device.prototype.setChromecastSuffix = function(suffix) {
this.setSuffix('chromecast', suffix);
}

/*
* Getting Suffixes
*/
Expand Down Expand Up @@ -85,6 +91,10 @@
return getSuffix('bot');
}

Device.prototype.ChromecastSuffix = function() {
return getSuffix('chromecast');
}

/*
* Setting Preferences
*/
Expand Down Expand Up @@ -124,6 +134,10 @@
this.setPreference('bot');
}

Device.prototype.preferChromecast = function() {
this.setPreference('chromecast');
}

/*
* Getting Type
*/
Expand Down Expand Up @@ -157,6 +171,10 @@
return this.isType('bot');
};

Device.prototype.isChromecast = function() {
return this.isType('chromecast');
};

/*
* Automatically detect the type
* Run when code first executes, can be run again later.
Expand Down Expand Up @@ -209,9 +227,12 @@
} else if (ua.match(/Macintosh|PowerPC/i) && !ua.match(/Silk/i)) {
// if agent is Mac Desktop
return 'desktop';
} else if (ua.match(/Linux/i) && ua.match(/X11/i) && !ua.match(/Charlotte/i)) {
} else if (ua.match(/Linux/i) && ua.match(/X11/i) && !ua.match(/Charlotte/i) && !ua.match(/CrKey/i)) {
// if user agent is a Linux Desktop
return 'desktop';
} else if (ua.match(/Linux/i) && ua.match(/X11/i) && !ua.match(/Charlotte/i) && ua.match(/CrKey/i)) {
// if user agent is a Linux Desktop
return 'chromecast';
} else if (ua.match(/CrOS/)) {
// if user agent is a Chrome Book
return 'desktop';
Expand Down
3 changes: 3 additions & 0 deletions device_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ if (typeof UI !== 'undefined') {
UI.registerHelper('isBot', function() {
return Meteor.Device.isBot();
});
UI.registerHelper('isChromecast', function() {
return Meteor.Device.isChromecast();
});

UI.registerHelper('device_type', function() {
return Meteor.Device.type();
Expand Down