PageSourceSearch

https://www.aoa.org/Content/js/scrollsneak.js

js aoa.org collected 2026-10-01 09:16:45 UTC 2,151 bytes, 53 lines download raw bytes

1/*!
2 * Scroll Sneak
3 * http://mrcoles.com/scroll-sneak/
4 *
5 * Copyright 2010, Peter Coles
6 * Licensed under the MIT licenses.
7 * http://mrcoles.com/media/mit-license.txt
8 *
9 * Date: Mon Mar 8 10:00:00 2010 -0500
10 */
11var ScrollSneak = function (prefix, wait) {
12    // clean up arguments (allows prefix to be optional - a bit of overkill)
13    if (typeof (wait) == 'undefined' && prefix === true) prefix = null, wait = true;
14    prefix = (typeof (prefix) == 'string' ? prefix : window.location.host).split('_').join('');
15    var pre_name;
16
17    // scroll function, if window.name matches, then scroll to that position and clean up window.name
18    this.scroll = function () {
19        if (window.name.search('^' + prefix + '_(\\d+)_(\\d+)_') == 0) {
20            var name = window.name.split('_');
21            window.scrollTo(name[1], name[2]);
22            window.name = name.slice(3).join('_');
23        }
24    }
25    // if not wait, scroll immediately
26    if (!wait) this.scroll();
27
28    this.sneak = function () {
29        // prevent multiple clicks from getting stored on window.name
30        if (typeof (pre_name) == 'undefined') pre_name = window.name;
31
32        // get the scroll positions
33        var top = 0, left = 0;
34        if (typeof (window.pageYOffset) == 'number') { // netscape
35            top = window.pageYOffset, left = window.pageXOffset;
36        } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) { // dom
37            top = document.body.scrollTop, left = document.body.scrollLeft;
38        } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) { // ie6
39            top = document.documentElement.scrollTop, left = document.documentElement.scrollLeft;
40        }
41        // store the scroll
42        if (top || left) window.name = prefix + '_' + left + '_' + top + '_' + pre_name;
43        return true;
44    }
45};
46
47// Example of applying sneak to a link:
48/*
49(function() {
50    var sneaky = new ScrollSneak(location.hostname);
51    document.getElementById('sneakytest').onclick = sneaky.sneak;
52})();
53 */

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.