Proper Google+ JSONP counter request.
1. Real JSONP with a callback. 2. Using a helper instead of a hard coded request. 3. Allow multiple counters on a page. 4. Allow HTTPS.master
parent
2e42befd36
commit
4dfc81ec38
|
@ -113,28 +113,9 @@
|
||||||
popupHeight: 360
|
popupHeight: 360
|
||||||
},
|
},
|
||||||
plusone: {
|
plusone: {
|
||||||
// HTTPS not supported yet: http://clubs.ya.ru/share/1499
|
counterUrl: protocol + 'share.yandex.ru/gpp.xml?url={url}&callback=?',
|
||||||
counterUrl: isHttps ? undefined : 'http://share.yandex.ru/gpp.xml?url={url}',
|
convertNumber: function(number) {
|
||||||
counter: function(jsonUrl, deferred) {
|
return parseInt(number.replace(/\D/g, ''), 10);
|
||||||
var options = services.plusone;
|
|
||||||
if (options._) {
|
|
||||||
// Reject all counters except the first because Yandex Share counter doesn’t return URL
|
|
||||||
deferred.reject();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
options._ = deferred;
|
|
||||||
$.ajax({
|
|
||||||
url: makeUrl(jsonUrl),
|
|
||||||
dataType: 'jsonp',
|
|
||||||
success: function(number){
|
|
||||||
if (typeof number === 'string') {
|
|
||||||
number = number.replace(/\D/g, '');
|
|
||||||
}
|
|
||||||
options._.resolve(parseInt(number, 10));
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.fail(deferred.reject);
|
|
||||||
},
|
},
|
||||||
popupUrl: 'https://plus.google.com/share?url={url}',
|
popupUrl: 'https://plus.google.com/share?url={url}',
|
||||||
popupWidth: 700,
|
popupWidth: 700,
|
||||||
|
|
Loading…
Reference in New Issue