«Одноклассники»: 10 лет спустя — Инфографика vc.ru к юбилею соцсети

').appendTo (currentForm.find (».js-attachments»)); currentForm.find (».js-attachments .attachment: last input»).click (); return false; });

// Form: image file attaching $(«body»).on («change»,».attachment input[type='file']», function (){ var input = this; //console.log ($(input).val ()); if (input.files && input.files[0]) { var reader = new FileReader (); reader.onload = function (e) { var src = e.target.result; $(''%20+%20src%20+%20'') .load (function (){ //console.log ($(input).val ()); //console.log (src); //console.log ($(input).clone ().val ()); //$(input).clone ().appendTo ($(input).parent ()); $(input).parent ().find («img»).attr («src», src); $(input).parent ().removeClass («empty»); $.fancybox.close (); }(input)) .error (function (){ //NOT IMAGE }) } reader.readAsDataURL (input.files[0]); } });

// Form: image link attaching by click $(«body»).on («click»,».b-attach__image__link a», function (){ input = $(this).parent ().find («input»); url = input.val (); input.addClass («loading»); verifyImage (url, function (url, result) { if (result) { $('').appendTo (currentForm.find (».js-attachments»)); var timer = setTimeout (function (){ input.val (»).removeClass («loading»); $.fancybox.close (); }, 200); } else { input.removeClass («loading»); // NOT IMAGE } }); return false; });

// Form: video link attaching by click $(«body»).on («click»,».b-attach__video__link a», function (){

input = $(this).parent ().find («input»); url = input.val (); input.addClass («loading»);

