SocialShare.js
399 lines
| 1 | /* |
| 2 | SocialShare - jQuery plugin |
| 3 | */ |
| 4 | (function ($) { |
| 5 | |
| 6 | function get_class_list(elem){ |
| 7 | if(elem.classList){ |
| 8 | return elem.classList; |
| 9 | }else{ |
| 10 | return $(elem).attr('class').match(/\S+/gi); |
| 11 | } |
| 12 | } |
| 13 | |
| 14 | $.fn.ShareLink = function(options){ |
| 15 | var defaults = { |
| 16 | title: '', |
| 17 | text: '', |
| 18 | image: '', |
| 19 | url: window.location.href, |
| 20 | class_prefix: 's_' |
| 21 | }; |
| 22 | |
| 23 | var options = $.extend({}, defaults, options); |
| 24 | |
| 25 | var class_prefix_length = options.class_prefix.length; |
| 26 | |
| 27 | var templates = { |
| 28 | twitter: 'https://twitter.com/intent/tweet?url={url}&text={text}', |
| 29 | pinterest: 'https://www.pinterest.com/pin/create/button/?media={image}&url={url}&description={text}', |
| 30 | facebook: 'https://www.facebook.com/sharer.php?s=100&p[title]={title}&u={url}&t={title}&p[summary]={text}&p[url]={url}', |
| 31 | vk: 'https://vkontakte.ru/share.php?url={url}&title={title}&description={text}&image={image}&noparse=true', |
| 32 | linkedin: 'https://www.linkedin.com/shareArticle?mini=true&url={url}&title={title}&summary={text}&source={url}', |
| 33 | myworld: 'https://connect.mail.ru/share?url={url}&title={title}&description={text}&imageurl={image}', |
| 34 | odnoklassniki: 'http://odnoklassniki.ru/dk?st.cmd=addShare&st.s=1&st._surl={url}&st.comments={text}', |
| 35 | tumblr: 'https://tumblr.com/share?s=&v=3&t={title}&u={url}', |
| 36 | blogger: 'https://blogger.com/blog-this.g?t={text}&n={title}&u={url}', |
| 37 | delicious: 'https://delicious.com/save?url={url}&title={title}', |
| 38 | plus: 'https://plus.google.com/share?url={url}', |
| 39 | digg: 'https://digg.com/submit?url={url}&title={title}', |
| 40 | reddit: 'http://reddit.com/submit?url={url}&title={title}', |
| 41 | stumbleupon: 'https://www.stumbleupon.com/submit?url={url}&title={title}', |
| 42 | pocket: 'https://getpocket.com/edit?url={url}&title={title}', |
| 43 | chiq: 'http://www.chiq.com/create/bookmarklet?u={url}&i={image}&d={title}&c={url}', |
| 44 | qrifier: 'http://qrifier.com/q?inc=qr&type=url&size=350&string={url}', |
| 45 | qrsrc: 'http://www.qrsrc.com/default.aspx?shareurl={url}', |
| 46 | qzone: 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url={url}', |
| 47 | tulinq: 'http://www.tulinq.com/enviar?url={url}&title={title}', |
| 48 | misterwong: 'http://www.mister-wong.com/index.php?action=addurl&bm_url={url}&bm_description={title}&bm_notice=', |
| 49 | sto_zakladok: 'http://www.100zakladok.ru/save/?bmurl={url}&bmtitle={title}', |
| 50 | two_linkme: 'http://www.2linkme.com/?collegamento={url}&id=2lbar', |
| 51 | adifni: 'http://www.adifni.com/account/bookmark/?bookmark_url={url}', |
| 52 | amazonwishlist: 'http://www.amazon.com/gp/wishlist/static-add?u={url}&t={title}', |
| 53 | amenme: 'http://www.amenme.com/AmenMe/Amens/AmenToThis.aspx?url={url}&title={title}', |
| 54 | aim: 'http://lifestream.aol.com/share/?url={url}&title={title}&description={text} ', |
| 55 | aolmail: 'http://webmail.aol.com/25045/aol/en-us/Mail/compose-message.aspx?to=&subject={title}&body={{content}}', |
| 56 | arto: 'http://www.arto.com/section/linkshare/?lu={url}&ln={title}', |
| 57 | baidu: 'http://cang.baidu.com/do/add?it={title}&iu={url}&fr=ien&dc={text}', |
| 58 | bitly: 'https://bitly.com/a/bitmarklet?u={url}', |
| 59 | bizsugar: 'http://www.bizsugar.com/bizsugarthis.php?url={url}', |
| 60 | blinklist: 'http://www.blinklist.com/blink?u={url}&t={title}&d={text}', |
| 61 | blip: 'http://blip.pl/dashboard?body={title}%3A%20{url}', |
| 62 | blogmarks: 'http://blogmarks.net/my/new.php?mini=1&simple=1&url={url}&title={title}&content={text}', |
| 63 | blurpalicious: 'http://www.blurpalicious.com/submit/?url={url}&title={title}&desc={text}', |
| 64 | bobrdobr: 'http://bobrdobr.ru/addext.html?url={url}&title={title}&desc={text}', |
| 65 | bonzobox: 'http://bonzobox.com/toolbar/add?u={url}&t={title}&desc={text}', |
| 66 | bookmerkende: 'http://www.bookmerken.de/?url={url}&title={title}', |
| 67 | box: 'https://www.box.net/api/1.0/import?import_as=link&url={url}&name={title}&description={text}', |
| 68 | bryderi: 'http://bryderi.se/add.html?u={url}', |
| 69 | buddymarks: 'http://buddymarks.com/add_bookmark.php?bookmark_title={title}&bookmark_url={url}&bookmark_desc={text}', |
| 70 | camyoo: 'http://www.camyoo.com/note.html?url={url}', |
| 71 | care2: 'http://www.care2.com/news/compose?sharehint=news&share[share_type]news&bookmarklet=Y&share[title]={title}&share[link_url]={url}&share[content]={text}', |
| 72 | citeulike: 'http://www.citeulike.org/posturl?url={url}&title={title}', |
| 73 | classicalplace: 'http://www.classicalplace.com/?u={url}&t={title}&c={text}', |
| 74 | cosmiq: 'http://www.cosmiq.de/lili/my/add?url={url}', |
| 75 | diggita: 'http://www.diggita.it/submit.php?url={url}&title={title}', |
| 76 | diigo: 'http://www.diigo.com/post?url={url}&title={title}&desc={text}', |
| 77 | domelhor: 'http://domelhor.net/submit.php?url={url}&title={title}', |
| 78 | dotnetshoutout: 'http://dotnetshoutout.com/Submit?url={url}&title={title}', |
| 79 | douban: 'http://www.douban.com/recommend/?url={url}&title={title}', |
| 80 | dropjack: 'http://www.dropjack.com/submit.php?url={url}', |
| 81 | edelight: 'http://www.edelight.de/geschenk/neu?purl={url}', |
| 82 | ekudos: 'http://www.ekudos.nl/artikel/nieuw?url={url}&title={title}&desc={text}', |
| 83 | elefantapl: 'http://elefanta.pl/member/bookmarkNewPage.action?url={url}&title={title}&bookmarkVO.notes=', |
| 84 | embarkons: 'http://www.embarkons.com/sharer.php?u={url}&t={title}', |
| 85 | evernote: 'http://www.evernote.com/clip.action?url={url}&title={title}', |
| 86 | extraplay: 'http://www.extraplay.com/members/share.php?url={url}&title={title}&desc={text}', |
| 87 | ezyspot: 'http://www.ezyspot.com/submit?url={url}&title={title}', |
| 88 | fabulously40: 'http://fabulously40.com/writeblog?subject={title}&body={url}', |
| 89 | informazione: 'http://fai.informazione.it/submit.aspx?url={url}&title={title}&desc={text}', |
| 90 | fark: 'http://www.fark.com/cgi/farkit.pl?u={url}&h={title}', |
| 91 | farkinda: 'http://www.farkinda.com/submit?url={url}', |
| 92 | favable: 'http://www.favable.com/oexchange?url={url}&title={title}&desc={text}', |
| 93 | favlogde: 'http://www.favlog.de/submit.php?url={url}', |
| 94 | flaker: 'http://flaker.pl/add2flaker.php?title={title}&url={url}', |
| 95 | folkd: 'http://www.folkd.com/submit/{url}', |
| 96 | fresqui: 'http://fresqui.com/enviar?url={url}', |
| 97 | friendfeed: 'http://friendfeed.com/share?url={url}&title={title}', |
| 98 | funp: 'http://funp.com/push/submit/?url={url}', |
| 99 | fwisp: 'http://fwisp.com/submit.php?url={url}', |
| 100 | givealink: 'http://givealink.org/bookmark/add?url={url}&title={title}', |
| 101 | gmail: 'http://mail.google.com/mail/?view=cm&fs=1&to=&su={title}&body={text}&ui=1', |
| 102 | goodnoows: 'http://goodnoows.com/add/?url={url}', |
| 103 | google: 'http://www.google.com/bookmarks/mark?op=add&bkmk={url}&title={title}&annotation={text}', |
| 104 | googletranslate: 'http://translate.google.com/translate?hl=en&u={url}&tl=en&sl=auto', |
| 105 | greaterdebater: 'http://greaterdebater.com/submit/?url={url}&title={title}', |
| 106 | hackernews: 'http://news.ycombinator.com/submitlink?u={url}&t={title}', |
| 107 | hatena: 'http://b.hatena.ne.jp/bookmarklet?url={url}&btitle={title}', |
| 108 | hedgehogs: 'http://www.hedgehogs.net/mod/bookmarks/add.php?address={url}&title={title}', |
| 109 | hotmail: 'http://www.hotmail.msn.com/secure/start?action=compose&to=&subject={title}&body={{content}}', |
| 110 | w3validator: 'http://validator.w3.org/check?uri={url}&charset=%28detect+automatically%29&doctype=Inline&group=0', |
| 111 | ihavegot: 'http://www.ihavegot.com/share/?url={url}&title={title}&desc={text}', |
| 112 | instapaper: 'http://www.instapaper.com/edit?url={url}&title={title}&summary={text}', |
| 113 | isociety: 'http://isociety.be/share/?url={url}&title={title}&desc={text}', |
| 114 | iwiw: 'http://iwiw.hu/pages/share/share.jsp?v=1&u={url}&t={title}', |
| 115 | jamespot: 'http://www.jamespot.com/?action=spotit&u={url}&t={title}', |
| 116 | jumptags: 'http://www.jumptags.com/add/?url={url}&title={title}', |
| 117 | kaboodle: 'http://www.kaboodle.com/grab/addItemWithUrl?url={url}&pidOrRid=pid=&redirectToKPage=true', |
| 118 | kaevur: 'http://kaevur.com/submit.php?url={url}', |
| 119 | kledy: 'http://www.kledy.de/submit.php?url={url}&title={title}', |
| 120 | librerio: 'http://www.librerio.com/inbox?u={url}&t={title}', |
| 121 | linkuj: 'http://linkuj.cz?id=linkuj&url={url}&title={title}&description={text}&imgsrc=', |
| 122 | livejournal: 'http://www.livejournal.com/update.bml?subject={title}&event={url}', |
| 123 | logger24: 'http://logger24.com/?url={url}', |
| 124 | mashbord: 'http://mashbord.com/plugin-add-bookmark?url={url}', |
| 125 | meinvz: 'http://www.meinvz.net/Suggest/Selection/?u={url}&desc={title}&prov=addthis.com', |
| 126 | mekusharim: 'http://mekusharim.walla.co.il/share/share.aspx?url={url}&title={title}', |
| 127 | memori: 'http://memori.ru/link/?sm=1&u_data[url]={url}', |
| 128 | meneame: 'http://www.meneame.net/submit.php?url={url}', |
| 129 | mixi: 'http://mixi.jp/share.pl?u={url}', |
| 130 | moemesto: 'http://moemesto.ru/post.php?url={url}&title={title}', |
| 131 | myspace: 'http://www.myspace.com/Modules/PostTo/Pages/?u={url}&t={title}&c=', |
| 132 | n4g: 'http://www.n4g.com/tips.aspx?url={url}&title={title}', |
| 133 | netlog: 'http://www.netlog.com/go/manage/links/?view=save&origin=external&url={url}&title={title}&description={text}', |
| 134 | netvouz: 'http://netvouz.com/action/submitBookmark?url={url}&title={title}&popup=no&description={text}', |
| 135 | newstrust: 'http://newstrust.net/submit?url={url}&title={title}&ref=addthis', |
| 136 | newsvine: 'http://www.newsvine.com/_tools/seed&save?u={url}&h={title}&s={text}', |
| 137 | nujij: 'http://nujij.nl/jij.lynkx?u={url}&t={title}&b={text}', |
| 138 | oknotizie: 'http://oknotizie.virgilio.it/post?title={title}&url={url}', |
| 139 | oyyla: 'http://www.oyyla.com/gonder?phase=2&url={url}', |
| 140 | pdfonline: 'http://savepageaspdf.pdfonline.com/pdfonline/pdfonline.asp?cURL={url}', |
| 141 | pdfmyurl: 'http://pdfmyurl.com?url={url}', |
| 142 | phonefavs: 'http://phonefavs.com/bookmarks?action=add&address={url}&title={title}', |
| 143 | plaxo: 'http://www.plaxo.com/events?share_link={url}&desc={text}', |
| 144 | plurk: 'http://www.plurk.com/m?content={url}+({title})&qualifier=shares ', |
| 145 | posteezy: 'http://posteezy.com/node/add/story?title={title}&body={url}', |
| 146 | pusha: 'http://www.pusha.se/posta?url={url}&title={title}&description={text}', |
| 147 | rediff: 'http://share.rediff.com/bookmark/addbookmark?title={title}&bookmarkurl={url}', |
| 148 | redkum: 'http://www.redkum.com/add?url={url}&step=1&title={title}', |
| 149 | scoopat: 'http://scoop.at/submit?url={url}&title={title}&body={text}', |
| 150 | sekoman: 'http://sekoman.lv/home?status={title}&url={url}', |
| 151 | shaveh: 'http://shaveh.co.il/submit.php?url={url}&title={title}', |
| 152 | shetoldme: 'http://shetoldme.com/publish?url={url}&title={title}&body={text}', |
| 153 | sinaweibo: 'http://v.t.sina.com.cn/share/share.php?url={url}&title={title}', |
| 154 | sodahead: 'http://www.sodahead.com/news/submit/?url={url}&title={title}', |
| 155 | sonico: 'http://www.sonico.com/share.php?url={url}&title={title}', |
| 156 | springpad: 'http://springpadit.com/s?type=lifemanagr.Bookmark&url={url}&name={title}', |
| 157 | startaid: 'http://www.startaid.com/index.php?st=AddBrowserLink&type=Detail&v=3&urlname={url}&urltitle={title}&urldesc={text}', |
| 158 | startlap: 'http://www.startlap.hu/sajat_linkek/addlink.php?url={url}&title={title}', |
| 159 | studivz: 'http://www.studivz.net/Suggest/Selection/?u={url}&desc={title}&prov=addthis.com', |
| 160 | stuffpit: 'http://www.stuffpit.com/add.php?produrl={url}', |
| 161 | stumpedia: 'http://www.stumpedia.com/submit?url={url}', |
| 162 | svejo: 'http://svejo.net/story/submit_by_url?url={url}&title={title}&summary={text}', |
| 163 | symbaloo: 'http://www.symbaloo.com/en/add/?url={url}&title={title}', |
| 164 | thewebblend: 'http://thewebblend.com/submit?url={url}&title={title}', |
| 165 | thinkfinity: 'http://www.thinkfinity.org/favorite-bookmarklet.jspa?url={url}&subject={title}', |
| 166 | thisnext: 'http://www.thisnext.com/pick/new/submit/url/?description={text}&name={title}&url={url}', |
| 167 | tuenti: 'http://www.tuenti.com/share?url={url}', |
| 168 | typepad: 'http://www.typepad.com/services/quickpost/post?v=2&qp_show=ac&qp_title={title}&qp_href={url}&qp_text={text}', |
| 169 | viadeo: 'http://www.viadeo.com/shareit/share/?url={url}&title={title}&urlaffiliate=32005&encoding=UTF-8', |
| 170 | virb: 'http://virb.com/share?external&v=2&url={url}&title={title}', |
| 171 | visitezmonsite: 'http://www.visitezmonsite.com/publier?url={url}&title={title}&body={text}', |
| 172 | vybralisme: 'http://vybrali.sme.sk/sub.php?url={url}', |
| 173 | webnews: 'http://www.webnews.de/einstellen?url={url}&title={title}', |
| 174 | wirefan: 'http://www.wirefan.com/grpost.php?d=&u={url}&h={title}&d={text}', |
| 175 | wordpress: 'http://wordpress.com/wp-admin/press-this.php?u={url}&t={title}&s={text}&v=2', |
| 176 | wowbored: 'http://www.wowbored.com/submit.php?url={url}', |
| 177 | wykop: 'http://www.wykop.pl/dodaj?url={url}&title={title}&desc={text}', |
| 178 | yahoobkm: 'http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&u={url}&t={title}&d={text}', |
| 179 | yahoomail: 'http://compose.mail.yahoo.com/?To=&Subject={title}&body={{content}}', |
| 180 | yammer: 'https://www.yammer.com/home/bookmarklet?bookmarklet_pop=1&u={url}&t={title}', |
| 181 | yardbarker: 'http://www.yardbarker.com/author/new/?pUrl={url}&pHead={title}', |
| 182 | yigg: 'http://www.yigg.de/neu?exturl={url}&exttitle={title}&extdesc={text}', |
| 183 | yoolink: 'http://go.yoolink.to/addorshare?url_value={url}&title={title}', |
| 184 | yorumcuyum: 'http://www.yorumcuyum.com/?baslik={title}&link={url}', |
| 185 | youmob: 'http://youmob.com/mobit.aspx?title={title}&mob={url}', |
| 186 | zakladoknet: 'http://zakladok.net/link/?u={url}&t={title}', |
| 187 | ziczac: 'http://ziczac.it/a/segnala/?gurl={url}>it={title}', |
| 188 | whatsapp: 'whatsapp://send?text={url} {title}' |
| 189 | } |
| 190 | |
| 191 | function link(network){ |
| 192 | var url = templates[network]; |
| 193 | url = url.replace(/{url}/g, encodeURIComponent(options.url)); |
| 194 | url = url.replace(/{title}/g, encodeURIComponent(options.title)); |
| 195 | url = url.replace(/{text}/g, encodeURIComponent(options.text)); |
| 196 | url = url.replace(/{image}/g, encodeURIComponent(options.image)); |
| 197 | return url; |
| 198 | } |
| 199 | |
| 200 | return this.each(function(i, elem){ |
| 201 | var classlist = get_class_list(elem); |
| 202 | for(var i = 0; i < classlist.length; i++){ |
| 203 | var cls = classlist[i]; |
| 204 | if(cls.substr(0, class_prefix_length) == options.class_prefix && templates[cls.substr(class_prefix_length)]){ |
| 205 | var final_link = link(cls.substr(class_prefix_length)); |
| 206 | $(elem).attr('href', final_link).click(function(){ |
| 207 | if($(this).attr('href').indexOf('http://') === -1 && $(this).attr('href').indexOf('https://') === -1){ |
| 208 | return window.open($(this).attr('href')) && false; |
| 209 | } |
| 210 | var screen_width = screen.width; |
| 211 | var screen_height = screen.height; |
| 212 | var popup_width = options.width ? options.width : (screen_width - (screen_width*0.2)); |
| 213 | var popup_height = options.height ? options.height : (screen_height - (screen_height*0.2)); |
| 214 | var left = (screen_width/2)-(popup_width/2); |
| 215 | var top = (screen_height/2)-(popup_height/2); |
| 216 | var parameters = 'toolbar=0,status=0,width=' + popup_width + ',height=' + popup_height + ',top=' + top + ',left=' + left; |
| 217 | return window.open($(this).attr('href'), '', parameters) && false; |
| 218 | }); |
| 219 | } |
| 220 | } |
| 221 | }); |
| 222 | } |
| 223 | |
| 224 | $.fn.ShareCounter = function(options){ |
| 225 | var defaults = { |
| 226 | url: window.location.href, |
| 227 | class_prefix: 'c_', |
| 228 | display_counter_from: 0, |
| 229 | increment: false |
| 230 | }; |
| 231 | |
| 232 | var options = $.extend({}, defaults, options); |
| 233 | |
| 234 | var class_prefix_length = options.class_prefix.length |
| 235 | |
| 236 | var social = { |
| 237 | 'vk': vk, |
| 238 | 'myworld': myworld, |
| 239 | 'linkedin': linkedin, |
| 240 | 'odnoklassniki': odnoklassniki, |
| 241 | 'pinterest': pinterest, |
| 242 | 'plus': plus, |
| 243 | 'facebook': facebook |
| 244 | } |
| 245 | |
| 246 | return this.each(function(i, elem){ |
| 247 | var classlist = get_class_list(elem); |
| 248 | for(var i = 0; i < classlist.length; i++){ |
| 249 | var cls = classlist[i]; |
| 250 | if(cls.substr(0, class_prefix_length) == options.class_prefix && social[cls.substr(class_prefix_length)]){ |
| 251 | social[cls.substr(class_prefix_length)](options.url, function(count){ |
| 252 | count = parseInt(count); |
| 253 | if (count >= options.display_counter_from){ |
| 254 | var current_value = parseInt($(elem).text()); |
| 255 | if(options.increment && !isNaN(current_value)){ |
| 256 | count += current_value; |
| 257 | } |
| 258 | $(elem).text(count); |
| 259 | } |
| 260 | }) |
| 261 | } |
| 262 | } |
| 263 | }); |
| 264 | |
| 265 | function vk(url, callback){ |
| 266 | if(window.VK === undefined){ |
| 267 | VK = { |
| 268 | CallbackList: [], |
| 269 | Share: { |
| 270 | count: function(idx, value){ |
| 271 | VK.CallbackList[idx](value); |
| 272 | } |
| 273 | } |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | var current_callback_index = VK.CallbackList.length; |
| 278 | VK.CallbackList.push(callback); |
| 279 | |
| 280 | $.ajax({ |
| 281 | type: 'GET', |
| 282 | dataType: 'jsonp', |
| 283 | url: 'https://vk.com/share.php', |
| 284 | data: {'act': 'count', 'index': current_callback_index, 'url': url} |
| 285 | }) |
| 286 | .fail(function(data, status){ |
| 287 | if(status != 'parsererror'){ |
| 288 | for(i in VK.CallbackList){ |
| 289 | VK.CallbackList[i](0) |
| 290 | } |
| 291 | } |
| 292 | }) |
| 293 | } |
| 294 | |
| 295 | function myworld(url, callback){ |
| 296 | var results = []; |
| 297 | $.ajax({ |
| 298 | type: 'GET', |
| 299 | dataType: 'jsonp', |
| 300 | url: 'https://connect.mail.ru/share_count', |
| 301 | jsonp: 'func', |
| 302 | data: {'url_list': url, 'callback': '1'} |
| 303 | }) |
| 304 | .done(function(data){callback(data[url].shares)}) |
| 305 | .fail(function(data){callback(0)}) |
| 306 | } |
| 307 | |
| 308 | function linkedin(url, callback){ |
| 309 | $.ajax({ |
| 310 | type: 'GET', |
| 311 | dataType: 'jsonp', |
| 312 | url: 'https://www.linkedin.com/countserv/count/share', |
| 313 | data: {'url': url, 'format': 'jsonp'} |
| 314 | }) |
| 315 | .done(function(data){callback(data.count)}) |
| 316 | .fail(function(){callback(0)}) |
| 317 | } |
| 318 | |
| 319 | function odnoklassniki(url, callback){ |
| 320 | if(window.ODKL === undefined){ |
| 321 | ODKL = { |
| 322 | CallbackList: [], |
| 323 | updateCount: function(uid, value){ |
| 324 | ODKL.CallbackList[parseInt(uid)](value); |
| 325 | } |
| 326 | } |
| 327 | } |
| 328 | |
| 329 | var current_callback_index = ODKL.CallbackList.length; |
| 330 | ODKL.CallbackList.push(callback); |
| 331 | |
| 332 | $.ajax({ |
| 333 | type: 'GET', |
| 334 | dataType: 'jsonp', |
| 335 | url: 'https://ok.ru/dk', |
| 336 | data: {'st.cmd': 'extLike', 'ref': url, 'uid': current_callback_index} |
| 337 | }) |
| 338 | .fail(function(data, status){ |
| 339 | if(status != 'parsererror'){ |
| 340 | for(i in ODKL.CallbackList){ |
| 341 | ODKL.CallbackList[i](0) |
| 342 | } |
| 343 | } |
| 344 | }) |
| 345 | } |
| 346 | |
| 347 | function pinterest(url, callback){ |
| 348 | $.ajax({ |
| 349 | type: 'GET', |
| 350 | dataType: 'jsonp', |
| 351 | url: 'https://api.pinterest.com/v1/urls/count.json', |
| 352 | data: {'url': url} |
| 353 | }) |
| 354 | .done(function(data){callback(data.count)}) |
| 355 | .fail(function(){callback(0)}) |
| 356 | } |
| 357 | |
| 358 | function plus(url, callback){ |
| 359 | $.ajax({ |
| 360 | type: 'POST', |
| 361 | url: 'https://clients6.google.com/rpc', |
| 362 | processData: true, |
| 363 | contentType: 'application/json', |
| 364 | data: JSON.stringify({ |
| 365 | 'method': 'pos.plusones.get', |
| 366 | 'id': location.href, |
| 367 | 'params': { |
| 368 | 'nolog': true, |
| 369 | 'id': url, |
| 370 | 'source': 'widget', |
| 371 | 'userId': '@viewer', |
| 372 | 'groupId': '@self' |
| 373 | }, |
| 374 | 'jsonrpc': '2.0', |
| 375 | 'key': 'p', |
| 376 | 'apiVersion': 'v1' |
| 377 | }) |
| 378 | }) |
| 379 | .done(function(data){callback(data.result.metadata.globalCounts.count)}) |
| 380 | .fail(function(){callback(0)}) |
| 381 | } |
| 382 | |
| 383 | function facebook(url, callback){ |
| 384 | $.ajax({ |
| 385 | type: 'GET', |
| 386 | dataType: 'jsonp', |
| 387 | url: 'https://graph.facebook.com', |
| 388 | data: {'id': url} |
| 389 | }) |
| 390 | .done(function (data){ |
| 391 | if(data.share != undefined && data.share.share_count != undefined){ |
| 392 | callback(data.share.share_count) |
| 393 | } |
| 394 | }) |
| 395 | .fail(function(){callback(0)}) |
| 396 | } |
| 397 | } |
| 398 | })(jQuery); |
| 399 |