// Script for iineButton (function () { if ($('.iine').length > 0) { var path = location.pathname; var bbsId = path.substr(Number(path.lastIndexOf('-')) + 1); var iineButton = $('.iineButton'); var len = iineButton.length; for(var i = 0; i < len; i++){ var iineA = $(iineButton[i]).children('a:first'); var bbsCommentId = iineA.data('id'); var count = Number($(iineButton[i]).next(".iineCount:first").text()); if (localStorage.getItem('qa_iine_'+bbsId+'_'+bbsCommentId) == "" || count >= 9999) { iineA.css({ 'cursor': 'auto', 'opacity': '0.7' }); } } $('.iineButton a').click(function(){ var index = $('.iineButton a').index(this); var bbsCommentId = $(this).data('id'); var iineButton = $('.iineButton a')[index]; var countText = $('.iineCount')[index]; var count = Number(countText.textContent); if (localStorage.getItem('qa_iine_'+ bbsId + '_' + bbsCommentId) == null && count < 9999) { $.ajax({ url: "iine-to-comment?targetBbsId=" + bbsId + "&targetBcId=" + bbsCommentId, type: "POST", success : function(data, status, xhr) { if (xhr.status === 200) { countText.textContent = count + 1; localStorage.setItem('qa_iine_'+bbsId+'_'+bbsCommentId, ""); iineButton.style.cursor = 'auto'; iineButton.style.opacity = '0.7'; } } }); } }); } })();