Read without ads. Subscribe KOMPAS.com+
‘
komentar_item += ”
komentar_item += ”
komentar_item += ”
komentar_item += ”
komentar_item += ‘
‘
});
komentar_item += ‘
‘;
if(result.result.total > 3){
komentar_item += ”;
}
}else{
komentar_item = ”;
}
var comment_cookie = getCookieKcm(‘comment’);
document.getElementById(“comments”).value = comment_cookie;
document.getElementById(“for_comment”).innerHTML = komentar_item;
var x = document.getElementsByClassName(“total_comment”);
if(result.result.total > 0){
if(typeof document.getElementsByClassName(“total_comment_share”)[0] !== ‘undefined’){
document.getElementsByClassName(“total_comment_share”)[0].innerHTML = result.result.total;
}
for (i = 0; i < x.length; i++) {
x[i].innerHTML = result.result.total;
}
}
var list=document.getElementsByClassName(“comment__avatar”),w=document.documentElement.clientWidth;function stringToHslColor(t){t=t.toUpperCase();for(var o=0,e=0;e0)r=(r+((o<<5)-o))%360,l+=n*Math.floor(2.5),i-=n*Math.floor(30/26);else var r=Math.floor(360/26*n),l=30,i=80}return”hsl(“+r+”,”+l+”%, “+i+”%)”}function applyHSLColor(t,o){t.style.backgroundColor=stringToHslColor(o)}function scrollTo(t,o,e){if(!(e<=0)){var n=(o-t.scrollTop)/e*10;setTimeout(function(){t.scrollTop=t.scrollTop+n,t.scrollTop!=o&&scrollTo(t,o,e-10)},10)}}function findPos(t){var o=0;if(t.offsetParent){for(;o+=t.offsetTop,t=t.offsetParent;);return[o]}}for(var i=0;i12 ? H – 12 : H == 0 ? 12 : H;
format = format.replace(/(^|[^\])hh+/g, “$1” + ii(h));
format = format.replace(/(^|[^\])h/g, “$1” + h);
var m = utc ? date.getUTCMinutes() : date.getMinutes();
format = format.replace(/(^|[^\])mm+/g, “$1” + ii(m));
format = format.replace(/(^|[^\])m/g, “$1” + m);
var s = utc ? date.getUTCSeconds() : date.getSeconds();
format = format.replace(/(^|[^\])ss+/g, “$1” + ii(s));
format = format.replace(/(^|[^\])s/g, “$1” + s);
var f = utc ? date.getUTCMilliseconds() : date.getMilliseconds();
format = format.replace(/(^|[^\])fff+/g, “$1” + ii(f, 3));
f = Math.round(f / 10);
format = format.replace(/(^|[^\])ff/g, “$1” + ii(f));
f = Math.round(f / 10);
format = format.replace(/(^|[^\])f/g, “$1” + f);
var T = H < 12 ? “AM” : “PM”;
format = format.replace(/(^|[^\])TT+/g, “$1” + T);
format = format.replace(/(^|[^\])T/g, “$1” + T.charAt(0));
var t = T.toLowerCase();
format = format.replace(/(^|[^\])tt+/g, “$1” + t);
format = format.replace(/(^|[^\])t/g, “$1” + t.charAt(0));
var tz = -date.getTimezoneOffset();
var K = utc || !tz ? “Z” : tz > 0 ? “+” : “-“;
if (!utc) {
tz = Math.abs(tz);
var tzHrs = Math.floor(tz / 60);
var tzMin = tz % 60;
K += ii(tzHrs) + “:” + ii(tzMin);
}
format = format.replace(/(^|[^\])K/g, “$1” + K);
var day = (utc ? date.getUTCDay() : date.getDay()) + 1;
format = format.replace(new RegExp(dddd[0], “g”), dddd[day]);
format = format.replace(new RegExp(ddd[0], “g”), ddd[day]);
format = format.replace(new RegExp(MMMM[0], “g”), MMMM[M]);
format = format.replace(new RegExp(MMM[0], “g”), MMM[M]);
format = format.replace(/\(.)/g, “$1”);
return format;
};
//Cek if not login then redirect
// $(“#comments”).on(‘click’, function() {
// var e = getCookieKcm(‘kmp_uid’);
// if(e == ”){
// window.top.location.href = document.getElementById(“login_url”).value;
// }
// });
//Limit character to LimitNum=300
function limitText(limitField, limitNum) {
if (limitField.value.length > limitNum) {
limitField.value = limitField.value.substring(0, limitNum);
} else{
// document.getElementById(“countdown”).innerHTML = limitNum – limitField.value.length;
}
}
//Insert comment
function insertComment(commentId) {
var e = getCookieKcm(‘kmp_uid’);
if(e == ”){
document.cookie = “comment=”+document.getElementById(“comments”).value;
window.top.location.href = document.getElementById(“login_url”).value;
}
else{
var xml_path = document.getElementById(“urlpage”).value;
// var article_url = document.referrer;
var article_url = document.getElementById(“urlpage”).value;
var token = getCookieKcm(‘kmp_uid’);
var type = getCookieKcm(‘kmp_lgn’) == ‘kompas’?’kid’:’sc’;
var loginwith = getCookieKcm(‘lgn_w’);
var data = {};
data[‘xml_path’] = xml_path;
data[‘article_url’] = article_url;
data[‘token’] = token;
data[‘acc_type’] = type;
data[‘loginwith’] = loginwith;
data[‘reply_comment_id’] = commentId;
if(commentId != “”){
var uname = document.getElementById(“uname-“+commentId).value;
var content = document.getElementById(“content-“+commentId).value;
var comments = document.getElementById(“comments_reply_”+commentId).value;
data[‘uname’] = uname;
data[‘content’] = content;
data[‘comments’] = comments;
} else {
var comments = document.getElementById(“comments”).value;
data[‘comments’] = comments;
}
if(comments == “” || comments.trim().length == 0){
alert(“Comment can not be empty!”);
} else{
if(commentId != “”){
$(“#btnkirim-“+commentId).css(“display”, “none”);
$(“#btnLoading-“+commentId).css(“display”, “block”);
} else {
$(“#btnkirim”).css(“display”, “none”);
$(“#btnLoading”).css(“display”, “block”);
}
$.post(“https://apis.kompas.com/api/comment/insert/v2”, data, function(result){
if(result.status == false){
if(result.message == “Please Login to write comment.”){
window.top.location.href = result.loginUrl;
} else{
alert(result.message);
}
$(“#btnkirim”).css(“display”, “inline”);
$(“#btnLoading”).css(“display”, “none”);
} else{
if ($(“div”).hasClass(“comment__board”)) {
$(“.comment__board”).css(“display”, “none”);
$(“.comment__list”).css(“display”, “block”);
}
$(“.comment__list”).prepend(result.view);
if(commentId != “”){
$(“#btnkirim-“+commentId).css(“display”, “inline”);
$(“#btnLoading-“+commentId).css(“display”, “none”);
closeForm(commentId);
} else {
$(“#btnkirim”).css(“display”, “inline”);
$(“#btnLoading”).css(“display”, “none”);
$(“#comments”).val(”);
}
document.cookie = “comment=”;
// showKgModalJernihKomentar(data);
}
}).fail(function(err) {
$(“#btnkirim”).css(“display”, “inline”);
$(“#btnLoading”).css(“display”, “none”);
window.top.location.href = “https://account.kompas.com/login/a29tcGFz/aHR0cDovL3d3dy5rb21wYXMuY29t?source=kompas.com&medium=komentar”;
});
}
}
}
//Reply comment
function replyComment(commentId) {
// case 1 comment only
let oneCom = document.getElementById(‘for_comment’);
if(!!oneCom) {
oneCom.style.height = ‘auto’
}
var uname = document.getElementById(“uname_”+commentId).innerText;
var date = document.getElementById(“tgl_”+commentId).innerText;
var content = document.getElementById(“cont_”+commentId).innerText;
document.getElementById(“reply_form_”+commentId).style.display = “block”;
document.getElementById(“comments_reply_”+commentId).focus();
document.getElementById(“uname-“+commentId).value = uname;
document.getElementById(“tgl-“+commentId).value = date;
document.getElementById(“content-“+commentId).value = content;
}
//Close reply comment
function closeForm(commentId) {
$(“#reply_form_”+commentId).css(“display”,”none”);
$(“#uname-“+commentId).val(“”);
$(“#tgl-“+commentId).val(“”);
$(“#content-“+commentId).val(“”);
}
//Like dislike comment
function likedislikeComment(commentId, type){
var data = {};
data[‘xml_path’] = document.getElementById(“urlpage”).value;
data[‘comment_id’] = commentId;
data[‘type’] = type;
data[‘total_like’] = document.getElementById(“like_”+commentId).value;
data[‘total_dislike’] = document.getElementById(“dislike_”+commentId).value;
data[‘token’] = getCookieKcm(‘kmp_uid’);
data[‘acc_type’] = getCookieKcm(‘kmp_lgn’) == ‘kompas’?’kid’:’sc’;
data[‘loginwith’] = getCookieKcm(‘lgn_w’);
$.post(“https://apis.kompas.com/api/comment/likedislike/v2”, data, function(result){
if(result.status==true){
$(“#like_”+commentId).val(result.total_like);
$(“#dislike_”+commentId).val(result.total_dislike);
$(“#total_like_”+commentId).html(result.total_like);
$(“#total_dislike_”+commentId).html(result.total_dislike);
if(type==’like’){
$(‘#button_like_’+commentId).attr(‘disabled’,’disabled’);
$(‘#button_dislike_’+commentId).removeAttr(‘disabled’,’disabled’);
}else{
$(‘#button_like_’+commentId).removeAttr(‘disabled’,’disabled’);
$(‘#button_dislike_’+commentId).attr(‘disabled’,’disabled’);
}
}else{
$(“#btnkirim”).css(“display”, “inline”);
$(“#btnLoading”).css(“display”, “none”);
window.top.location.href = document.getElementById(“login_url”).value;
}
});
}
Health Minister Reveals Indonesia Needs 81,416 General Practitioners and 55,192 Specialists
- News
- 2 minutes ago
Puan: Firefighters in Karhutla Deserve Proper Protection from the State
- News
- 17 minutes ago
KPK Seizes BMW Vehicle from Husband of Pekalongan Regent Fadia Arafiq
- News
- 17 minutes ago
Cartenz Peace Task Force Captures Fugitive in Serious Assault and Attempted Rape Case in Puncak Jaya
- News
- 27 minutes ago
CKG Program Focuses on Hypertension, Diabetes, and Dyslipidemia Screenings
- News
- 27 minutes ago
Gus Ipul Promises to Investigate Unhan Cadet Case Allegedly Assaulting 3 Sekolah Rakyat Students
- News
- 37 minutes ago
DPR Member Urges Government to Lead Discussions on Forest Fires at ASEAN Summit
- News
- 37 minutes ago
Teddy Summons Minister Sakti Wahyu Trenggono, What’s Going On?
- News
- 52 minutes ago
DPR Member Unveils Proposal to Increase KPU-Bawaslu Commissioners Through Election Bill
- News
- 1 hours ago
After the Smoke, Palm Oil Rises
- News
- 1 hours ago
KPK Probes Discussion Between Golkar DPD II Chairman and Pemalang Regent Regarding Position Filling
- News
- 1 hours ago
Indonesian Army Tests Three TRG-122 Rockets in East Kalimantan
- News
- 1 hours ago
Unease, Turmoil, Revolution
- News
- 2 hours ago
Commander: TNI Archery Championship as a Benchmark for National and Global Athlete Development
- News
- 2 hours ago
At Harvard, JK Highlights Global Conflict Impact on Indonesia’s Economy
- News
- 2 hours ago
Budiman Sudjatmiko: I Used to be Like “Tom and Jerry” with Prabowo
- News
- 2 hours ago
PKS Legislator on Indonesia’s Forest Fire Issue at ASEAN Summit: A Momentum for Cooperation
- News
- 2 hours ago
JK’s Lecture at Harvard Highlights National Spending and Debt Burden
- News
- 2 hours ago
Launching the Archery Championship, TNI Commander Encourages the Development of National Athletes
- News
- 2 hours ago
Transformation of Bakom: From Palace Megaphone to Dialogue Space
- News
- 3 hours ago
1
2
3
Next
Last ›


