openxjs-rails 1.0.0.0
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 +15 -0
- data/.gitignore +2 -0
- data/Gemfile +4 -0
- data/README.md +30 -0
- data/Rakefile +2 -0
- data/lib/openxjs-rails.rb +5 -0
- data/lib/openxjs/rails/engine.rb +9 -0
- data/lib/openxjs/rails/version.rb +5 -0
- data/openxjs-rails.gemspec +17 -0
- data/vendor/assets/javascripts/openxjs.js +177 -0
- metadata +66 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NDEwNWRlNTlmYzliY2FlMWZkOGYwMzlmYjViMzg0MGViZjk2MWVhNg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
Mjk0MTJjMWJkYmI1MWM5ZDFiZTA3NGZlYTI0MDhlZjg2NmJiNmVmMQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YzhlMmUyMjZhZWMzZGI3Y2NmZjkxNDQ0ZjMzYTUzYWM5YzlmZmE2MTU0OTc5
|
10
|
+
ZGRlM2E1ZTBiNjgzMzJmMTI3MmJiZjk5ZThhMDg1OTg5N2FlMzFlNzI4ZTQ1
|
11
|
+
ZDVkN2YzM2RhYmZmNWFlMTlhZGZiYjlhNjZjY2QzMDAwNWEyNGM=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZjU4YzUyMTRhN2NkNTBlNTM0NDRhZTg1ZmI5Zjg1OGJkYTE3YzI5MDIzZDhm
|
14
|
+
YjNmMjc2ZGViMTc2N2QyYWRmNmFkOTA5MDhjM2FiOThiMDEwZDkxMTBkZmI3
|
15
|
+
ZjE0ZDI1YTZlZjUyOTA5ZTNjNWQ1MmIwZmIwNjQ5YjgxNTRhZTg=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# openxjs-rails
|
2
|
+
[](https://gemnasium.com/softgames/openxjs-rails)
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
Add this line to your application's Gemfile:
|
7
|
+
|
8
|
+
gem 'openxjs-rails'
|
9
|
+
|
10
|
+
And then execute:
|
11
|
+
|
12
|
+
$ bundle
|
13
|
+
|
14
|
+
Add this line to your test manifest file:
|
15
|
+
|
16
|
+
//=require openxjs
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
Read more about openxjs [here](http://github.com/softgames/openxjs).
|
21
|
+
|
22
|
+
## Contributing
|
23
|
+
|
24
|
+
openxjs is maintained by [Softgames](http://github.com/softgames)
|
25
|
+
|
26
|
+
1. Fork it
|
27
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
28
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
29
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
30
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/openxjs/rails/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Softgames GmbH"]
|
6
|
+
gem.email = ["scotty@softgames.de"]
|
7
|
+
gem.summary = %q{openxjs.js via asset pipeline}
|
8
|
+
gem.homepage = "http://github.com/softgames/openxjs-rails"
|
9
|
+
|
10
|
+
gem.files = `git ls-files`.split("\n")
|
11
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
12
|
+
gem.name = "openxjs-rails"
|
13
|
+
gem.require_paths = ["lib"]
|
14
|
+
gem.version = Openxjs::Rails::VERSION
|
15
|
+
|
16
|
+
gem.add_dependency 'railties', '>= 3.1'
|
17
|
+
end
|
@@ -0,0 +1,177 @@
|
|
1
|
+
// Generated by CoffeeScript 1.6.1
|
2
|
+
|
3
|
+
/*
|
4
|
+
OpenXJS
|
5
|
+
Copyright(c) 2013 Softgames GmbH <scotty@softgames.de>
|
6
|
+
*/
|
7
|
+
|
8
|
+
|
9
|
+
(function() {
|
10
|
+
|
11
|
+
window.OpenXJS = (function() {
|
12
|
+
|
13
|
+
OpenXJS.prototype.spcScript = "spc.php";
|
14
|
+
|
15
|
+
function OpenXJS(options) {
|
16
|
+
this.deliveryUrl = options.deliveryUrl;
|
17
|
+
this.defaultParameters = options.parameters;
|
18
|
+
}
|
19
|
+
|
20
|
+
OpenXJS.prototype.displayAds = function(zonesMapping, parameters, callback) {
|
21
|
+
var _this = this;
|
22
|
+
return this.receiveAdCodes(zonesMapping, parameters, function(codes) {
|
23
|
+
var code, target;
|
24
|
+
for (target in codes) {
|
25
|
+
code = codes[target];
|
26
|
+
_this._displayAd(target, code);
|
27
|
+
}
|
28
|
+
return typeof callback === "function" ? callback() : void 0;
|
29
|
+
});
|
30
|
+
};
|
31
|
+
|
32
|
+
OpenXJS.prototype.receiveAdCodes = function(zonesMapping, parameters, callback) {
|
33
|
+
var openXParameters, scriptUrl,
|
34
|
+
_this = this;
|
35
|
+
openXParameters = this._openxParameters(zonesMapping, parameters);
|
36
|
+
scriptUrl = this.deliveryUrl + this.spcScript + "?" + this._queryString(openXParameters);
|
37
|
+
return this._loadScript(scriptUrl, function() {
|
38
|
+
return _this._parseResponse(zonesMapping, callback);
|
39
|
+
});
|
40
|
+
};
|
41
|
+
|
42
|
+
OpenXJS.prototype._parseResponse = function(zonesMapping, callback) {
|
43
|
+
var codes, target, zone;
|
44
|
+
codes = {};
|
45
|
+
if (typeof window.OA_output !== "object") {
|
46
|
+
window.OA_output = null;
|
47
|
+
if (typeof callback === "function") {
|
48
|
+
callback(codes);
|
49
|
+
}
|
50
|
+
return;
|
51
|
+
}
|
52
|
+
for (target in zonesMapping) {
|
53
|
+
zone = zonesMapping[target];
|
54
|
+
if (this._emptyResponse(window.OA_output[target])) {
|
55
|
+
continue;
|
56
|
+
}
|
57
|
+
codes[target] = window.OA_output[target];
|
58
|
+
}
|
59
|
+
window.OA_output = null;
|
60
|
+
return typeof callback === "function" ? callback(codes) : void 0;
|
61
|
+
};
|
62
|
+
|
63
|
+
OpenXJS.prototype._displayAd = function(target, code) {
|
64
|
+
var targetElement;
|
65
|
+
targetElement = document.getElementById(target);
|
66
|
+
if (targetElement === null) {
|
67
|
+
return;
|
68
|
+
}
|
69
|
+
return document.getElementById(target).innerHTML = code;
|
70
|
+
};
|
71
|
+
|
72
|
+
OpenXJS.prototype._openxParameters = function(zonesMapping, parameters) {
|
73
|
+
var key, mappingString, mergedParameters, openXParameters, target, value, zone;
|
74
|
+
mergedParameters = this._mergeObjects(this.defaultParameters, parameters);
|
75
|
+
mappingString = "|";
|
76
|
+
for (target in zonesMapping) {
|
77
|
+
zone = zonesMapping[target];
|
78
|
+
mappingString += "" + target + "=" + zone + "|";
|
79
|
+
}
|
80
|
+
openXParameters = {
|
81
|
+
zones: mappingString,
|
82
|
+
nz: 1,
|
83
|
+
blockcampaign: 1,
|
84
|
+
charset: this._documentCharset(),
|
85
|
+
cb: this._randomNumber(),
|
86
|
+
r: this._randomNumber(),
|
87
|
+
loc: this._location(),
|
88
|
+
referer: this._referrer()
|
89
|
+
};
|
90
|
+
for (key in mergedParameters) {
|
91
|
+
value = mergedParameters[key];
|
92
|
+
openXParameters[key] = value;
|
93
|
+
}
|
94
|
+
return openXParameters;
|
95
|
+
};
|
96
|
+
|
97
|
+
OpenXJS.prototype._loadScript = function(url, callback) {
|
98
|
+
var called, s,
|
99
|
+
_this = this;
|
100
|
+
s = document.createElement('script');
|
101
|
+
s.async = "async";
|
102
|
+
called = false;
|
103
|
+
s.onload = s.onreadystatechange = function() {
|
104
|
+
if ((s.readyState && !(/complete|loaded/.test(s.readyState))) || called) {
|
105
|
+
return;
|
106
|
+
}
|
107
|
+
called = true;
|
108
|
+
s.onload = s.onreadystatechange = null;
|
109
|
+
return typeof callback === "function" ? callback() : void 0;
|
110
|
+
};
|
111
|
+
s.src = url;
|
112
|
+
return this._appendToHead(s);
|
113
|
+
};
|
114
|
+
|
115
|
+
OpenXJS.prototype._randomNumber = function() {
|
116
|
+
return Math.floor(Math.random() * 99999999999);
|
117
|
+
};
|
118
|
+
|
119
|
+
OpenXJS.prototype._location = function() {
|
120
|
+
return window.location;
|
121
|
+
};
|
122
|
+
|
123
|
+
OpenXJS.prototype._referrer = function() {
|
124
|
+
return document.referrer;
|
125
|
+
};
|
126
|
+
|
127
|
+
OpenXJS.prototype._documentCharset = function() {
|
128
|
+
if (document.charset) {
|
129
|
+
return document.charset;
|
130
|
+
} else {
|
131
|
+
if (document.characterSet) {
|
132
|
+
return document.characterSet;
|
133
|
+
} else {
|
134
|
+
return "";
|
135
|
+
}
|
136
|
+
}
|
137
|
+
};
|
138
|
+
|
139
|
+
OpenXJS.prototype._emptyResponse = function(response) {
|
140
|
+
return typeof response !== "string" || response === "" || response === "<a href=\'F\' target=\'_blank\'><img src=\'F\' border=\'0\' alt=\'\'></a>\n";
|
141
|
+
};
|
142
|
+
|
143
|
+
OpenXJS.prototype._queryString = function(parameters) {
|
144
|
+
var elements, name, value;
|
145
|
+
elements = [];
|
146
|
+
for (name in parameters) {
|
147
|
+
value = parameters[name];
|
148
|
+
if (value != null) {
|
149
|
+
elements.push("" + name + "=" + (encodeURIComponent(value)));
|
150
|
+
}
|
151
|
+
}
|
152
|
+
return elements.join('&');
|
153
|
+
};
|
154
|
+
|
155
|
+
OpenXJS.prototype._appendToHead = function(element) {
|
156
|
+
var head;
|
157
|
+
head = document.head || document.getElementsByTagName("head")[0] || document.documentElement;
|
158
|
+
return head.insertBefore(element, head.firstChild);
|
159
|
+
};
|
160
|
+
|
161
|
+
OpenXJS.prototype._mergeObjects = function(obj1, obj2) {
|
162
|
+
var attrname, obj3;
|
163
|
+
obj3 = {};
|
164
|
+
for (attrname in obj1) {
|
165
|
+
obj3[attrname] = obj1[attrname];
|
166
|
+
}
|
167
|
+
for (attrname in obj2) {
|
168
|
+
obj3[attrname] = obj2[attrname];
|
169
|
+
}
|
170
|
+
return obj3;
|
171
|
+
};
|
172
|
+
|
173
|
+
return OpenXJS;
|
174
|
+
|
175
|
+
})();
|
176
|
+
|
177
|
+
}).call(this);
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: openxjs-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Softgames GmbH
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-03-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: railties
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.1'
|
27
|
+
description:
|
28
|
+
email:
|
29
|
+
- scotty@softgames.de
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- .gitignore
|
35
|
+
- Gemfile
|
36
|
+
- README.md
|
37
|
+
- Rakefile
|
38
|
+
- lib/openxjs-rails.rb
|
39
|
+
- lib/openxjs/rails/engine.rb
|
40
|
+
- lib/openxjs/rails/version.rb
|
41
|
+
- openxjs-rails.gemspec
|
42
|
+
- vendor/assets/javascripts/openxjs.js
|
43
|
+
homepage: http://github.com/softgames/openxjs-rails
|
44
|
+
licenses: []
|
45
|
+
metadata: {}
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
requirements: []
|
61
|
+
rubyforge_project:
|
62
|
+
rubygems_version: 2.0.2
|
63
|
+
signing_key:
|
64
|
+
specification_version: 4
|
65
|
+
summary: openxjs.js via asset pipeline
|
66
|
+
test_files: []
|