Skip to content

Instantly share code, notes, and snippets.

@andreychev
Created July 21, 2012 15:33
Show Gist options
  • Save andreychev/3156174 to your computer and use it in GitHub Desktop.
Save andreychev/3156174 to your computer and use it in GitHub Desktop.
Функция для определия модели Айпеда.
// функция для определения модели Айпада
function detectIPadVersion(callback, undefined) {
if ('ondevicemotion' in window) {
window.addEventListener('devicemotion', function self(event) {
if (~navigator.platform.indexOf('iPad')) {
var version = event.acceleration ? (window.devicePixelRatio === 2) + 2 : 1;
}
window.removeEventListener('devicemotion', self);
callback(version);
}, false);
} else {
callback(undefined);
}
};
// пример вызова, в callback будет передан номер модели (1,2 или 3) или undefined, в случае, если это не iPad
detectIPadVersion(alert);
// http://bolknote.ru
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment