PageSourceSearch

https://www.eit.ac.nz/wp-content/themes/eit2016/js/eit-translations.js

js eit.ac.nz collected 2026-10-02 05:23:36 UTC 1,517 bytes, 84 lines download raw bytes

1jQuery(document).ready(function($){
2
3	if($.cookie('language')) {
4		$('.language-toggle a').text('English');
5
6		//Do translation replacements
7
8		doTranslate();
9
10	}
11
12
13	$('.language-toggle').on('click','a',function(){
14
15		if($.cookie('language')) { //Maori > English
16			
17			$('.language-toggle a').text('Māori');
18			$.removeCookie('language',{ path : '/' });
19			console.log($.cookie('language'))
20
21			console.log('maori > english')
22			doTranslate(true);
23
24		}
25		else { //English > Maori
26
27			$('.language-toggle a').text('English');
28			$.cookie('language', '1', { path: '/'} );
29			console.log('english > maori')
30			doTranslate();
31
32		}
33
34	});
35
36
37	function doTranslate(reverse) {
38		
39
40		if(reverse !== true) {
41			reverse = false;
42		}
43
44		if(translations.length) {
45
46			$('h2, h3, h4, h5, h6').each(function(){
47
48				$element = $(this);
49
50				if($(this).children().length > 1) { //this heading has too many child elements which we will ruin if we try to translate text inside, so gtfo
51					return true;
52				}
53
54				if($(this).children().length == 1) { //this heading has an element inside, probably a link. We shall translate that instead.
55					$element = $(this).children().first();
56				}
57
58				var text = $element.text();
59
60				$.each(translations, function(){
61
62					var english = this.english;
63					var te_reo = this.te_reo;
64
65					if(reverse) {
66						text = text.replace(te_reo,english);
67					}
68					else {
69						text = text.replace(english,te_reo);
70					}
71					
72				});				
73
74				$element.text(text);
75
76			});
77
78		}
79
80
81	}
82
83
84});//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.