Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ ->
- window.ua = {}
- ua = window.ua
- ua.name = window.navigator.userAgent.toLowerCase()
- ua.isiPhone = ua.name.indexOf("iphone") > -1
- ua.isiPod = ua.name.indexOf("ipod") > -1
- ua.isiPad = ua.name.indexOf("ipad") > -1
- ua.isiOS = ua.isiPhone or ua.isiPod or ua.isiPad
- ua.isAndroid = ua.name.indexOf("android") > -1
- ua.isTablet = ua.isiPad or (ua.isAndroid and ua.name.indexOf("mobile") < 0)
- if ua.isiOS
- verArray = /(os)\s([0-9]{1,}[\_0-9]{1,})/.exec(ua.name)
- ua.ver = parseInt(verArray[2].replace(/\./g, ""), 10) if verArray
- if ua.isAndroid
- verArray = /(android)\s([0-9]{1,}[\.0-9]{1,})/.exec(ua.name)
- ua.ver = parseInt(verArray[2].replace(/\./g, ""), 10) if verArray
- if ua.isiPhone
- w = screen.width
- h = screen.height
- ua.iPhoneVer = if (w is 480 or h is 480) then "iPhone4" else if (w is 568 or h is 568) then "iPhone5" else if (w is 667 or h is 667) then "iPhone6" else if (w is 736 or h is 736) then "iPhone6plus" else "iPhone-unknown"
- $("body")
- .addClass ->
- c = ""
- if ua.isiPhone
- c += "iPhone "
- c += "#{ua.iPhoneVer} "
- c += "iPod " if ua.isiPod
- c += "iPad " if ua.isiPad
- c += "iOS iOS_#{ua.ver} " if ua.isiOS
- c += "android android_#{ua.ver} " if ua.isAndroid
- c += "tablet" if ua.isTablet
- c
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement