deviceatlasapi 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/README.ClientSide.txt +93 -0
- data/deviceatlasapi.gemspec +1 -0
- data/lib/deviceatlasapi/version.rb +1 -1
- data/vendor/assets/javascripts/deviceatlas-1.1.min.js +7 -0
- metadata +17 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
N2MyZWQ2Y2M4NzczZjFkMzBhY2NiY2Q4NzE3NDE0NTc4NWQ5ZTA0Yw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Y2QxMzkwNTMzYzMyZGViZmE3ZGFmMWM0OGRjOGYzYTE0NDk2ODljNw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZjQ2OTgwZTNkY2NhYjE1MmYwNjk0MzA3MDEzZDEwMmYwY2I3OTFiMmRlZWRm
|
10
|
+
ZjI5NTFjMmY1NjU2NzhiMGFiYTk3MmIzMDMxZjBlMjQ5YjhmNjM2ODBiMDk0
|
11
|
+
MjlmNzZiNDNlM2I3MWEyMWQwMTU3YTIzNWQzZmRmNzIwNzk5ZGU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTEwMzljMDA3ZDRhNTYxMjZlOGI1N2M3MWFiMmI3NjI4OTZmMDcxNDk5NDc0
|
14
|
+
MDYxZmMzNmIwNmNiZmZjMDg4ZDYzYTA1NjRmNmI4YzkwZTEzZmE3NmIwZDA0
|
15
|
+
ZGZmZjQxMDFlMTQ1YmZlNDE1MjMxZGE1MDA2OTJhZWY5YzI3ZTM=
|
@@ -0,0 +1,93 @@
|
|
1
|
+
DeviceAtlas APIs with client side properties
|
2
|
+
|
3
|
+
|
4
|
+
***** INTRO *****
|
5
|
+
The DeviceAtlas APIs can work in conjunction with a JavaScript property
|
6
|
+
detection file and merge the resulting properties for use on the server side.
|
7
|
+
The client properties are also available to other JavaScript libraries. The
|
8
|
+
DeviceAtlas client detection file needs to be included on your web page for this
|
9
|
+
to function.
|
10
|
+
|
11
|
+
|
12
|
+
***** CLIENT SIDE ACCESS TO PROPERTIES *****
|
13
|
+
The properties gathered from the DeviceAtlas JavaScript detection are available
|
14
|
+
to other JavaScript functions and can be accessed on the client side by using
|
15
|
+
the "DeviceAtlas" namespace.
|
16
|
+
|
17
|
+
EXAMPLE:
|
18
|
+
--------------------------------------------
|
19
|
+
|
20
|
+
// Does the browser support Web GL ?
|
21
|
+
var supportsWebGl = DeviceAtlas.js.webGl;
|
22
|
+
|
23
|
+
--------------------------------------------
|
24
|
+
|
25
|
+
The normal DeviceAtlas property name should be used to access the client side
|
26
|
+
property.
|
27
|
+
|
28
|
+
|
29
|
+
***** SERVER SIDE ACCESS TO PROPERTIES *****
|
30
|
+
The JavaScript detection file creates a special cookie with the detected client
|
31
|
+
properties.
|
32
|
+
|
33
|
+
When using DeviceAtlas Enterprise APIs:
|
34
|
+
To access the client side properties on the server the contents of this cookie
|
35
|
+
need to be passed to the API's getProperty and getProperties () methods.
|
36
|
+
|
37
|
+
When using DeviceAtlas Cloud APIs:
|
38
|
+
If using this cookie is allowed in the settings, the API will use the cookie
|
39
|
+
if it exists.
|
40
|
+
|
41
|
+
The client side properties over-ride any data file properties and also serve as
|
42
|
+
an input into additional logic to determine other properties such iPhone models
|
43
|
+
which are normally not detectable.
|
44
|
+
|
45
|
+
The cookie containing the properties is called "DAPROPS".
|
46
|
+
|
47
|
+
|
48
|
+
***** BASIC SERVER SIDE USAGE *****
|
49
|
+
1) Include the deviceatlas-X.X.min.js file on your webpage.
|
50
|
+
2) In your web application, pass the contents of the DeviceAtlas cookie
|
51
|
+
to the DeviceAtlas API.
|
52
|
+
|
53
|
+
NOTE: the cookie contents will only be set after the first request. It is
|
54
|
+
recommended to not rely on the client side properties for the very first page.
|
55
|
+
|
56
|
+
Please see the Example code bundled with the API for more information.
|
57
|
+
|
58
|
+
|
59
|
+
***** CUSTOM CONFIGURATION *****
|
60
|
+
To customize a cookie name or other cookie parameters like a domain or a path
|
61
|
+
you can use the code bellow - just remember that this code must be used before
|
62
|
+
you include deviceatlas-X.X.min.js file.
|
63
|
+
|
64
|
+
var DeviceAtlas = {
|
65
|
+
cookieName: 'DAPROPS', // the name of the cookie name
|
66
|
+
cookieExpiryDays: 1, // the time the cookie expires in days
|
67
|
+
cookieDomain: '.yourdomain.tld', // custom domain
|
68
|
+
cookiePath: '/' // custom path
|
69
|
+
}
|
70
|
+
|
71
|
+
|
72
|
+
***** SENDING COOKIE VIA URL *****
|
73
|
+
In restricted environment where cookies are not allowed it is possible
|
74
|
+
to get a cookie content using js getPropertiesAsString() method and pass it as
|
75
|
+
an URL parameter.
|
76
|
+
|
77
|
+
NOTE: it's up to web application integration to get the value from the URL
|
78
|
+
and pass it properly to the DeviceAtlas API.
|
79
|
+
|
80
|
+
EXAMPLE:
|
81
|
+
|
82
|
+
<script type="text/javascript">
|
83
|
+
|
84
|
+
window.onload = function() {
|
85
|
+
var img = document.createElement('img');
|
86
|
+
img.setAttribute('id', 'ad-banner');
|
87
|
+
img.setAttribute('src', './ads.php?DAPROPS=' + encodeURIComponent(DeviceAtlas.getPropertiesAsString()));
|
88
|
+
document.body.appendChild(img);
|
89
|
+
}
|
90
|
+
|
91
|
+
</script>
|
92
|
+
|
93
|
+
© 2013 Afilias Technologies Ltd (dotMobi). All rights reserved
|
data/deviceatlasapi.gemspec
CHANGED
@@ -0,0 +1,7 @@
|
|
1
|
+
|
2
|
+
/*
|
3
|
+
* Copyright 2013 Afilias Technologies Ltd (dotMobi). All rights reserved.
|
4
|
+
* http://deviceatlas.com
|
5
|
+
*/
|
6
|
+
|
7
|
+
var DeviceAtlas=DeviceAtlas||{};DeviceAtlas={apiVersion:"1.1",propsCache:"",cookieName:DeviceAtlas.cookieName||"DAPROPS",cookieExpiryDays:DeviceAtlas.cookieExpiryDays||1,cookieDomain:DeviceAtlas.cookieDomain||null,cookiePath:DeviceAtlas.cookiePath||"/",divStyle:null,ns:{svg:"http://www.w3.org/2000/svg"},cssPrfxs:["Webkit","Moz","O","ms","Khtml"],fncPrfxs:["webkit","moz","o","ms","khtml"],properties:{"js.webGl":function(){return !!window.WebGLRenderingContext},"js.geoLocation":function(){return !!navigator.geolocation},"js.webSqlDatabase":function(){return !!window.openDatabase},"js.indexedDB":function(){return DeviceAtlas.testPrexifes(window,"indexedDB")},"js.webSockets":function(){return DeviceAtlas.testPrexifes(window,"WebSocket")},"js.localStorage":function(){try{return !!localStorage.getItem}catch(A){return false}},"js.sessionStorage":function(){try{return !!sessionStorage.getItem}catch(A){return false}},"js.webWorkers":function(){return !!window.Worker},"js.applicationCache":function(){return !!window.applicationCache},"js.supportBasicJavaScript":function(){if((typeof alert!="function")||(typeof confirm!="function")||(typeof setTimeout!="function")||(typeof setInterval!="function")){return false}return !!document.location&&!!document.forms},"js.modifyDom":function(){if(!document.createElement||!document.appendChild){return false}var A,B;A=document.createElement("span");B=document.createElement("div");B.appendChild(A);return(B==A.parentNode)},"js.modifyCss":function(){if(!document.createElement){return false}var A;A=document.createElement("div");if((typeof A.style!="object")||(typeof A.style.display=="undefined")){return false}A.style.display="none";return(A.style.display=="none")},"js.supportEvents":function(){var B={submit:"form",click:"input",change:"input",load:"img",select:"input"};for(var A in B){if(!DeviceAtlas.isEventSupported(A,B[A])){return false}}return true},"js.supportEventListener":function(){return !!window.addEventListener},"js.xhr":function(){return(typeof XMLHttpRequest=="function")||(typeof XMLHttpRequest=="object")},"js.supportConsoleLog":function(){return(typeof console=="object")&&(typeof console.log=="function")},"js.json":function(){return(typeof JSON=="object")&&(typeof JSON.stringify=="function")},"js.deviceOrientation":function(){return false},"js.deviceMotion":function(){return !!window.DeviceMotionEvent},"js.touchEvents":function(){return("ontouchstart" in window)},"js.querySelector":function(){return !!document.querySelector},"html.canvas":function(){if(!document.createElement){return false}var A;A=document.createElement("canvas");return !!(A.getContext&&A.getContext("2d"))},"html.video":function(){if(!document.createElement){return false}var C,A=new Boolean();C=document.createElement("video");try{if(A=!!C.canPlayType){A.ogg=C.canPlayType('video/ogg; codecs="theora"');var B='video/mp4; codecs="avc1.42E01E';A.h264=C.canPlayType(B+'"')||C.canPlayType(B+', mp4a.40.2"');A.webm=C.canPlayType('video/webm; codecs="vp8, vorbis"')}}catch(D){}return A.valueOf()},"html.audio":function(){if(!document.createElement){return false}var B,A=new Boolean();B=document.createElement("audio");try{if(A=!!B.canPlayType){A.ogg=B.canPlayType('audio/ogg; codecs="vorbis"');A.mp3=B.canPlayType("audio/mpeg;");A.wav=B.canPlayType('audio/wav; codecs="1"');A.m4a=B.canPlayType("audio/x-m4a;")||B.canPlayType("audio/aac;")}}catch(C){}return A.valueOf()},"html.svg":function(){return !!document.createElementNS&&!!document.createElementNS(DeviceAtlas.ns.svg,"svg").createSVGRect},"html.inlinesvg":function(){if(!document.createElement){return false}var A;A=document.createElement("div");A.innerHTML="<svg/>";return(A.firstChild&&A.firstChild.namespaceURI)==DeviceAtlas.ns.svg},"css.animations":function(){return DeviceAtlas.testPropsAll("animationName")},"css.columns":function(){return DeviceAtlas.testPropsAll("columnCount")},"css.transforms":function(){return !!DeviceAtlas.testProps(["transformProperty","WebkitTransform","MozTransform","OTransform","msTransform"])},"css.transitions":function(){return DeviceAtlas.testPropsAll("transitionProperty")},displayColorDepth:function(){return screen.colorDepth},cookieSupport:function(){if(typeof navigator.cookieEnabled=="undefined"&&typeof document.cookie=="string"){return true}return !!navigator.cookieEnabled},orientation:function(){if(typeof window.orientation!="undefined"){return window.orientation}else{return null}},devicePixelRatio:function(){var A=1;try{A=window.devicePixelRatio}catch(B){}return A+""},deviceAspectRatio:function(){var A=["2/3","40/71","3/4","16/9","16/10"];return DeviceAtlas.discoverMediaQueryValue("device-aspect-ratio",A)},flashCapable:function(){try{if(navigator.plugins&&navigator.plugins.length>0&&navigator.mimeTypes){var E="application/x-shockwave-flash";if(navigator.mimeTypes[E]&&navigator.mimeTypes[E].enabledPlugin){return true}}if((typeof ActiveXObject=="function")||(typeof ActiveXObject=="object")){var A=["ShockwaveFlash.ShockwaveFlash.7","ShockwaveFlash.ShockwaveFlash.7","ShockwaveFlash.ShockwaveFlash"];for(var C in A){try{var B=new ActiveXObject(A[C]);return true}catch(D){}}}}catch(D){}return false},accessDom:function(){return !!document.getElementById&&!!document.getElementsByTagName&&!!document.getElementsByName},userMedia:function(){return DeviceAtlas.testPrexifes(navigator,"getUserMedia")}},testProps:function(A){if(!document.createElement){return null}if(this.divStyle==null){this.divStyle=document.createElement("div").style}if(typeof this.divStyle=="undefined"){return null}for(var B in A){if(typeof this.divStyle[A[B]]!="undefined"){return true}}return false},testPropsAll:function(B){var C=B.charAt(0).toUpperCase()+B.substr(1),A=(B+" "+this.cssPrfxs.join(C+" ")+C).split(" ");return this.testProps(A)},testPrexifes:function(D,E){var B=E.charAt(0).toUpperCase()+E.substr(1);for(var C=-1,A=this.fncPrfxs.length;++C<A;){if(!!D[this.fncPrfxs[C]+B]){if(A>1){this.fncPrfxs=[this.fncPrfxs[C]];this.cssPrfxs=[this.cssPrfxs[C]]}return true}}return !!D[E]},isEventSupported:function(A,D){if(!document.createElement){return false}var C,B;C=document.createElement(D);A="on"+A;B=A in C;if(!B){if(!C.setAttribute){C=document.createElement("div")}if(!!C.setAttribute&&!!C.removeAttribute){C.setAttribute(A,"");B=(typeof C[A]=="function")}}return B},discoverMediaQueryValue:function(B,D){if(typeof window.matchMedia=="undefined"){return null}for(var C in D){var A=window.matchMedia("("+B+":"+D[C]+")");if(A.matches){return D[C]+""}}return null},orientationEventTest:function(A){var C=this;if(!!window.addEventListener&&!!window.removeEventListener){var B=function(D){if(D!=null&&D.alpha!=null){A["js.deviceOrientation"]=true;C.exposeProperty("js.deviceOrientation",true);C.propsCache=C.encodeProperties(A);C.setCookie(C.propsCache)}window.removeEventListener("deviceorientation",B,false)};window.addEventListener("deviceorientation",B,false)}},exposeProperties:function(){var C={},A;for(var B in this.properties){A=this.properties[B]();if(A==null||typeof A=="undefined"){continue}this.exposeProperty(B,A);C[B]=A}return C},exposeProperty:function(C,A){var B;if(C.indexOf(".")!=-1){B=C.split(".");if(typeof this[B[0]]=="undefined"){this[B[0]]={}}this[B[0]][B[1]]=A}else{this[C]=A}},getPropertyType:function(A,B){if(typeof B=="boolean"){return"b"}else{if(typeof B=="number"){return"i"}else{return"s"}}},setCookie:function(B){var A=new Date();A.setDate(A.getDate()+this.cookieExpiryDays);var C="";if(this.cookieDomain!=null){C=";domain="+this.cookieDomain}document.cookie=this.cookieName+'="'+B+'";expires='+A.toUTCString()+";path="+this.cookiePath+C},encodeProperties:function(D){var A="",C;for(var B in D){C=this.getPropertyType(B,D[B]);A+=C+B+":"+((C=="b")?D[B]+0:D[B])+"|"}return A.slice(0,-1)},getPropertiesAsString:function(){return this.propsCache},run:function(){var A=this.exposeProperties();this.propsCache=this.encodeProperties(A);if(A.cookieSupport){this.setCookie(this.propsCache)}this.orientationEventTest(A)}};DeviceAtlas.run();
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deviceatlasapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Trevor Kimenye
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ! '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: railties
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.1'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.1'
|
55
69
|
description: Lets you access the DeviceAtlas cloud api
|
56
70
|
email:
|
57
71
|
- kimenye@gmail.com
|
@@ -62,12 +76,14 @@ files:
|
|
62
76
|
- .gitignore
|
63
77
|
- Gemfile
|
64
78
|
- LICENSE.txt
|
79
|
+
- README.ClientSide.txt
|
65
80
|
- README.md
|
66
81
|
- Rakefile
|
67
82
|
- deviceatlasapi.gemspec
|
68
83
|
- lib/deviceatlasapi.rb
|
69
84
|
- lib/deviceatlasapi/controller.rb
|
70
85
|
- lib/deviceatlasapi/version.rb
|
86
|
+
- vendor/assets/javascripts/deviceatlas-1.1.min.js
|
71
87
|
homepage: https://github.com/kimenye/deviceatlasapi
|
72
88
|
licenses:
|
73
89
|
- MIT
|