PageSourceSearch

https://www.ourchinastory.com/common/js/global_controll.js?v=20211029

js ourchinastory.com collected 2026-10-02 07:10:01 UTC 14,981 bytes, 377 lines download raw bytes

1// JavaScript Document
2
3var OldFirefox=false;
4var isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
5var isIpad = navigator.maxTouchPoints && navigator.maxTouchPoints > 2 && /MacIntel/.test(navigator.platform);
6
7function Init(){
8
9    if($(".Accordion").length>0){
10        $(".Accordion").each(function() {
11           $(this).click(function() {
12                if($(this).hasClass("Show")){
13                    $(this).toggleClass("Show");
14                    $(this).closest("section").animate({height:$(this).closest("section").find(".SectionHeader").outerHeight(true)},500,'easeOutQuart').removeClass("Show wMargin");
15                }else{
16                    $(".Accordion").removeClass("Show");
17                    $(this).toggleClass("Show");
18                    $("html,body").animate({scrollTop:$("header").outerHeight()+($(this).closest("section").index()+1)*$(this).closest("section").find(".SectionHeader").outerHeight()},500,'easeOutQuart');
19                    $(this).closest("section").siblings().animate({height:$(this).closest("section").find(".SectionHeader").outerHeight(true)},500,'easeOutQuart').removeClass("Show wMargin");
20                    $(this).closest("section").addClass("Show wMargin").animate({height: $(this).closest("section").outerHeight()+$(this).closest("section").find("main > article").outerHeight()},500,'easeOutQuart');
21                }
22             });
23        });
24    }
25
26
27    if($("#FooterWeChat, #ArticleWeChat, #GameWeChat").length>0){
28        if(isMobile){
29            $("#ArticleWeChat").click(function() {
30                $("html, body").toggleClass("Fixed");
31                $("#WeChatWrapper").css({"display":"flex"});
32            });
33			$("#GameWeChat").click(function() {
34                $("html, body").toggleClass("Fixed");
35                $("#WeChatWrapper").css({"display":"flex"});
36            });
37            $("#WeChatCloseButton").click(function() {
38                $("html, body").toggleClass("Fixed");
39                $("#WeChatWrapper").css({"display":"none"});
40            });
41        }else{
42            $("#FooterWeChat").mouseover(function() {
43                $("#WeChatWrapper").addClass("WeChatPop");
44                WeChatPopPosition();
45
46            });
47            $("#FooterWeChat").mouseout(function() {
48                $("#WeChatWrapper").css({"display":"none"}).removeClass("WeChatPop");
49            });
50
51			$("#GameWeChat").mouseover(function() {
52                $("#WeChatWrapper").addClass("WeChatPop");
53                WeChatGamePopPosition();
54
55            });
56            $("#GameWeChat").mouseout(function() {
57                $("#WeChatWrapper").css({"display":"none"}).removeClass("WeChatPop");
58            });
59
60			$("#ArticleWeChat").mouseover(function() {
61                $("#WeChatWrapper").addClass("WeChatPop");
62                WeChatArticlePopPosition();
63
64            });
65            $("#ArticleWeChat").mouseout(function() {
66                $("#WeChatWrapper").css({"display":"none"}).removeClass("WeChatPop");
67            });
68        }
69    }
70
71    function WeChatPopPosition(){
72        if(!isMobile && $("#WeChatWrapper").hasClass("WeChatPop")){
73            var WeChatPos=$("#FooterWeChat").offset();
74            $("#WeChatWrapper").css({"display":"flex","top":WeChatPos.top - $("#WeChatWrapper").outerHeight()-100 + "px","left":WeChatPos.left + $("#FooterWeChat").outerWidth()*0.5 - $("#WeChatWrapper").outerWidth()*0.5 - 10 + "px"});
75        }
76    }
77
78	function WeChatArticlePopPosition(){
79        if(!isMobile && $("#WeChatWrapper").hasClass("WeChatPop")){
80            var WeChatPos=$("#ArticleWeChat").offset();
81            $("#WeChatWrapper").css({"display":"flex","top":WeChatPos.top - $("#WeChatWrapper").outerHeight()-100 + "px","left":WeChatPos.left + $("#ArticleWeChat").outerWidth()*0.5 - $("#WeChatWrapper").outerWidth()*0.5 - 10 + "px"});
82        }
83    }
84	function WeChatGamePopPosition(){
85        if(!isMobile && $("#WeChatWrapper").hasClass("WeChatPop")){
86            var WeChatPos=$("#GameWeChat").offset();
87            $("#WeChatWrapper").css({"display":"flex","top":WeChatPos.top - $("#WeChatWrapper").outerHeight()-15 + "px","left":WeChatPos.left + $("#GameWeChat").outerWidth()*0.5 - $("#WeChatWrapper").outerWidth()*0.5 - 10 + "px"});
88        }
89    }
90
91    navigator.browserversion= (function(){
92        var ua= navigator.userAgent, tem,
93        M= ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
94        if(/trident/i.test(M[1])){
95            tem=  /\brv[ :]+(\d+)/g.exec(ua) || [];
96            return 'IE '+(tem[1] || '');
97        }
98        if(M[1]=== 'Chrome'){
99            tem= ua.match(/\b(OPR|Edge)\/(\d+)/);
100            if(tem!= null) return tem.slice(1).join(' ').replace('OPR', 'Opera');
101        }
102        M= M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?'];
103        if((tem= ua.match(/version\/(\d+)/i))!= null) M.splice(1, 1, tem[1]);
104        return M;
105    })();
106
107    if(navigator.browserversion[0]==="Firefox" && parseInt(navigator.browserversion[1])<70){
108        OldFirefox=true;
109        GridBoxHandler();
110    }
111
112	var className = $('body').attr('data-channel');
113	if($("header").find("div."+className).length !==0){
114		$("header").find("div."+className).addClass("Selected");
115	}
116	$("#MenuIcon").css({"flex-basis":$("header").outerHeight() + "px", "height":$("header").outerHeight()});
117	if($("#MenuIcon").length>0){
118		NavAction();
119		$(document).on('keyup',function(event){
120			if(event.keyCode == 27) {
121				if($("#MenuIcon").hasClass("Expand")){
122					MenuAction();
123				}
124                CloseCommentBubble(event);
125			}
126		});
127	}
128    $(document).click(function(event) {
129        CloseCommentBubble(event);
130	});
131
132	if($("#MenuIcon").length>0){
133        $("#MenuIcon").click(function() {
134            MenuAction();
135        });
136    }
137	if($("section.Expandable").length>0){
138		$(".ExpandableButton").on( "click", function() {
139			$("section.Expandable").toggleClass("Show");
140			if(!$("section.Expandable").hasClass("Show")){
141				var offsetPos=$("section.Expandable").offset();
142				$("html,body").animate({scrollTop:offsetPos.top+$("section.Expandable").outerHeight()*0.8},1000,'easeOutQuart');
143			}
144		});
145	}
146	if($("#BackToTop").length>0){
147        $("#BackToTop").click(function() {
148           $("html,body").animate({scrollTop:"0"},1000,'easeOutQuart');
149        });
150    }
151    if($(".MemPasswordTrigger").length>0){
152          $(".MemPasswordTrigger").each(function() {
153              $(this).click(function() {
154                  if($(this).hasClass("Show")){
155                      $(this).removeClass("Show");
156                      $(this).siblings(".MemberInput").attr("type","password");
157                  }else{
158                      $(this).addClass("Show");
159                      $(this).siblings(".MemberInput").attr("type","text");
160                  }
161              });
162          });
163    }
164    if($(".MemPassword").length>0){
165          $(".MemPassword > input").each(function() {
166              $(this).focus(function() {
167                  $(this).parent(".MemPassword").addClass("Focus");
168              });
169              $(this).blur(function() {
170                  $(this).parent(".MemPassword").removeClass("Focus");
171              });
172          });
173    }
174    if($("#CookieCloseBtn").length>0){
175        $("#CookieCloseBtn").click(function() {
176           $("#CookieWrapper").css({"display":"none"});
177        });
178    }
179
180    if($("#CloseOverlay").length>0){
181         $("#CloseOverlay").click(function() {
182			$("#OverlayWrapper .OverlayContainer .Container > p").html('');
183            $("#OverlayWrapper").removeClass("Show");
184            $("body").css({"overflow":"visible"});
185         });
186    }
187
188    if($(".CommentSelectBubble").length>0){
189         $(".CommentUserSelect").click(function(event){
190            event.preventDefault();
191            event.stopImmediatePropagation();
192            var UserSelect=$(this).position();
193            var TargetBox=$(this).parent().parent().parent().siblings(".CommentSelectBubble");
194            if($(this).hasClass("Active")){
195                CloseCommentBubble(event);
196            }else{
197                CloseCommentBubble(event);
198                $(TargetBox).addClass("Active").css({"left":UserSelect.left+$(this).outerWidth()+50,"top":UserSelect.top-($(this).outerHeight()+8)*0.5});
199                $(this).addClass("Active");
200            }
201        });
202    }
203    if($(".CommentSection").length>0){
204        UserCommentHandler();
205        var commentType = $('body').attr('comment-type');
206        if(commentType==="included"){
207            $("#CommentInclFooter #BackToTop").remove();
208            $("#CommentSwitcher, .CommentBtn > .Button.Cancel").css({"display":"none"});
209        }
210        if(commentType!="included"){
211            $("body").addClass("CommentPage");
212            $(".CommentSection").addClass("StandAlone");
213            $("#CommentPageHeader").css({"display":"block"});
214            //$("#CommentSwitcher").css({"display":"flex"});
215            $("#CommentPost").css({"bottom":($("#CommentPost").outerHeight(true)-$("#CommentTrigger").outerHeight(true)-18-$(window).innerWidth()*0.008)*-1+"px"});
216            $("#CommentInclHeader, #CommentInclFooter").css({"display":"block"});
217            $("#CommentTrigger").click(function() {
218                $("#CommentPost").animate({bottom:0},500,'easeOutQuart').addClass("Expand");
219                $("#CommentLightBox").addClass("Expand");
220                $(this).addClass("Hide");
221                $("#CommentLightBox").css({"display":"block"}).animate({opacity:1},500,'easeOutQuart');
222            });
223            $("#CommentLightBox").click(function() {
224                $("#CommentTrigger").removeClass("Hide");
225                $("#CommentPost").animate({bottom:($("#CommentPost").outerHeight(true)-$("#CommentTrigger").outerHeight(true)-18-$(window).innerWidth()*0.008)*-1+"px"},500,'easeOutQuart').removeClass("Expand");
226                $("#CommentLightBox").removeClass("Expand");
227                $("#CommentLightBox").animate({opacity:0}
227,500,'easeOutQuart',function(){$("#CommentLightBox").css({"display":"none"});});
228				$('#CommentSwitcher').removeClass('Close');
229            });
230            $("#CommentSwitcher, .CommentBtn > .Button.Cancel").click(function() {
231                if($("#CommentLightBox").hasClass("Expand")){
232                    $("#CommentTrigger").removeClass("Hide");
233                    $("#CommentPost").animate({bottom:($("#CommentPost").outerHeight(true)-$("#CommentTrigger").outerHeight(true)-18-$(window).innerWidth()*0.008)*-1+"px"},500,'easeOutQuart').removeClass("Expand");
234                    $("#CommentLightBox").removeClass("Expand");
235                    $("#CommentLightBox").animate({opacity:0},500,'easeOutQuart',function(){$("#CommentLightBox").css({"display":"none"});});
236                    $(this).removeClass("Close");
237					$('#CommentSwitcher').removeClass('Close');
238                }else{
239                    $("#CommentPost").animate({bottom:0},500,'easeOutQuart').addClass("Expand");
240                    $("#CommentLightBox").addClass("Expand");
241                    $("#CommentTrigger").addClass("Hide");
242                    $("#CommentLightBox").css({"display":"block"}).animate({opacity:1},500,'easeOutQuart');
243                    $(this).addClass("Close");
244                }
245            });
246        }
247    }
248
249    if($("#ArticleComment").length>0){
250        $("#ArticleComment a, #ArticleCommentTrigger .Button").click(function() {
251             var CommentY=$("#UserCommentBlock").offset();
252            $("html,body").animate({scrollTop:CommentY.top-100},800,'easeOutQuart');
253        });
254    }
255
256
257	$(window).resize(function() {
258		if($("#MenuIcon").length>0 && $("#MenuIcon").hasClass("Expand")){
259			if($("html,body").innerWidth()>1024){
260				MenuAction();
261			}else{
262				NavAction();
263				MenuIconAction();
264			}
265		}
266        if(OldFirefox){
267            GridBoxHandler();
268        }
269        WeChatPopPosition();
270        AboutUsContent();
271        if($(".CommentSection").length>0){
272            UserCommentHandler();
273        }
274	});
275
276
277}
278
279function CloseCommentBubble(event){
280    event.stopImmediatePropagation();
281    $(".CommentSelectBubble, .CommentUserSelect").removeClass("Active");
282}
283
284
285function UserCommentHandler(){
286   var commentType = $('body').attr('comment-type');
287   var windowWidth=$(window).innerWidth();
288   if(commentType!="included" && $("#CommentPost").hasClass("Active")){
289        if($("#CommentPost").hasClass("Expand")){
290            $("#CommentTrigger").addClass("Hide");
291            $("#CommentPost").css({"bottom":0});
292        }else{
293            $("#CommentTrigger").removeClass("Hide");
294            $("#CommentPost").css({"bottom":($("#CommentPost").outerHeight(true)-$("#CommentTrigger").outerHeight(true)-18-windowWidth*0.008)*-1+"px"});
295        }
296    }
297}
298
299
300
301function MenuAction(){
302	$("#MenuIcon, nav").toggleClass("Expand");
303	$("html, body, header").toggleClass("Fixed");
304	NavAction();
305}
306
307function NavAction(){
308	if($("nav").hasClass("Expand")){
309		$("#HeaderMenu nav").css({"height":"calc(100% - "+$("header").outerHeight()+"px)", "top":$("header").outerHeight()});
310		MenuIconAction();
311	}else{
312		$("#HeaderMenu nav").css({"height":"100%", "top":0});
313	}
314}
315
316function MenuIconAction(){
317	$("#MenuIcon").css({"flex-basis":$("header").outerHeight() + "px", "height":$("header").outerHeight()});
318}
319
320
321function GridBoxHandler(){
322    $(".Square").each(function() {
323        $(this).css({"min-height":$(this).outerWidth(), "padding-top":0});
324    });
325    $(".Horz-Rect").each(function() {
326        $(this).css({"min-height":$(this).outerWidth()*0.5, "padding-top":0});
327    });
328    $(".Vert-Rect").each(function() {
329        $(this).css({"min-height":$(this).outerWidth()*2, "padding-top":0});
330    });
331}
332
333
334function AboutUsContent(){
335    if($(".AboutUsContent").length>0){
336          $(".AboutUsContent").each(function() {
337              if(!$(this).hasClass("Show")){
338                $(this).css({"height":$(this).find(".SectionHeader").outerHeight(true)});
339              }else{
340                $(this).css({"height":"auto"});
341              }
342          });
343    }
344}
345
346
347function JumpPage(ID){
348    var PageY=$("#"+ID).offset();
349    $("html,body").animate({scrollTop:PageY.top-100},500,'easeOutQuart');
350}
351
352function showOverlay(information){
353	$("#OverlayWrapper .OverlayContainer .Container > p").html(information);
354	$("#OverlayWrapper").addClass("Show");
355    $("body").css({"overflow":"hidden"});
356}
357
358function showOverlayWithoutClose(information){
359	$("#OverlayWrapperWithoutClose .OverlayContainer .Container > p").html(information);
360	$("#OverlayWrapperWithoutClose").addClass("Show");
361    $("body").css({"overflow":"hidden"});
362}
363
364
365$(document).ready(function(){
366	Init();
367    AboutUsContent();
368	document.createElement('header');
369	document.createElement('section');
370	document.createElement('main');
371	document.createElement('article');
372	document.createElement('aside');
373	document.createElement('nav');
374	document.createElement('footer');
375	document.createElement('figure');
376});
377

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.