PageSourceSearch

http://www.bayonetta.com/scripts/age-gate.js

js bayonetta.com collected 2026-10-02 19:37:17 UTC 6,353 bytes, 207 lines download raw bytes

1'use strict';
2
3/**
4 * Page loader : hide loader when all are loaded.
5 */
6$(window).on('load', function () {
7    $('#page-loader').addClass('hidden');
8    AgeGate.generateYearsOptions();
9});
10
11/**
12 * A namespace for the age gate form and age checks.
13 * Dependencies: jQuery, Monolog.
14 */
15var AgeGate = AgeGate || {};
16
17var cookie_passed = 'passed';
18var cookie_failed = 'failed';
19
20AgeGate.config = {
21    isDebugMode: true,
22    redirectOnSuccessLocation: '',
23    messageAgeCheckFailed: 'SORRY<br>YOU DO NOT MEET THE CRITERIA TO VIEW ' + 'THIS CONTENT'
24};
25
26AgeGate.generateYearsOptions = function () {
27    var select = document.getElementById('age-gate-years');
28    var year = new Date().getFullYear();
29    var options = '<option value="">YEAR</option>';
30    for (var i = year; i >= year - 100; i--) {
31        options += '<option value="' + i + '">' + i + '</option>';
32    }
33    if (select !== null) {
34        select.innerHTML = options;
35    }
36};
37
38//AgeGate.modal = new Monolog({
39//content: AgeGate.config.messageAgeCheckFailed
40//});
41
42
43// On page load: check cookie and let/don't let user in.
44$(document).ready(function (event) {
45    var cookie = cookiecutter.getCookie('age_gate');
46    if (cookie_passed == cookie) {
47        $('#age-gate-dialog').hide();
48        if (!AgeGate.config.isDebugMode) {
49            location.href = AgeGate.config.redirectOnSuccessLocation;
50        }
51    } else if (cookie_failed == cookie) {
52        $('#age-gate-dialog').addClass('active invalid');
53    }
54});
55
56//Restrict Form Entry to Numeric characters
57jQuery.fn.forceNumeric = function () {
58
59    return this.each(function () {
60        $(this).keydown(function (e) {
61            var key = e.which || e.keyCode;
62
63            if (!e.shiftKey && !e.altKey && !e.ctrlKey &&
64            // numbers
65            key >= 48 && key <= 57 ||
66            // Numeric keypad
67            key >= 96 && key <= 105 ||
68            // comma, period and minus, . on keypad
69            key == 190 || key == 188 || key == 109 || key == 110 ||
70            // Backspace and Tab and Enter
71            key == 8 || key == 9 || key == 13 ||
72            // Home and End
73            key == 35 || key == 36 ||
74            // left and right arrows
75            key == 37 || key == 39 ||
76            // Del and Ins
77            key == 46 || key == 45) return true;
78
79            return false;
80        });
81    });
82};
83
84$(document).ready(function () {
85    $('input.age-gate').forceNumeric();
86});
87
88//Enforce Min/Max Values
89$(document).ready(function () {
90    $('input.age-gate').change(function () {
91        var max = parseInt($(this).attr('max'));
92        var min = parseInt($(this).attr('min'));
93        if ($(this).val() > max) {
94            $(this).val(max);
95        } else if ($(this).val() < min) {
96            $(this).val(min);
97        }
98    });
99});
100
101//Hide obscuring Age-Gate Elements
102var is_keyboard = false;
103var initial_screen_size = window.innerHeight;
104
105window.addEventListener('resize', function () {
106    is_keyboard = window.innerHeight < initial_screen_size;
107    updateViews();
108}, false);
109
110function updateViews() {
111    if (is_keyboard) {
112        $('p.disclaimer').hide();
113    } else {
114        $('p.disclaimer').show();
115    }
116}
117
118// Add Leading Zeros to DD && MM
119$('#age-gate-days').focusout(function () {
120    var n = $('#age-gate-days').val();
121    if ($.isNumeric(n) && n.length == 1) {
122        var new_val = n > 0 && n < 10 ? '0' + n : n;
123        if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
124            // Hack for Firefox
125            $('#age-gate-days').attr('type', 'tel');
126        }
127        $('#age-gate-days').val(new_val);
128    }
129});
130
131$('#age-gate-months').focusout(function () {
132    var n = $('#age-gate-months').val();
133    if ($.isNumeric(n) && n.length == 1) {
134        var new_val = n > 0 && n < 10 ? '0' + n : n;
135        if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
136            // Hack for Firefox
137            $('#age-gate-months').attr('type', 'tel');
138        }
139        $('#age-gate-months').val(new_val);
140    }
141});
142
143// Submit age gate form and set cookie if age is ok.
144$('#age-gate-form-submit').click(function (event) {
145    event.preventDefault();
146
147    var yearOfBirth = $('#age-gate-years').val();
148    var monthOfBirth = $('#age-gate-months').val();
149    var dayOfBirth = $('#age-gate-days').val();
150
151    // Make sure valid day, month and year of birth are all entered.
152    if (yearOfBirth.length < 4 || monthOfBirth.length < 2 || dayOfBirth.length < 2) {
153        $('#no-date-error').addClass('active');
154        document.getElementById('no-date-error').innerHTML = 'PLEASE ENTER YOUR DATE OF BIRTH IN THE FORMAT DD-MM-YYYY';
155        return false;
156    }
157
158    var currentDate = new Date();
159    var formDate = new Date(yearOfBirth, monthOfBirth - 1, dayOfBirth);
160
161    var formDatePlus18Years = new Date(parseInt($('#age-gate-years').val()) + 18, $('#age-gate-months').val() - 1, $('#age-gate-days').val());
162
163    if (currentDate >= formDatePlus18Years) {
164        cookiecutter.setCookie('age_gate', cookie_passed);
165        //location.href = AgeGate.config.redirectOnSuccessLocation;
166        $('#age-gate-dialog').hide();
167    } else {
168        cookiecutter.setCookie('age_gate', cookie_failed);
169        //AgeGate.modal.show();
170        // Hide the modal close button
171        //$('.monolog-close').hide();
172        $('#age-gate-dialog').addClass('active invalid');
173    }
174
175    if (currentDate >= formDatePlus18Years) {} else {}
176});
177
178/**
179 * Cookie handler.
180 */
181var cookiecutter = {
182    setCookie: function setCookie(name, value, days) {
183        if (days) {
184            var date = new Date();
185            date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
186            var expires = '; expires=' + date.toGMTString();
187        } else var expires = '';
188        document.cookie = name + '=' + value + expires + '; path=/';
189    },
190
191    getCookie: function getCookie(name) {
192        var nameEQ = name + '=';
193        var ca = document.cookie.split(';');
194        for (var i = 0; i < ca.length; i++) {
195            var c = ca[i];
196            while (c.charAt(0) == ' ') {
197                c = c.substring(1, c.length);
198            }if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
199        }
200        return null;
201    },
202
203    deleteCookie: function deleteCookie(name) {
204        setCookie(name, '', -1);
205    }
206};
207//# sourceMappingURL=age-gate.js.map

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.