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
Artem Sapegin 2015-12-21 20:57:23 +01:00
parent 2e42befd36
commit 4dfc81ec38
1 changed files with 3 additions and 22 deletions

View File

@ -113,28 +113,9 @@
popupHeight: 360
},
plusone: {
// HTTPS not supported yet: http://clubs.ya.ru/share/1499
counterUrl: isHttps ? undefined : 'http://share.yandex.ru/gpp.xml?url={url}',
counter: function(jsonUrl, deferred) {
var options = services.plusone;
if (options._) {
// Reject all counters except the first because Yandex Share counter doesnt 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);
counterUrl: protocol + 'share.yandex.ru/gpp.xml?url={url}&callback=?',
convertNumber: function(number) {
return parseInt(number.replace(/\D/g, ''), 10);
},
popupUrl: 'https://plus.google.com/share?url={url}',
popupWidth: 700,