Skip to content

Commit 5d82634

Browse files
author
Igor Khomenko
committed
Merge pull request #101 from QuickBlox/develop.QBWEBSDK-220.v2
QBWEBSDK-220
2 parents 55562f8 + ed93a55 commit 5d82634

16 files changed

+452
-406
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ npm-debug.log
1010

1111
# Use command grunt for create quickblox.js
1212
quickblox.js
13+
14+
#jasmine-npm generate
15+
.grunt

js/modules/qbPushNotifications.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,22 @@
88
var config = require('../qbConfig'),
99
Utils = require('../qbUtils');
1010

11+
var isBrowser = typeof window !== "undefined";
12+
1113
function PushNotificationsProxy(service) {
1214
this.service = service;
1315
this.subscriptions = new SubscriptionsProxy(service);
1416
this.events = new EventsProxy(service);
1517

1618
this.base64Encode = function(str) {
17-
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function(match, p1) {
18-
return String.fromCharCode('0x' + p1);
19-
}));
20-
}
21-
19+
if(isBrowser) {
20+
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function(match, p1) {
21+
return String.fromCharCode('0x' + p1);
22+
}));
23+
} else {
24+
return new Buffer(str).toString('base64');
25+
}
26+
};
2227
}
2328

2429
// Subscriptions
@@ -43,7 +48,6 @@ SubscriptionsProxy.prototype = {
4348

4449
delete: function(id, callback) {
4550
Utils.QBLog('[SubscriptionsProxy]', 'delete', id);
46-
4751
this.service.ajax({url: Utils.getUrl(config.urls.subscriptions, id), type: 'DELETE', dataType:'text'},
4852
function(err, res){
4953
if (err) { callback(err, null);}
@@ -72,7 +76,7 @@ EventsProxy.prototype = {
7276
callback = params;
7377
params = null;
7478
}
75-
79+
7680
Utils.QBLog('[EventsProxy]', 'list', params);
7781

7882
this.service.ajax({url: Utils.getUrl(config.urls.events), data: params}, callback);
@@ -92,10 +96,8 @@ EventsProxy.prototype = {
9296

9397
delete: function(id, callback) {
9498
Utils.QBLog('[EventsProxy]', 'delete', id);
95-
9699
this.service.ajax({url: Utils.getUrl(config.urls.events, id), type: 'DELETE'}, callback);
97100
}
98-
99101
};
100102

101103
module.exports = PushNotificationsProxy;

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,16 @@
4646
"xml2js": "^0.4.13"
4747
},
4848
"devDependencies": {
49+
"ghooks": "^1.0.3",
4950
"grunt": "^0.4.5",
5051
"grunt-browserify": "^3.2.1",
5152
"grunt-contrib-connect": "^0.9.0",
5253
"grunt-contrib-uglify": "^0.6.0",
5354
"grunt-contrib-watch": "^0.6.1",
5455
"grunt-notify": "^0.4.1",
5556
"grunt-parallel": "^0.4.1",
56-
"load-grunt-tasks": "^1.0.0",
57-
"xml2js": "^0.4.12"
57+
"jasmine": "^2.4.1",
58+
"load-grunt-tasks": "^1.0.0"
5859
},
5960
"autoupdate": {
6061
"source": "git",
@@ -64,5 +65,10 @@
6465
"quickblox.js",
6566
"quickblox.min.js"
6667
]
68+
},
69+
"config": {
70+
"ghooks": {
71+
"pre-commit": "jasmine"
72+
}
6773
}
6874
}

quickblox.min.js

Lines changed: 10 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)