PageSourceSearch

https://machida-tc.com/js/smoothScroll.js

js machida-tc.com collected 2026-10-05 11:14:54 UTC 3,116 bytes, 136 lines download raw bytes

1/**
2* smoothScrollEx Plugin ver1.1
3*
4* 2015 Jun Sato http://creator-index.com/
5*
6* MIT-style license.
7*
8*/
9
10;(function($) {
11    
12      var url = window.location;	
13      var path = url.href.split('/');
14      var file_name = path.pop();
15      if (file_name == "") {file_name = "index.html"} 
16      
17      if (file_name.indexOf('id=') != -1 ) {
18        var split_file_name = file_name.split('?');
19        file_name = split_file_name[0];
20      }
21      
22      sessionStorage.fileName = file_name;   
23
24
25
26	$(window).load(function(){
27			
28		var options = $.extend({
29			
30			scrollSpeed: 1000,
31			easing: 'swing',
32			adjustment: 0,
33			delayTime: 100
34			
35			},options);
36				
37		$('[href*="#"]').click(function(event){
38			var element = $(this);
39			var elementHref = element.attr('href');
40  
41       
42       
43			if(elementHref.search(/^#.+/) === 0){
44			
45				var targetId = elementHref;
46				var targetY = $(targetId).offset().top + options.adjustment;
47				event.preventDefault();
48				$('html,body').animate({scrollTop: targetY},options.scrollSpeed,options.easing);
49			
50			}else {
51      
52        var fileName = elementHref.split('/').pop().split(/#/);
53        
54        if (sessionStorage.fileName == fileName[0]) {
55        
56        try {
57          var targetY = $("#" + fileName[1]).offset().top + options.adjustment;
58        } catch(e) {
59          return;
60        }
61        
62        
63				event.preventDefault();
64				$('html,body').animate({scrollTop: targetY},options.scrollSpeed,options.easing);
65        
66        }
67        sessionStorage.fileName = fileName[0];
68	
69				var hrefSplit = elementHref.split(/#/);
70				var hrefFirst = hrefSplit[0];
71				var hrefLast = '#' + hrefSplit[1];
72
73				var pathname = location.pathname;
74				var pathnameSplit = pathname.split(/\//);				
75				var pathnameLast = pathnameSplit[pathnameSplit.length - 1];
76        
77        if (pathnameLast == "") {
78          pathnameLast = "index.html"
79        }
80				
81				var hostname = location.hostname;
82			
83				function aHrefCheck(){ 
84				 
85					var check1 = hrefFirst.match(/https?:\/\/.[^\/]+\//);
86  
87					if(check1 === null){
88						return true;
89					}else{
90						var check2 = check1[0].indexOf(hostname);
91						if (check2 != -1){
92							return true;
93						}else{
94							return false;
95						}
96					}
97				}			
98		
99				function aHrefChange(){
100					if (hrefFirst.indexOf(hostname) !== -1 || hrefFirst.indexOf(pathnameLast) === -1){
101						hrefLast = hrefLast.replace('#','?id=');			
102						elementHref = hrefFirst + hrefLast;
103						element.attr('href',elementHref);			
104					}else{
105						return;
106					}
107				}
108				
109				if(aHrefCheck() === true){
110					aHrefChange();
111				}else{
112
113					return;
114				}		
115			}
116		});
117				
118		var url = $(location).attr('href');
119		var stringMatch = url.indexOf('?id=');
120		
121		if(stringMatch === -1){
122			return;
123		}else {
124			var urlSplit = url.split(/\?id=/);
125			var anchorLink = '#' + urlSplit[urlSplit.length -1];
126			var anchorLinkTop = $(anchorLink).offset().top + options.adjustment;
127			
128			$('html,body').delay(options.delayTime).animate({scrollTop: anchorLinkTop},options.scrollSpeed,options.easing);
129			
130		}
131
132	return this;
133	
134	});
135		
136})(jQuery);

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.