PageSourceSearch

https://www.theadviser.com.au/media/mod_custom/js/article-counter.js?a9f118

js theadviser.com.au collected 2026-09-24 17:35:00 UTC 3,792 bytes, 104 lines download raw bytes

1var ARTICLE_COUNTER = (($) => {
2    const initialise = () => {
3        if ($('#articleGateCounterTag').length > 0) {
4            prepareArticleGateChecks();
5            toggleArticleGate();
6            setEventHandlers();
7        }
8        else {
9            preparePremiumArticleGateChecks();
10        }
11    };
12
13    const preparePremiumArticleGateChecks = () => {
14        let paywallUser = window.paywallUser;
15        if (paywallUser && (paywallUser.id || paywallUser.username) && paywallUser.premium) {
16            $('.paywall').toggleClass('paywall');
17            $('#gated-content').hide();
18            return;
19        }
20    };
21
22    const prepareArticleGateChecks = () => {
23        let paywallUser = window.paywallUser;
24        if (paywallUser && (paywallUser.id || paywallUser.username)) {
25            $('.paywall').toggleClass('paywall');
26            $('#freeMembershipOverlay').hide();
27            $('#b-snapper-id').addClass('b-snapper-id');
28            $('#free-article').addClass('hidden').hide();
29            $('#free-article-mobile').hide();
30            return;
31        }
32
33        const currentArticleId = $('#currentArticleId').val();
34        const currentDate = new Date();
35        const firstDayOfNextMonth = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 1);
36
37        let articleGateObject = {
38            count             : 2,
39            expires           : firstDayOfNextMonth.getTime(),
40            visitedArticleIds : [currentArticleId]
41        };
42
43        const articleGateData = localStorage.getItem('articleGateData');
44        if (articleGateData !== null) {
45            articleGateObject = JSON.parse(articleGateData);
46
47            if (articleGateObject.visitedArticleIds.includes(currentArticleId) === false) {
48                articleGateObject.visitedArticleIds.push(currentArticleId);
49                articleGateObject.count--;
50            }
51
52            if (articleGateObject.expires <= currentDate.getTime()) {
53                articleGateObject.count = 2;
54                articleGateObject.expires = firstDayOfNextMonth.getTime();
55            }
56        }
57
58        localStorage.setItem('articleGateData', JSON.stringify(articleGateObject));
59    };
60
61    const toggleArticleGate = () => {
62        const articleGateData = JSON.parse(localStorage.getItem('articleGateData'));
63        if (articleGateData.count < 0) {
64            $('#free-article-mobile, #free-article').hide();
65            $('.b-topLeaderboard').removeClass('bottom-margin');
66            $('.b-topLeaderboard').addClass('bottom-zero');
67        } else {
68            $('#free-article')
69                .removeClass('hidden')
70                .show()
71                .append("<style>@media (max-width: 1024px) { #b-snapbanner-zoneunit { bottom: 150px !important; } }</style>")
72
73            $('.paywall').toggleClass('paywall');
74            $('#freeMembershipOverlay').hide();
75            $('#b-snapper-id').addClass('b-snapper-id');
76            $('.article-limit').text(articleGateData.count);
77            $('.article-limit-text').text(`free article${(articleGateData.count >= 2) ? 's' : ''} left this month.`);
78        }
79    };
80
81    const setEventHandlers = () => {
82        $('#free-article-close').on('click', () => {
83            $('#free-article').hide();
84        });
85
86        $('#free-article-mobile').on('click', '.mobile-arrow', function () {
87            const $arrowIcon = $(this).find('svg');
88            const $mobileDown = $('#free-article-mobile-down');
89            const $leaderboard = $('.b-topLeaderboard');
90
91            $mobileDown.slideToggle(200);
92            $leaderboard.toggleClass('!bottom-[160px]');
93            $arrowIcon.toggleClass('rotate-180');
94        });
95
96
97    };
98
99    return { initialise };
100})(jQuery);
101
102jQuery(() => {
103    ARTICLE_COUNTER.initialise();
104});

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.