function cocorawurlencode(st) { st=(st+'').toString().replace(/~/g,'%7E'); st = encodeURIComponent(st).replace(/\*/g, '%2A').replace(/'/g,'%27').replace(/\(/g, '%28').replace(/!/g,'%21').replace(/\)/g, '%29').replace(/&/g,'%26').replace(/\/g,'%3e'); if (st.length>300) { ipr=st.indexOf('%',299); if ((st.substr(ipr,3)=='%D0')||(st.substr(ipr,3)=='%D1')) ipr=ipr-3; st=st.substr(0,ipr+3)+'...'; } return st; } function cocodatetime() { cocoDate = new Date(); return cocoDate.getFullYear()+'-'+(cocoDate.getMonth()+1)+'-'+cocoDate.getDate()+' '+cocoDate.getHours()+':'+cocoDate.getMinutes()+':'+cocoDate.getSeconds(); } function cocopost(url) { var XHttp; try { XHttp=new XMLHttpRequest(); } catch (e) { try { XHttp=new ActiveXObject('Msxml2.XMLHTTP'); } catch (e) { try { XHttp=new ActiveXObject('Microsoft.XMLHTTP'); } catch (e) { /*alert('error!');*/ return false; } } } XHttp.withCredentials = true; XHttp.open('POST','http://www.ecolora.net/index.php/en/?option=com_coco&format=raw'+url,true); XHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); XHttp.onreadystatechange=function() { var rsp; if(XHttp.readyState==4){ setTimeout(function(){ rsp = XHttp.responseText; },2500); } } /*XHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');*/ try { XHttp.send(null); } catch (e) { request.send(); } } function coconew() { if (typeof VK != 'undefined') VK.Observer.subscribe('widgets.comments.new_comment',function(num,last_comment,date,sign){ cocopost('&num='+num+'&comm='+cocorawurlencode(last_comment)+'&date='+date+'&chks='+sign+'&title='+cocorawurlencode(document.title)+'&task=add&ct=2'); }); if (typeof VK != 'undefined') VK.Observer.subscribe('widgets.comments.delete_comment',function(num,last_comment,date,sign){ cocopost('&num='+num+'&comm='+cocorawurlencode(last_comment)+'&date='+date+'&chks='+sign+'&title='+cocorawurlencode(document.title)+'&task=del&ct=2'); }); }; window.fbAsyncInit = function(){ FB.init({appId: '156744554411092', status: true, cookie: true, xfbml: true}); FB.Event.subscribe('comment.create', function(response) { FB.api({method: 'fql.query','query':'SELECT post_fbid, text, time FROM comment WHERE object_id IN (SELECT comments_fbid FROM link_stat WHERE url ="'+response.href+'")'}, function(response1) { for(var i = 0; i < response1.length; i++) { if (response1[i].post_fbid == response.commentID) cocopost('&comm='+cocorawurlencode(response1[i].text)+'&date='+response1[i].time+'&chks='+0+'&title='+cocorawurlencode(document.title)+'&task=add&ct=1'); } } ); }); FB.Event.subscribe('comment.remove', function(response) { cocopost('&comm='+''+'&date='+cocodatetime()+'&chks='+0+'&title='+cocorawurlencode(document.title)+'&task=del&ct=1'); }); /*response.href; console.info(response); response.commentID*/ }; if (window.addEventListener) { window.addEventListener('load',coconew,false); } else if (window.attachEvent) { window.attachEvent('onload',coconew); } else { window.onload = function() {coconew();} };