From 4dfc81ec38454edb6f391b4921b9f3d5b7bacb12 Mon Sep 17 00:00:00 2001 From: Artem Sapegin Date: Mon, 21 Dec 2015 20:57:23 +0100 Subject: [PATCH] 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. --- src/social-likes.js | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/src/social-likes.js b/src/social-likes.js index a9de714..5ef6134 100644 --- a/src/social-likes.js +++ b/src/social-likes.js @@ -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 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); + 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,