PageSourceSearch

https://newsland.com/js/comment.js?v=0.2.2495470

js newsland.com collected 2026-10-02 03:47:17 UTC 8,493 bytes, 1 lines download raw bytes

1function getErrorMessageForPostComment(response,message){let status=response.status;if(response.headers.get("X-USER-BANNED")){return"Вы забанены, поэтому некоторые функции сайта для вас недоступны"}if(status==403){if(message=="daily limit")return"Запрещено. Возможно, дневной лимит добавления комментариев исчерпан.";if(message.startsWith("blacklist")){let who_is_blocked=message.split(" ")[1];let type=message.split(" ")[2];let id=message.split(" ")[3];let link_src="/user/"+id;let who_type=who_is_blocked+" "+type;if(who_type=="you post")return`<span><a href="${link_src}">Автор поста</a> добавил вас в черный список.</span>`;if(who_type=="you comment")return`<span><a href="${link_src}">Автор комментария</a> добавил вас в черный список.</span>`;if(who_type=="he post")return`<span>Вы добавили <a href="${link_src}">автора поста</a> в черный список.</span>`;if(who_type=="he comment")return`<span>Вы добавили <a href="${link_src}">автора комментария</a> в черный список.</span>`}return"Запрещено."}if(status==500)return"Ошибка сервера.";if(status==400)return"Некорректные данные.";return"Неизвестная ошибка."}async function postComment(post_id,user_id,comment,reply_id){let commonMessageArea=document.getElementById("commonMessageArea");printMessage(commonMessageArea);try{let response=await fetch("/api/add-comment",{method:"POST",body:JSON.stringify({post_id:post_id,user_id:user_id,comment:comment,...reply_id&&{reply:reply_id}}),headers:{Accept:"application/json","Content-Type":"application/json","CSRF-Token":document.querySelector('meta[name="csrf-token"]').getAttribute("content")}});let message=null;try{message=(await response.json()).message}catch(e){console.error(e)}if(response.ok&&message&&message.comment_id){return message.comment_id}else{printMessage(commonMessageArea,getErrorMessageForPostComment(response,message),"error")}}catch(err){printMessage(commonMessageArea,"Проверьте, пожалуйста, соединение с интернетом","error");console.error(err)}return false}async function addCommentFunction(postId,postAuthorId,postStatus,userId,comment){if(!comment){return}if(postStatus!=1){let blackStatus=await whoIsBlocked(postAuthorId);if(blackStatus==1||blackStatus==2){let message="";if(blackStatus==1){message=`<span><a href="/user/${postAuthorId}">Автор поста</a> добавил вас в черный список. Комментарий не будет сохранен.</span>`}else if(blackStatus==2){message=`<span>Вы добавили <a href="/user/${postAuthorId}">автора поста</a> в черный список. Комментарий не будет сохранен.</span>`}printMessage(commonMessageArea,message,"error");return}}let addCommentForm=document.getElementById("addCommentForm");if(addCommentForm){addCommentForm.classList.add("hide-comment-form");let commentId=await postComment(postId,userId,comment);if(commentId){window.location.hash=`#comment_${commentId}`;window.location.reload(true);return}addCommentForm.classList.remove("hide-comment-form")}addCommentForm.classList.remove("hide-comment-form")}async function addReplyFunction(postId,parentAuthorId,userId,replyId,reply){if(!reply){return}if(parentAuthorId){let blackStatus=await whoIsBlocked(parentAuthorId);if(blackStatus==1||blackStatus==2){let message="";if(blackStatus==1){message=`<span><a href="/user/${parentAuthorId}">Автор комментария</a> добавил вас в черный список. Комментарий не будет сохранен.</span>`}else if(blackStatus==2){message=`<span>Вы добавили <a href="/user/${parentAuthorId}">автора комментария</a> в черный список. Комментарий не будет сохранен.</span>`}printMessage(commonMessageArea,message,"error");return}}let addReplyForm=document.getElementById("addReplyForm");if(addReplyForm){addReplyForm.classList.add("hide-comment-form");let commentId=await postComment(postId,userId,reply,replyId);if(commentId){window.location.hash=`#comment_${commentId}`;window.location.reload(true);return}addReplyForm.classList.remove("hide-comment-form")}addCommentForm.classList.remove("hide-comment-form")}function commentRatingPlus(id){fetch("/rating/comment/"+id,{method:"POST",body:JSON.stringify({data:"plus"}),headers:{Accept:"application/json","Content-Type":"application/json","CSRF-Token":document.querySelector('meta[name="csrf-token"]').getAttribute("content")}}).then(async function(response){var indicator=$(`#rating_${id}`);let commentRatingContainer=document.querySelector(`.comment-rating[data-id="${id}"]`);commentRatingContainer.classList.remove("my-choise--1","my-choise-1","my-choise-0");var cnt=parseInt(indicator.first().text());switch(response.status){case 202:indicator.text(cnt-1);break;case 200:cnt+=1;case 201:indicator.text(cnt+1);commentRatingContainer.classList.add("my-choise-1");break;case 403:if(response.headers.get("content-type")==="application/json; charset=utf-8"){let blackData=await response.json();let message="";if(blackData&&blackData.code==="1"){message=`<span><a href="/user/${blackData.opponent_id}">Автор комментария</a> добавил вас в черный список. Голос не будет сохранен.</span>`}else if(blackData&&blackData.code==="2"){message=`<span>Вы добавили <a href="/user/${blackData.opponent_id}">автора комментария</a> в черный список. Голос не будет сохранен.</span>`}if(printMessage&&typeof printMessage==="function"&&commonMessageArea&&commonMessageArea instanceof HTMLElement){printMessage(commonMessageArea,message,"error")}}break;case 401:formOpen();break;default:}})}function commentRatingMinus(id){fetch("/rating/comment/"+id,{method:"POST",body:JSON.stringify({data:"minus"}),headers:{Accept:"application/json","Content-Type":"application/json","CSRF-Token":document.querySelector('meta[name="csrf-token"]').getAttribute("content")}}).then(async function(response){var indicator=$(`#rating_${id}`);var cnt=parseInt(indicator.first().text());let commentRatingContainer=document.querySelector(`.comment-rating[data-id="${id}"]`);commentRatingContainer.classList.remove("my-choise--1","my-choise-1","my-choise-0");switch(response.status){case 202:indicator.text(cnt+1);break;case 200:cnt-=1;case 201:indicator.text(cnt-1);commentRatingContainer.classList.add("my-choise--1");break;case 403:if(response.headers.get("content-type")==="application/json; charset=utf-8"){let blackData=await response.json();let message="";if(blackData&&blackData.code==="1"){message=`<span><a href="/user/${blackData.opponent_id}">Автор комментария</a> добавил вас в черный список. Голос не будет сохранен.</span>`}else if(blackData&&blackData.code==="2"){message=`<span>Вы добавили <a href="/user/${blackData.opponent_id}">автора комментария</a> в черный список. Голос не будет сохранен.</span>`}if(printMessage&&typeof printMessage==="function"&&commonMessageArea&&commonMessageArea instanceof HTMLElement){printMessage(commonMessageArea,message,"error")}}break;case 401:formOpen();break;default:}})}let userExpertTimeout=null;function userExpertTooltip(expertElement){const commentElement=expertElement.closest(".comment");const expertTooltip=commentElement.querySelector(".user-expert-tooltip");if($(expertElement).is(":active")){expertTooltip.classList.remove("d-none")}else{expertTooltip.classList.add("d-none")}if(userExpertTimeout){clearTimeout(userExpertTimeout)}userExpertTimeout=setTimeout(()=>{userExpertTooltip(expertElement)},200)}let expertCommentTimeout=null;function expertCommentTooltip(expertElement){const commentElement=expertElement.closest(".comment");const expertTooltip=commentElement.querySelector(".expert-comment-tooltip");if($(expertElement).is(":active")){expertTooltip.classList.remove("d-none")}else{expertTooltip.classList.add("d-none")}if(expertCommentTimeout){clearTimeout(expertCommentTimeout)}expertCommentTimeout=setTimeout(()=>{expertCommentTooltip(expertElement)},200)}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.