virt2/api/jquery/plugins/pluso/pluso-like.js

3 lines
41 KiB
JavaScript
Raw Normal View History

(function(w,d){var prot=/^((https|chrome-extension):)/i.test(w.location.protocol)?"https":"http",u=prot+"://share.pluso.ru",uid="3892109012292373999",tags="getElementsByTagName",h=d[tags]("body")[0],b=d.documentElement,db=d.body,compat=0;function js(url,id,callback){if(typeof id=="function"){callback=id;id=null}if(id&&d.getElementById(id))return;if(url.charAt(0)=="+")url=u+"/"+url.substring(1);s=d.createElement("script");s.type="text/javascript";s.charset="UTF-8";s.async=true;if(typeof id=="string")s.id=id;s.src=url;if(typeof callback=="function"){var called=false;s.onreadystatechange=function(){if(this.readyState=="complete"&&!called){called=true;callback()}};s.onload=function(){if(!called){called=true;callback()}}}h.appendChild(s)}function styled(rules){var s=d.createElement("style");s.setAttribute("type","text/css");h.appendChild(s);if(s.styleSheet){s.styleSheet.cssText=rules}else{s.appendChild(d.createTextNode(rules))}}function pointed(event){return{pageX:typeof event.pageX!="undefined"?event.pageX:event.clientX+d.body.scrollLeft+b.scrollLeft,pageY:typeof event.pageY!="undefined"?event.pageY:event.clientY+d.body.scrollTop+b.scrollTop}}function dimensions(){return{width:w.innerWidth||b.clientWidth||db&&db.clientWidth,height:Math.max(db&&db.scrollHeight,db&&db.offsetHeight,b.clientHeight,b.scrollHeight,b.offsetHeight)}}function numk(num,mini){var d=typeof mini!="undefined"?0:1;if(num>=1e9){return(num/1e9).toFixed(d).replace(/\.0$/,"")+"G"}if(num>=1e6){return(num/1e6).toFixed(d).replace(/\.0$/,"")+"M"}if(num>=1e3){return(num/1e3).toFixed(d).replace(/\.0$/,"")+"K"}return num}function osize(opt){return opt.small==1?"small":opt.medium==1?"medium":"big"}function getImg(url){var img;try {img = new Image();} catch (ignore) {img = document.createElement("img");}img.src = url;}function rnd(min,max){if(!max){max=min;min=0}return Math.floor(Math.random()*(max-min+1))+min}if(!Array.indexOf){Array.prototype.indexOf=function(obj){for(var i=0,l=this.length;i<l;i++){if(this[i]==obj){return i}}return-1}}if(!Array.prototype.map){Array.prototype.map=function(f){var result=[];for(var i=0,l=this.length;i<l;i++){result.push(f(this[i]))}return result}}var iterate=function(obj,callback){for(var key in obj)if(obj.hasOwnProperty(key))callback(key,obj)};var elements=d.querySelectorAll?function(className,context){return(context||d).querySelectorAll("."+className)}:function(className,context){if(!className)return[];var e=(context||d)[tags]("*");var list=[];for(var i=0,length=e.length;i<length;i++){var clss=e[i].className.split(" ");if(clss.indexOf(className)>-1)list.push(e[i])}return list};var encode=encodeURIComponent;var cloned=function(obj){if(typeof obj.length!="undefined")return obj.slice(0);var clone={};for(var i in obj){if(typeof obj[i]=="object")clone[i]=cloned(obj[i]);else clone[i]=obj[i]}return clone};var arrayed=function(obj){return Object.prototype.toString.call(obj)==="[object Array]"};var lang=function(elem,service,title){var language=elem.pluso.params.lang;if(title){return pluso.lang[language]&&pluso.lang[language].titles&&pluso.lang[language].titles[service]||title}else return pluso.lang[language]&&pluso.lang[language][service]||pluso.lang["ru"]&&pluso.lang["ru"][service]||service};var ready=function(w,d){var inited=false,loaded=false,queue=[],done,old;function go(){if(!inited){if(!d.body)return setTimeout(go,13);inited=true;if(queue){var j,k=0;while(j=queue[k++])j.call(null);queue=null}}}function check(){if(loaded)return;loaded=true;if(d.readyState==="complete")return go();if(d.addEventListener){d.addEventListener("DOMContentLoaded",done,false);w.addEventListener("load",go,false)}else{if(d.attachEvent){d.attachEvent("onreadystatechange",done);w.attachEvent("onload",go);var k=false;try{k=w.frameElement==null}catch(j){}if(b.doScroll&&k)ie()}else{old=w.onload;w.onload=function(e){old(e);go()}}}}if(d.addEventListener){done=function(){d.removeEventListener("DOMContentLoaded",done,false);go()}}else{if(d.attachEvent){done=function(){if(d.readyState==="complete"){d.detachEvent("onreadystatechange",done);go()}}}}function ie(){if(inited)re
};pluso.share_pinme=function(){js("http://st.pinme.ru/js/pinbutton.js?r="+Math.random()*99999999)};pluso.share_readability=function(){js("http://www.readability.com/bookmarklet/save.js?r="+Math.random()*99999999)};pluso.share_print=function(){window.print()};pluso.share_bookmark=function(ep){if(typeof window.sidebar=="object"&&typeof window.sidebar.addPanel=="function"){window.sidebar.addPanel(ep.params.title,ep.params.url,"")}else if(typeof window.external=="object"&&!window.chrome){window.external.AddFavorite(ep.params.url,ep.params.title)}else prompt("Скопируйте и добавьте эту ссылку в Закладки",ep.params.url)};pluso.share_email=function(ep){var link="mailto:?Subject="+ep.params.title+"&body="+encodeURIComponent(ep.params.url)+"%0A";window.open(link,"mailto")};pluso.params=function(elem){return"u="+encode(elem.pluso.params.url)+(pluso.screenWidth&&pluso.screenHeight?"&w="+pluso.screenWidth+"&h="+pluso.screenHeight:"")+"&ref="+encode(d.referrer)+(elem.pluso.params.user>0?"&user="+encode(elem.pluso.params.user):"")+"&uid="+uid+"&k="+pluso.randomString(16)};pluso.share=function(t,elem,menu){var sharer=t.className.substring(6),share=pluso["share_"+sharer],sharelink=pluso.sharelink(sharer,elem,menu);pluso.counter[elem.pluso.params.url]+=1;elem.counter.title=pluso.counter[elem.pluso.params.url];elem.counter.innerHTML=numk(pluso.counter[elem.pluso.params.url]);if(elem.pluso.options.sepcounter=="1"){var serviceClass=t.className;if(!pluso.sepcounters[sharer])pluso.sepcounters[sharer]=0;pluso.sepcounters[sharer]=parseInt(pluso.sepcounters[sharer])+1;var serviceCounter=t.parentNode.getElementsByTagName("b")[0];serviceCounter.title=pluso.sepcounters[sharer];serviceCounter.innerHTML=numk(pluso.sepcounters[sharer])}if(typeof share=="function"){js(sharelink);if(window.opera&&sharer=="bookmark"){t.href=elem.pluso.params.url;return true}else{share(elem.pluso)}}else{if(!window.open(sharelink,sharer,pluso.tabbed.indexOf(sharer)==-1?"toolbar=0,status=0,resizable=1,width=626,height=436":"")){w.location.href=sharelink}}return false};pluso.more=function(xy,elem){if(elem.box){var div=elem.box}else{var div=d.createElement("div"),html=[];div.className="pluso-box";html.push('<a href="'+u+'/?new_a" target="_blank" class="pluso-logo">+PLUSO</a>');html.push('<a href="'+u+'/?new_a" target="_blank" class="pluso-go">'+lang(elem,"get")+"</a>");html.push('<a href="#close" title="'+lang(elem,"close")+'" class="pluso-close">&times;</a>');html.push('<div class="pluso-list">');for(var i=0,l=pluso.titles.length;i<l;i++){p=pluso.titles[i];pt=lang(elem,p[0],p[1]);html.push('<a href="'+elem.pluso.params.url.replace(/"/g,"&quot;")+'" title="'+pt+'" class="pluso-'+p[0]+'"'+(p[0]=="bookmark"?' rel="sidebar"':"")+"><b></b>"+pt+"</a>")}var bn=Math.random()>.5?"1":"2";html.push('<a class="pluso-promo" style="display:block;width:100%;height:200px;margin:0;padding:0;background:url('+u+"/img/pluso-like/promo_"+bn+'.png) center center no-repeat" href="http://watson.pluso.com/?new'+(bn==1?"chromeaddon":"music")+'" target="_blank"></a>');html.push("</div>");div.innerHTML=html.join("");div.onmouseover=function(ev){if(div.timer)clearTimeout(div.timer)};div.onmouseout=function(ev){var ev=ev||w.event,e=ev.toElement||ev.relatedTarget,t=ev.target||ev.srcElement;if(e&&e.tagName&&e.tagName.toUpperCase()=="B")e=e.parentNode;if(!e||e==div||e.parentNode==div||e.parentNode.parentNode==div){return false}div.timer=setTimeout(function(){div.style.display="none"},777)};div.onclick=pluso.click(elem,1)}if(elem.box&&elem.box.style.display=="block")return;var z=pluso.offsets[osize(elem.pluso.options)]/2,x=xy.pageX-z,y=xy.pageY-z,ws=dimensions();if(x<0)x=10;else if(x+310>ws.width)x=ws.width-350;if(y<0)y=5;else if(y+265>ws.height)y=ws.height-265;div.style.left=x+"px";div.style.top=y+"px";if(elem.box){elem.box.style.display="block"}else{elem.box=div;d[tags]("body")[0].appendChild(div)}pluso.process("menu",elem)};pluso.sharelink=function(sharer,elem,menu){var k=d.getSelection,y=w.getSelection,x=d.selection;var s=y?y():k?k():x?x.createRange().text:0;return u+