if (parseYoutube (url) || parseCoub (url) || parseVimeo (url)){ if (parseYoutube (url)){ pic = «https://img.youtube.com/vi/» + parseYoutube (url) + »/0.jpg»; $('').appendTo (currentForm.find (».js-attachments»)); } if (parseCoub (url)){ pic_url = »/static/main/img/ui/attach.coub.png»; $('').appendTo (currentForm.find (».js-attachments»)); } if (parseVimeo (url)){ $.ajax ({ type:'GET', url: 'https://vimeo.com/api/oembed.json? url=' + url, jsonp: 'callback', dataType: 'jsonp', success: function (data){ pic_url = data.thumbnail_url; $('').appendTo (currentForm.find (».js-attachments»)); } }); } $.fancybox.close (); input.val (»).removeClass («loading»); } else { //NOT YOUTUBE input.removeClass («loading»); } return false; });

// Form: coub link attaching by click $(«body»).on («click»,».b-attach__coub__link a», function (){

input = $(this).parent ().find («input»); url = input.val (); input.addClass («loading»);

if (coub_parser (url)){ pic_url = »/static/main/img/ui/attach.coub.png»; $('').appendTo (currentForm.find (».js-attachments»)); $.fancybox.close (); } else { //NOT COUB } input.val (»).removeClass («loading»); return false; });

// Form: image, video and coub link attaching by timeout $(«body»).on («input»,».b-attach__image__link input, .b-attach__video__link input, .b-attach__coub__link input», function (){ if ($(this).val ().length > 0) { link = $(this).parent ().find («a»); clearTimeout (window.attachInputTimer); window.attachInputTimer = setTimeout (function (){ link.click (); }, 500); } });

// Form: link-attaching: youtube parser function parseYoutube (url){ var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\? v?=?([^#\&\?]*).*/; var match = url.match (regExp); if (match&&match[7].length==11){ return match[7]; } else { return false; } }

// Form: link-attaching: coub parser function parseCoub (url){ var regExp = /^.*(coub.com\/view\/).*/; var match = url.match (regExp); if (match){ return url; } else { return false; } }

// Form: link-attaching: vimeo parser function parseVimeo (url){ var regExp = /(?: vimeo (?: pro)?.com)\/(?:[^\d]+)?(\d+)(?:.*)/; var match = url.match (regExp); if (match){ return url; } else { return false; } }

// Form: link-attaching: image verifying function verifyImage (url, callback, timeout) { timeout = timeout || 10000; var timedOut = false, timer; var img = new Image (); img.onerror = img.onabort = function () { if (! timedOut) { clearTimeout (timer); callback (url, false); } }; img.onload = function () { if (! timedOut) { clearTimeout (timer); callback (url, true); } }; img.src = url; timer = setTimeout (function () { timedOut = true; callback (url, false); }, timeout); }

// Form: delete attaches $(«body»).on («click»,».js-attachments .attachment .x», function (){ $(this).parents (».attachment»).remove (); return false; });

$.timeago.settings.strings.suffixAgo = 'назад'; $('time.timeago').timeago ();

$(«body»).on («keydown»,».comment-add textarea», function (e) { if ((e.metaKey || e.ctrlKey) && (e.keyCode == 10 || e.keyCode == 13)) { $(this).parent ().parent ().find ('.submit').click (); e.preventDefault (); } });

// Comment add: login and submit $(«body»).on («click»,».login a», function (){ saveComment ($(this).parents («form»).find («textarea»).val ()); });

// Comment: video embedding $(«body»).on («click»,».video-preview», function (){ $(this).hide (); $(this).before (''); return false; });

// Comment: add reply form $(«body»).on («click»,».reply-button a.reply», function (){ if (!$(this).hasClass («disabled»)){ $('.comment-add.reply').remove (); var reply_comment = $('.comment-add').clone (); reply_comment.find (».in_reply_to_comment_id»).val ($(this).attr («data-comment-id»));

if (reply_comment.hasClass («payment»)){

if (reply_comment.hasClass («not-logined»)){ reply_comment.find (».l a»).each (function (){ $(this).attr («href», $(this).attr («href») + »#reply» + reply_comment.find (».in_reply_to_comment_id»).attr («value»)); }); } else { reply_comment.find (».btn_darkgreen»).attr («href», reply_comment.find (».btn_darkgreen»).attr («href») + »#reply» + reply_comment.find (».in_reply_to_comment_id»).attr («value»)); }

}

reply_comment.addClass («reply»).insertAfter ($(this).parents (».comment»)); reply_comment.find ('textarea').focus (); } return false; });

// Comment: rating marks: scroll $('.rating .marks.scroll .wrap-list').slimscroll ({ wheelStep: 3, width: '240 px', height: '248 px' });

// Comment: rating marks: toggle by click $(«body»).on («click»,».rating-count», function (){ $(this).parents (».rating»).find (».marks: not (.empty)»).toggle (); return false; });

// Comment: rating marks: toggle by mouseover $(«body»).on («mouseenter»,».rating-count», function (){ var rc = $(this); var st = setTimeout (function (){ rc.parents (».rating»).find (».marks: not (.empty)»).show (); /* console.log ('rating-count.mouseenter'); */ }, 500); rc.parents ('.comment').find ('.rating').mouseleave (function (){ clearTimeout (st); rt = setTimeout (function (){ rc.parents (».rating»).find (».marks: not (.empty)»).fadeOut («fast»); /* console.log ('rating.mouseleave'); */ }, 500); }); });

// Comment: add reply form by hash if (window.location.hash) { if (window.location.hash.indexOf (»#reply») != -1){ comment_id = window.location.hash.replace ('#reply', '#comment'); $(comment_id).find (».reply-button»).click (); } if (window.location.hash.indexOf (»#comment») != -1){ comment_id = window.location.hash.replace ('#comment', '#commentBox'); $(comment_id).addClass («highlight»); } }

// Comment: like and dislike $(«body»).on («click»,».comment-vote: not (.active)», function (){ var vote = $(this); var rating = $(this).parents (».rating»); var list = rating.find (».marks ul»); var comment_id = $(this).attr («data-comment-id»); var sign = $(this).attr («data-sign»); var hash = $(this).attr («data-hash»);

$.post ('/helper/like', { commentId: comment_id, sign: sign, hash: hash }, function (data, textStatus) {

//console.log (data);

if (typeof data.error == «undefined» || data.error == 'undefined') {

if (data.likes_count > 0) { var text = data.likes_count; rating.addClass ('positive').removeClass ('negative'); } else if (data.likes_count '+u.profile_image_url+''+u.name+''); list.parents (».marks»).removeClass («empty»); }

rating.find (».rating-count»).text (text);

} else {

showStatusTip (data.error, 'error');

}

}, 'json'); return false; });

// Comment: highlight the answers $(«body»).on («mouseover»,».b-comment__return a», function (){ var reply_link = $(this); var click = false; $(».b-comment»).removeClass («highlight»); $(reply_link.attr («href»).replace ('#comment', '#commentBox')).addClass («highlight»);

reply_link.on ('click', function (){ click = true; }); reply_link.on ('mouseleave', function (){ if (! click){ rt = setTimeout (function (){ $(reply_link.attr («href»).replace ('#comment', '#commentBox')).removeClass («highlight»); }, 100); } }); });

// Comment: highlight the answers $(«body»).on («click»,».b-comment__return a», function (){ var reply_link = $(this); $(reply_link.attr («href»).replace ('#comment', '#commentBox')).addClass («highlight»); clearTimeout (rt); });

var isTouchDevice = 'ontouchstart' in document.documentElement;

if (isTouchDevice){

$(«body»).on («click tap»,».comment», function (){ $(».comment»).removeClass («touched»); $(this).addClass («touched»); });

$(«body»).on («click tap»,».comment .m-thumbs-up», function (){ $(this).parents (».comment»).find (».thumbs-up»).click (); $(this).parents (».comment»).removeClass («touched»); return false; });

$(«body»).on («click tap»,».comment .m-thumbs-down», function (){ $(this).parents (».comment»).find (».thumbs-down»).click (); $(this).parents (».comment»).removeClass («touched»); return false; });

$(«body»).on («click tap»,».comment .m-reply», function (){ $(this).parents (».comment»).find (».reply-button .reply»).click (); $(this).parents (».comment»).removeClass («touched»); return false; });

}

});

©  vc.ru