PageSourceSearch

https://nic.monster/assets/js/main.js?v=0.1

js nic.monster collected 2026-10-03 21:38:56 UTC 7,310 bytes, 220 lines download raw bytes

1jQuery(document).ready(function ($) {
2
3    // goTo() scroll function
4    (function ($) {
5        $.fn.goTo = function (offsetTop) {
6            if (offsetTop === undefined) offsetTop = 0;
7            var topY = $(this).offset().top * 1 + offsetTop;
8            $('html, body').animate({
9                scrollTop: topY + 'px'
10            }, 1000);
11            return this;
12        }
13    })(jQuery);
14
15    // Mobile nav toggle
16    $('#mobile-nav-toggle').click(function () {
17        $('#header-main-nav').slideToggle();
18        $('body').toggleClass('mobileToggled');
19    });
20
21    // WHOIS Scripts
22
23    // Caret jQuery plugin
24    (function ($) {
25        $.fn.caret = function (pos) {
26            var target = this[0];
27            var isContentEditable = target.contentEditable === 'true';
28            if (arguments.length == 0) {
29                if (window.getSelection) {
30                    if (isContentEditable) {
31                        target.focus();
32                        var range1 = window.getSelection().getRangeAt(0), range2 = range1.cloneRange();
33                        range2.selectNodeContents(target);
34                        range2.setEnd(range1.endContainer, range1.endOffset);
35                        return range2.toString().length;
36                    }
37                    return target.selectionStart;
38                }
39                if (document.selection) {
40                    target.focus();
41                    if (isContentEditable) {
42                        var range1 = document.selection.createRange(), range2 = document.body.createTextRange();
43                        range2.moveToElementText(target);
44                        range2.setEndPoint('EndToEnd', range1);
45                        return range2.text.length;
46                    }
47                    var pos = 0, range = target.createTextRange(),
48                        range2 = document.selection.createRange().duplicate(), bookmark = range2.getBookmark();
49                    range.moveToBookmark(bookmark);
50                    while (range.moveStart('character', -1) !== 0)pos++;
51                    return pos;
52                }
53                if (target.selectionStart)
54                    return target.selectionStart;
55                return 0;
56            }
57            if (pos == -1)
58                pos = this[isContentEditable ? 'text' : 'val']().length;
59            if (window.getSelection) {
60                if (isContentEditable) {
61                    target.focus();
62                    window.getSelection().collapse(target.firstChild, pos);
63                }
64                else
65                    target.setSelectionRange(pos, pos);
66            }
67            else if (document.body.createTextRange) {
68                if (isContentEditable) {
69                    var range = document.body.createTextRange();
70                    range.moveToElementText(target);
71                    range.moveStart('character', pos);
72                    range.collapse(true);
73                    range.select();
74                } else {
75                    var range = target.createTextRange();
76                    range.move('character', pos);
77                    range.select();
78                }
79            }
80            if (!isContentEditable)
81                target.focus();
82            return pos;
83        }
84    })(jQuery);
85
86    $(function () {
87
88        // Scroll to the #whois-result element if exists
89        // if ($('#whois-result').length != 0) {
90        //     $('.whois-block').hide();
91        //     $('#whois-result').goTo(-50);
92        // }
93
94        // Enforce tld in search string
95
96        $("#whois-search-term").bind("keydown keypress click focus blur change", function (event) {
97
98            // Only enforce TLD id "domain" type search is selected
99            if ($('#type-domain').length != 0 && !$('#type-domain').attr('checked')) {
100                return true;
101            }
102
103            var myString = $(this).val(),
104                suffix = '.Monster',
105                stringLength, safeEndPoint;
106
107            // Check if my string ends up with suffix, if not add it at the and of the string
108            if (myString.indexOf(suffix, myString.length - suffix.length) === -1) {
109                myString = myString + suffix;
110                $(this).val(myString);
111            }
112
113            stringLength = myString.length;
114            safeEndPoint = stringLength - suffix.length;
115
116            //move cursor if need be
117            if (safeEndPoint < $(this).caret()) {
118                $(this).caret(safeEndPoint);
119            }
120
121            return true;
122        });
123
124        // Search Again link, click scrolls back to search
125        $('#whois-search-again').click(function () {
126            $('#whois-form').goTo(-50);
127            $('#whois-search-term').focus();
128            return false;
129        });
130
131    });
132
133    $('#whois-search-term').on('click, focus', function () {
134        $('#whois-form').addClass('prefix-active');
135        $('#whois-search-term').removeAttr('placeholder');
136    });
137
138    if ( $('.whois__results').length > 0 ) {
139        $('.whois__results').goTo(-100);
140    }
141
142    // Responsive Tables
143
144    /*
145     Responsive table solution by ZURB Foundation
146     http://zurb.com/playground/responsive-tables
147
148     Just add "responsive" class to <table>
149
150     Foundation v2.1.4 http://foundation.zurb.com */
151
152    var switched = false;
153    var updateTables = function () {
154        if (($(window).width() < 800) && !switched) {
155            switched = true;
156            $("table.responsive").each(function (i, element) {
157                splitTable($(element));
158            });
159            return true;
160        }
161        else if (switched && ($(window).width() > 800)) {
162            switched = false;
163            $("table.responsive").each(function (i, element) {
164                unsplitTable($(element));
165            });
166        }
167    };
168
169    $(window).load(updateTables);
170    $(window).on("redraw", function () {
171        switched = false;
172        updateTables();
173    }); // An event to listen for
174    $(window).on("resize", updateTables);
175
176
177    function splitTable(original) {
178        original.wrap("<div class='table-wrapper' />");
179
180        var copy = original.clone();
181        copy.find("td:not(:first-child), th:not(:first-child)").css("display", "none");
182        copy.removeClass("responsive");
183
184        original.closest(".table-wrapper").append(copy);
185        copy.wrap("<div class='pinned' />");
186        original.wrap("<div class='scrollable' />");
187
188        setCellHeights(original, copy);
189    }
190
191    function unsplitTable(original) {
192        original.closest(".table-wrapper").find(".pinned").remove();
193        original.unwrap();
194        original.unwrap();
195    }
196
197    function setCellHeights(original, copy) {
198        var tr = original.find('tr'),
199            tr_copy = copy.find('tr'),
200            heights = [];
201
202        tr.each(function (index) {
203            var self = $(this),
204                tx = self.find('th, td');
205
206            tx.each(function () {
207                var height = $(this).outerHeight(true);
208                heights[index] = heights[index] || 0;
209                if (height > heights[index]) heights[index] = height;
210            });
211
212        });
213
214        tr_copy.each(function (index) {
215            $(this).height(heights[index]);
216        });
217    }
218
219});
220

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.