PageSourceSearch

https://www.thermage.hk/Assets/Thermage-hk/js/common.js

js thermage.hk collected 2026-09-27 05:15:03 UTC 11,546 bytes, 356 lines download raw bytes

1var config_vars = {
2	cookieFontSize : 'thermage_pagesizes'
3	,cookieAlert: 'thermage_alert'
4	,defaultFontSize : 'middle'
5	,fontClassNameSuffix : '_size'
6	,fontClassNameSmall : 'small'
7	,fontClassNameMiddle : 'middle'
8	,fontClassNameLarge : 'large'
9	,fontSizeControlSelector : '#sizecontrol'
10};
11var langs = new Array('en', 'tc', 'sc');
12var langCaption = new Array('English', '繁體中文', '簡体中文');
13var lang = '';
14var langSearch = '';
15
16function Menu() {
17	this.contentId = 0;
18	this.alt = "";
19	this.href = "";
20	this.target = "";
21	this.Class = "";
22	this.aClass = "";
23	this.divClass = "";
24	this.menuItem="";
25	this.ulID = '';
26	this.ulClass = '';
27	this.extraHTML="";
28	this.childs = new Array();
29	this.addChild = function(m) {
30		this.childs[this.childs.length] = m;
31	}
32}
33
34var common_text = {
35	"image_txt" : {
36		"en" : "Image",
37		"tc" : "圖片",
38		"sc" : "图片"
39	},
40	"home_txt" : {
41		"en" : "Home",
42		"tc" : "首頁",
43		"sc" : "首页"
44	},
45	"copyright_txt" : {
46		"en" : "Copyright © 2014",
47		"tc" : "版權所有 不得轉載",
48		"sc" : "版权所有 不得转载"
49	}
50}
51
52for(var counter=0; counter<langs.length; counter++){
53	if(location.href.toString().search('/'+langs[counter]+'/')!=-1){
54		lang = langs[counter];
55		
56	}
57}
58if(lang==''){
59	var temp = 1;
60	if (location.href.indexOf("lang=")>0) {
61		temp = location.href.match(/lang=\d+/)[0];
62		temp = temp.replace('lang=','') - 1;
63	}
64	lang = langs[temp];
65	var currentSection = '';
66}else{
67	var theEval = eval('/'+lang+'\\/[a-zA-Z0-9\_]+/');
68	var currentSection = location.href.toString().match(theEval)[0].replace(lang+'/','');
69}
70try{
71	var currentRootSection = zmsCurrentContentId;
72	if(zmsParentContentId!=''){
73		currentRootSection = zmsParentContentId.match(/\d+,$/)[0].replace(',','');
74	}
75	
76}catch(e){
77}
78
79function getPath(){
80	var langs = ['en', 'tc', 'sc'];
81	var currentLang = langs[0];
82	for(x in langs){
83		if(location.href.search("/"+langs[x]+"/")!=-1){
84			currentLang = langs[x];
85		}
86	}
87	//alert(location.href.substr(0, location.href.search('/'+currentLang+'/')));
88	return [location.href.substr(0, location.href.search('/'+currentLang+'/')), currentLang];
89}
90var temp = getPath();
91var currentPath = temp[0];
92var currentLang = temp[1];
93var currentPathLang = temp[0] + '/' + temp[1] + '/';
94//var zmsCharsetID = langs.indexOf(currentLang) + 1;
95
96function SwitchLang(charsetID){
97	var url = window.location.toString();
98	var isStaticURL = false;
99	var langPaths = new Array("en", "tc", "sc");
100	var oldLangPath = "";
101
102	// Check url type (is static page or dynamic page)
103	for (i=0; i < langPaths.length; i++){
104		if (url.indexOf("/"+langPaths[i]+"/") != -1){
105			oldLangPath = "/"+langPaths[i]+"/";
106			isStaticURL = true;
107			break;
108		}
109	}
110
111	if (isStaticURL){
112		var path;
113		path = window.location.href;
114		window.location = path.replace(oldLangPath, "/"+langPaths[charsetID - 1]+"/");
115	}else{
116		if (url.indexOf("lang=") != -1){
117			window.location = 
118				url.replace(/lang=\d/, "lang="+charsetID);
119		}
120	}
121}
122
123/* FontSize */
124var currnetAlert = getCookie(config_vars.cookieAlert);
125currnetAlert = currnetAlert.replace("=", "");
126if(currnetAlert==''){currnetAlert = 'false';}
127function loadAlert(){
128	var currnetAlert = getCookie(config_vars.cookieAlert);
129	currnetAlert = currnetAlert.replace("=","");
130	if(currnetAlert==''){currnetAlert = 'false';}
131	if(currnetAlert == 'false'){
132		return false;
133	}else{
134		return true;
135	}
136}
137function setAlert(){
138	setCookie(config_vars.cookieAlert, 'true', 365);
139	$('#wrapper').removeClass('alert');
140}
141var currFontSize = getCookie(config_vars.cookieFontSize);
142currFontSize = currFontSize.replace("=","");
143if(currFontSize==''){currFontSize = config_vars.defaultFontSize;}
144var sizeKeyWords = [
145	{classname:config_vars.fontClassNameSmall, caption:'Small'},
146	{classname:config_vars.fontClassNameMiddle, caption: 'Mid'}, 
147	{classname:config_vars.fontClassNameLarge, caption: 'Large'}
148];
149function loadFontSize() {
150	var currFontSize = getCookie(config_vars.cookieFontSize);
151	currFontSize = currFontSize.replace("=","");
152	if(currFontSize==''){currFontSize = config_vars.defaultFontSize;}
153	var index=1;
154	for(var i in sizeKeyWords){
155		if(sizeKeyWords[i].classname==currFontSize){	index=i;	break;	}
156	}
157	changeFontSize(parseInt(index)+1, true);
158}
159
160function changeFontSize(index, isPageStart){
161//	if(! isPageStart){
162		for(var i in sizeKeyWords){
163			var ClassName = sizeKeyWords[i].classname;
164			if(i==index-1){
165				$(config_vars.fontSizeControlSelector).addClass(''+ClassName+config_vars.fontClassNameSuffix);
166				$('.'+ClassName).parent('li').addClass('selected');
167			}else{
168				$(config_vars.fontSizeControlSelector).removeClass(''+ClassName+config_vars.fontClassNameSuffix);
169				$('.'+ClassName).parent('li').removeClass('selected');
170			}
171		}
172//	}
173	setCookie(config_vars.cookieFontSize, sizeKeyWords[index-1].classname, 365);
174	
175}
176function getCookie(c_name) {
177	if (document.cookie.length>0) {
178		c_start=document.cookie.indexOf(c_name + "=");
179		if (c_start!=-1) { 
180			c_start=c_start + c_name.length+1;
181			c_end=document.cookie.indexOf(";",c_start);
182			if (c_end==-1) c_end=document.cookie.length;
183				return unescape(document.cookie.substring(c_start,c_end));
184		} 
185	}
186	return "";
187}
188function setCookie(c_name,value,expiredays) {
189	var exdate=new Date();
190	exdate.setDate(exdate.getDate()+expiredays);
191	deleteCookie(c_name);
192	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString()+";path=/");
193}
194
195function deleteCookie(c_name) {
196	if (getCookie(c_name))	document.cookie = c_name + "=;expires=Thu, 01-Jan-1970 00:00:01 GMT;path=/";
197}
198function isDescendant(parent, child) {
199	var node = child.parentNode;
200	while (node != null) {
201		if (node == parent) {
202			return true;
203		}
204		node = node.parentNode;
205	}
206	return false;
207}
208//popup print
209function popupPrintInit(id, callback){
210	if ($("iframe#"+id).length === 0 ){
211		$("#content").append("<iframe id='hiddenPrint' src='/__new_project/print/index.html' style='position: absolute; border: 0px; width: 1px; height: 1px;' />");
212		var ifrm = document.getElementById(id);
213		$(ifrm).load(callback);
214	}else{
215		callback();
216	}
217}
218
219function printPage(){
220	var id = "hiddenPrint";
221	popupPrintInit(id, function(){
222		var ifrm = document.getElementById(id);
223		var frameDoc = ifrm.contentDocument || ifrm.contentWindow;
224		if (frameDoc.document){
225			frameDoc = frameDoc.document;
226		}		
227		var cloneHTMLText = $('#content').clone().html();
228		var pathPattern = /\.\.\/\.\.\//g;
229		for(var i=2;i<(location.pathname.match(/\//g) || []).length;i++){
230			cloneHTMLText = cloneHTMLText.replace(pathPattern, "../");
231		}
232		cloneHTMLText = cloneHTMLText.replace(/\.\.\//g, currentPath + '/');
233		frameDoc.getElementById('content').innerHTML = cloneHTMLText;
234
235		var iw = ifrm.contentWindow || ifrm;
236		$(ifrm).show(); // Work around with IE
237		iw.focus(); // Work around with IE
238		iw.print();
239		//$(ifrm).hide();
240	});
241}
242
243var popW = 600;
244var popH = 450;
245/* topbar social links : START */
246function shareToFaceBook(_sharePath){
247  var currentPath = escape(document.URL);
248  //alert(currentPath);
249	if(typeof _sharePath == "string"){
250		currentPath = escape(_sharePath);
251	}
252	var extLink = 'http://www.facebook.com/share.php?u=';
253	var pageTitle = encodeURI('選用Thermage,一次療程,即重拾年輕!');
254  var left = (screen.width/2)-(popW/2);
255  var top = (screen.height/2)-(popH/2);	
256	window.open(extLink + currentPath + '&t=' + pageTitle,'_blank', 'width='+popW+', height='+popH+', top='+top+', left='+left); 
257  //return false;
258}
259 
260function shareToTwitter(_sharePath){
261 	var currentPath = escape(document.URL);
262	if(typeof _sharePath == "string"){
263		currentPath = escape(_sharePath);
264	}
265	var extLink = 'http://twitter.com/home?status=';
266	var pageTitle = encodeURI('選用Thermage,一次療程,即重拾年輕!');
267  var left = (screen.width/2)-(popW/2);
268  var top = (screen.height/2)-(popH/2);
269	window.open(extLink + pageTitle + '%3A+' + currentPath, '_blank', 'width='+popW+', height='+popH+', top='+top+', left='+left); 					
270	//return false;
271}
272 
273function shareToWeibo(_sharePath){
274	var currentPath = escape(document.URL);
275	if(typeof _sharePath == "string"){
276		currentPath = escape(_sharePath);
277	}
278	var extLink = "http://v.t.sina.com.cn/share/share.php?title=";
279	var pageTitle = encodeURI('選用Thermage,一次療程,即重拾年輕!');
280  var left = (screen.width/2)-(popW/2);
281  var top = (screen.height/2)-(popH/2);		
282	window.open(extLink + pageTitle + '&url=' + currentPath + '&source=bookmark', '_blank', 'width='+popW+', height='+popH+', top='+top+', left='+left); 
283    //return false;
284}
285 
286function emailForm(_sharePath)
287{
288	var currentPath = escape(document.URL);
289	if(typeof _sharePath == "string"){
290		currentPath = escape(_sharePath);
291	}
292	var pageTitle = encodeURI('選用Thermage,一次療程,即重拾年輕!');
293	
294	
295	var mailto_link = 'mailto:?subject='+pageTitle+'&body='+currentPath;
296  var left = (screen.width/2)-(popW/2);
297  var top = (screen.height/2)-(popH/2);		
298	$('.email_to a').attr('href', mailto_link);
299	return false;
300} 
301/* topbar social links : END */
302
303/*  search result */
304function addHeaderSearchForm(){
305	var txt_form = '';
306	txt_form+='<form id="search" enctype="application/x-www-form-urlencoded" method="get" action="'+zmsSitePrefix + '/' + langs[ zmsCharsetID - 1]+ '/' + 'search_result/index.html" class="clearfix">';
307	txt_form+='<label for="cx">
307<input id="cx" name="cx" type="hidden" value="008059672872597293162:mgmwc_wey4w" /></label>';
308	txt_form+='<label for="cof"><input id="cof" name="cof" type="hidden" value="FORID:11" /></label>';
309	txt_form+='<label for="ie"><input name="ie" type="hidden" value="UTF-8"></label>';
310	txt_form+='<label for="hl">';
311	if (langs[ zmsCharsetID - 1] == 'en'){
312		txt_form+='<input name="hl" type="hidden" value="en"></label>';
313	}else if (langs[ zmsCharsetID - 1] == 'tc'){
314		txt_form+='<input name="hl" type="hidden" value="zh-TW"></label>';
315	}else if (langs[ zmsCharsetID - 1] == 'sc'){
316		txt_form+='<input name="hl" type="hidden" value="zh-CN"></label>';
317	}	
318	txt_form+='<div id="searchInput">';
319	txt_form+='<label class="hidden" for="q">Search:</label> <input class="searchinput" type="text" placeholder="'+langTxt[langs[zmsCharsetID - 1]]['Search']+'" name="q" id="q" onkeypress="if (event.keyCode==13)header_search()" />';
320	txt_form+=' <a id="btn_search" class="btn" href="javascript:header_search();">'+langTxt[langs[zmsCharsetID - 1]]['Go']+'</a>';
321	txt_form+='</form>';
322
323	$('#searchBarBox').children().remove();
324	$(txt_form).appendTo('#searchBarBox');
325}
326
327function header_search(){
328	$('#search').submit();
329}
330function searchPageSubmit(){
331	$('#cse-search-box input[name="siteurl"]').remove();
332	$('#cse-search-box').submit();
333}
334/*  search result ends */
335
336$(document).ready(function () {
337	var word = "Thermage";
338
339	$('#main_nav li a, #mobile_nav li a').each(function () {
340		var regex = new RegExp("\\b" + word + "\\b", "gi");
341		var html = $(this).html();
342		var replacedHtml = html.replace(regex, function (match) {
343			return match + "<sup>&reg;</sup>";
344		});
345		$(this).html(replacedHtml);
346	});
347});
348$(document).ready(function () {
349	$(function () {
350		$('.Form__Element__Caption').each(function (i, elem) {
351			$(elem).html(function (i, html) {
352				return html.replace(/\*/g, "<span>*</span>");
353			});
354		});
355	});
356});

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.