PageSourceSearch

https://naac.org.hk/js/init.js

js naac.org.hk collected 2026-10-02 19:07:58 UTC 3,821 bytes, 140 lines download raw bytes

1$(document).ready(function(){
2	let init_size = get_cookie('size');
3	if(init_size == 'larger') {
4		$('html, header, .add_size_class').addClass('largerSize');
5	}
6	else if(init_size == 'normal') {
7		$('html, header, .add_size_class').addClass('normalSize');
8	}
9	else if(init_size == 'small') {
10		$('html, header, .add_size_class').addClass('smallSize');
11	}
12
13
14
15	$('.table-responsive', '.editor').table({
16		className: 'table-responsive-wrapper',
17		width: 768		
18	});
19	$('.aaa-c button').click(function(){
20		if(!$(this).hasClass('cur')) {
21			var font = $(this).data('font');
22			var size = $(this).data('size');
23			$('html').css('font-size', font);
24			change_size(size);
25		}
26	});
27	
28	var cur_size = get_cookie('size');
29	if(cur_size) {
30		$('.size button.' + cur_size).trigger('click');
31	}
32	else {
33		$('.size button.normal').trigger('click');
34	}
35	$(".menu-btn").on('click',function(){
36		let menu = $(".menu-container");
37		if(menu.hasClass('active')){
38			menu.removeClass('active');
39			$("html").css('overflow-y','auto');
40		} else {
41			menu.addClass('active');
42			$("html").css('overflow-y','hidden');
43		}
44	});
45	$('.to-top').click(function(){
46		$('html').animate({
47			scrollTop: 0
48		});
49	});
50	var w = $('.menu').outerWidth(true) + 1;
51	var render = function() {
52			if($(window).scrollTop() == 0){
53				$('.to-top').fadeOut('fast'); 
54				$('header').removeClass('scrolled');
55				$('.whatsapp').addClass('movedown');
56				// if(window.innerWidth > 767)$('.wts').removeClass('up');
57			}else{
58				$('.to-top').fadeIn('slow'); 
59				$('header').addClass('scrolled');
60				$('.whatsapp').removeClass('movedown');
61				// if(window.innerWidth > 767)$('.wts').addClass('up');
62			}
63			var offset = 90;
64			if(window.innerWidth < 767)offset = 60;
65			// console.log($(window).scrollTop(),$(window).height(),$('footer').position().top + offset)
66			if($(window).scrollTop()+$(window).height() > $('footer').position().top + offset){
67				$('.to-top').removeClass('floating');
68				$('.whatsapp').removeClass('floating');
69			} else {
70				$('.to-top').addClass('floating');
71				$('.whatsapp').addClass('floating');
72
73			}
74
75			$('.subcontent').css('width', ($('.content').innerWidth() - w) + 'px');
76		
77		if(($(window).scrollTop() > $("header").height()) && !$("header").hasClass('sticky')){
78			$("header").addClass('sticky');
79		} else if(($(window).scrollTop() <= $("header").height()) && $("header").hasClass('sticky')){
80			$("header").removeClass('sticky');
81		}
82	};
83	$(window).on('scroll resize touchmove', render);
84	render();
85});
86
87function pad (str, max) {
88	str = str.toString();
89	return str.length < max ? pad("0" + str, max) : str;
90  }
91
92  
93function change_size(size) {
94	if(size == 'larger') {
95		$('html, header, .add_size_class').addClass('largerSize');
96	}
97	else {
98		$('html, header, .add_size_class').removeClass('largerSize');
99	}
100	if(size == 'normal') {
101		$('html, header, .add_size_class').addClass('normalSize');
102	}
103	else {
104		$('html, header, .add_size_class').removeClass('normalSize');
105	}
106	if(size == 'small') {
107		$('html, header, .add_size_class').addClass('smallSize');
108	}
109	else {
110		$('html, header, .add_size_class').removeClass('smallSize');
111	}
112	set_cookie('size', size);
113	$('.size').find('.cur').removeClass('cur');
114	$('.size button.' + size).addClass('cur');
115	$(window).trigger('resize');
116}
117
118function get_cookie(key) {
119	key = encodeURIComponent(key);
120	var reg = RegExp('(?:^|;\\s*)' + key + '=([^;]*)');
121	var cookie = document.cookie;
122	var val = false;
123	
124	if(match = cookie.match(reg)) {
125		val = decodeURIComponent(match[1]);
126	}
127	
128	return val;
129}
130
131function set_cookie(key, value) {
132	key = encodeURIComponent(key);
133	value = encodeURIComponent(value);
134	document.cookie = key + '=' + value + '; path=/;';
135}
136
137function del_cookie(key) {
138	key = encodeURIComponent(key);
139	document.cookie = key + '=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
140}

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.