PageSourceSearch

https://binderim.com/js/blog/blog-detail-vote.401mdplq44.js

js binderim.com collected 2026-09-24 14:40:27 UTC 2,589 bytes, 57 lines download raw bytes

1// T-20260816-25 (Issue #1616): Views/Blog/Detay.cshtml icindeki inline <script> bloğu buraya
2// tasindi (proje kurali: .cshtml icinde <script> tutulmaz). Davranis birebir korunmustur --
3// metin icermez, bu yuzden dil bagimsizdir.
4(function () {
5    const box = document.getElementById('blogVoteBox');
6    if (!box) return;
7
8    const helpfulBtn = document.getElementById('voteHelpfulBtn');
9    const notHelpfulBtn = document.getElementById('voteNotHelpfulBtn');
10    if (!helpfulBtn || !notHelpfulBtn) return;
11
12    // Anonim ziyaretci: sunucu butonlara data-login-url basar (eski inline onclick, Razor
13    // tarafindan HTML-encode edildigi icin hic calismiyordu -- QA #1616 pre-existing bug).
14    const loginUrl = helpfulBtn.getAttribute('data-login-url');
15    if (loginUrl) {
16        [helpfulBtn, notHelpfulBtn].forEach(function (btn) {
17            btn.addEventListener('click', function (e) {
18                e.preventDefault();
19                window.location.href = loginUrl;
20            });
21        });
22        return;
23    }
24
25    const postId = box.getAttribute('data-post-id');
26    const helpfulCount = document.getElementById('helpfulCount');
27    const notHelpfulCount = document.getElementById('notHelpfulCount');
28    const csrfToken = document.querySelector('input[name="__RequestVerificationToken"]')?.value;
29
30    function vote(isHelpful, btn) {
31        if (!csrfToken) return;
32        btn.disabled = true;
33        fetch('/blog/oy', {
34            method: 'POST',
35            headers: {
36                'Content-Type': 'application/json',
37                'RequestVerificationToken': csrfToken
38            },
39            body: JSON.stringify({ postId: parseInt(postId), isHelpful: isHelpful })
40        })
41        .then(res => res.json())
42        .then(data => {
43            if (!data.success) return;
44            helpfulCount.textContent = data.helpfulCount;
45            notHelpfulCount.textContent = data.notHelpfulCount;
46
47            helpfulBtn.classList.toggle('active', data.currentUserVote === true);
48            notHelpfulBtn.classList.toggle('active', data.currentUserVote === false);
49            helpfulBtn.querySelector('i').className = 'bi bi-hand-thumbs-up' + (data.currentUserVote === true ? '-fill' : '');
50            notHelpfulBtn.querySelector('i').className = 'bi bi-hand-thumbs-down' + (data.currentUserVote === false ? '-fill' : '');
51        })
52        .finally(() => { btn.disabled = false; });
53    }
54
55    helpfulBtn.addEventListener('click', () => vote(true, helpfulBtn));
56    notHelpfulBtn.addEventListener('click', () => vote(false, notHelpfulBtn));
57})();

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.