Berita Terkini Hari Ini, Kabar Akurat Terpercaya (2024)

Berikan Komentar

`; var e = getCookieKcm('kmp_uid'); if (e == '') { widget += `

`; } else { widget += `

`; } widget += `

Isi komentar sepenuhnya adalah tanggung jawab pengguna dan diatur dalam UU ITE

`; } container.innerHTML = widget; } } var ajax_loader = "https://asset.kompas.com/data/2017/widget/comment/desktop/images/loading.gif"; //Load Comment $.get("https://apis.kompas.com/api/comment/v2/list?urlpage=https://lipsus.kompas.com/pameranotomotifnasional2024/read/2018/07/17/090704910/timbulkan-kontroversi-scarlett-johansson-mundur-dari-film-rub-tug&json&limit=1", function(result) { // console.log(result.result); if (window.location.href.includes('#comment_widget')) { document.getElementById("comments").focus(); } gen_widget_comment(result.result.komentar, result.result.total, 'https://lipsus.kompas.com/pameranotomotifnasional2024/komentar/2018/07/17/090704910/timbulkan-kontroversi-scarlett-johansson-mundur-dari-film-rub-tug'); var url = 'https://lipsus.kompas.com/pameranotomotifnasional2024/read/2018/07/17/090704910/timbulkan-kontroversi-scarlett-johansson-mundur-dari-film-rub-tug'; if (result.result.total > 0) { // Pin var pc = result.result.pinned_comments; if (pc.length === 0) { firstComment = result.result.komentar; } else { firstComment = pc; } var komentar_item = '

'; $.each(firstComment, function(index, value) { komentar_reply = value.comment_text.split('$//$'); komentar_fullname = value.user_fullname.split(' ') fullname = komentar_fullname[0].charAt(0).toUpperCase() if (komentar_fullname[1]) { fullname += komentar_fullname[1].charAt(0).toUpperCase() } komentar_item += '

'; komentar_item += '

' komentar_item += '

' komentar_item += '

' + value.user_fullname + '

' komentar_item += '

' + formatDateComment(new Date(1000 * value.comment_time), 'dddd, d MMM yyyy | HH:mm WIB') + '

' komentar_item += '

' komentar_item += '' komentar_item += '

' komentar_item += '

' komentar_item += '

' if (komentar_reply[1]) { komentar_fullname_reply = komentar_reply[1].split(' ') fullname_reply = komentar_fullname_reply[0].charAt(0).toUpperCase() if (komentar_fullname_reply[1]) { fullname_reply += komentar_fullname_reply[1].charAt(0).toUpperCase() } komentar_item += '

' komentar_item += '

' komentar_item += '

' komentar_item += '

' komentar_item += '

' + komentar_reply[1] + '

' komentar_item += '

' komentar_item += '

' komentar_item += '

' komentar_item += komentar_reply[2] komentar_item += '

' komentar_item += '

' komentar_item += '

' komentar_item += '

' } komentar_item += '

' + komentar_reply[0] + '

' komentar_item += '

' komentar_item += '

' komentar_item += '

' komentar_item += '

' komentar_item += '' komentar_item += '' komentar_item += '

' komentar_item += '

' komentar_item += '' komentar_item += '' komentar_item += '

' komentar_item += '

' komentar_item += '' komentar_item += '

' if (value.is_flagged == '1') { komentar_item += '

' komentar_item += '' komentar_item += '

' } komentar_item += '

' komentar_item += '

' komentar_item += '

' komentar_item += '

' }); komentar_item += '

'; if (result.result.total > 1) { komentar_item += '

Lihat Semua Komentar (' + result.result.total + ')

'; } } else { komentar_item = '

Belum ada komentar. Jadilah yang pertama untuk memberikan komentar!

'; } // 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; e < t.length; e++) { var n = (o = t.charCodeAt(e)) - 64; if (e > 0) 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; i < list.length; i++) { var t = list[i].getAttribute("data-init"); applyHSLColor(list[i], t) } var btntop = document.getElementById("comment-buble"); btntop && btntop.addEventListener("click", function(t) { t.preventDefault(); var o = findPos(document.getElementById(this.getAttribute("href").substring(1))); scrollTo(document.documentElement, o - 100, 200) }); }); function formatDateComment(date, format, utc) { var MMMM = ["\x00", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; var MMM = ["\x01", "Jan", "Feb", "Mar", "Apr", "Mei", "Jun", "Jul", "Agu", "Sep", "Okt", "Nov", "Des"]; var dddd = ["\x02", "Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu"]; var ddd = ["\x03", "Min", "Sen", "Sel", "Rab", "Kam", "Jum", "Sab"]; function ii(i, len) { var s = i + ""; len = len || 2; while (s.length < len) s = "0" + s; return s; } var y = utc ? date.getUTCFullYear() : date.getFullYear(); format = format.replace(/(^|[^\\])yyyy+/g, "$1" + y); format = format.replace(/(^|[^\\])yy/g, "$1" + y.toString().substr(2, 2)); format = format.replace(/(^|[^\\])y/g, "$1" + y); var M = (utc ? date.getUTCMonth() : date.getMonth()) + 1; format = format.replace(/(^|[^\\])MMMM+/g, "$1" + MMMM[0]); format = format.replace(/(^|[^\\])MMM/g, "$1" + MMM[0]); format = format.replace(/(^|[^\\])MM/g, "$1" + ii(M)); format = format.replace(/(^|[^\\])M/g, "$1" + M); var d = utc ? date.getUTCDate() : date.getDate(); format = format.replace(/(^|[^\\])dddd+/g, "$1" + dddd[0]); format = format.replace(/(^|[^\\])ddd/g, "$1" + ddd[0]); format = format.replace(/(^|[^\\])dd/g, "$1" + ii(d)); format = format.replace(/(^|[^\\])d/g, "$1" + d); var H = utc ? date.getUTCHours() : date.getHours(); format = format.replace(/(^|[^\\])HH+/g, "$1" + ii(H)); format = format.replace(/(^|[^\\])H/g, "$1" + H); var h = H > 12 ? 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'] = getCookieKcm('lgn_w'); 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("Komentar tidak boleh kosong!"); } 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 == "Silahkan Login dahulu untuk memberi komentar.") { 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; } }); }

Berita Terkini Hari Ini, Kabar Akurat Terpercaya (2024)
Top Articles
Latest Posts
Recommended Articles
Article information

Author: Cheryll Lueilwitz

Last Updated:

Views: 5864

Rating: 4.3 / 5 (54 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Cheryll Lueilwitz

Birthday: 1997-12-23

Address: 4653 O'Kon Hill, Lake Juanstad, AR 65469

Phone: +494124489301

Job: Marketing Representative

Hobby: Reading, Ice skating, Foraging, BASE jumping, Hiking, Skateboarding, Kayaking

Introduction: My name is Cheryll Lueilwitz, I am a sparkling, clean, super, lucky, joyous, outstanding, lucky person who loves writing and wants to share my knowledge and understanding with you.