PageSourceSearch

http://big5.www.gov.cn/gate/big5/www.gov.cn/images/pub.js

js www.gov.cn collected 2026-10-02 02:12:24 UTC 7,443 bytes, 247 lines download raw bytes

1/* 政府網站pub.js
2* 1.IsIE8:是否ie8瀏覽器
3* 2.IsPC:是否PC端
4* 3.PcBackTop:PC端回到頂部
5* 4.Debounce:防抖
6* 6.MobiBackTop:手機端回到頂部
7*/
8
9var trs = (function () {
10  function IsIE8() {
11    var isIE = userAgentInfo.indexOf("compatible") > -1 && userAgentInfo.indexOf("MSIE") > -1;
12    if (isIE) {
13      var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
14      reIE.test(userAgentInfo);
15      var fIEVersion = parseFloat(RegExp["$1"]);
16      if (fIEVersion <= 8) {
17        return;
18      }
19    }
20  }
21  function IsPC() {
22    var userAgentInfo = navigator.userAgent;
23    var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
24    var flag = true;
25    for (var v = 0; v < Agents.length; v++) {
26      if (userAgentInfo.indexOf(Agents[v]) > 0) {
27        flag = false;
28        break;
29      }
30    }
31    return flag;
32  }
33  function debounce(fn,wait){
34    var timer = null;
35    return function(){
36      if(timer !== null){
37        clearTimeout(timer);
38      }
39      timer = setTimeout(fn,wait);
40    }
41  }
42  function PcBackTop() {
43    var dom = '<div id="back_top" class="back_top"><a>回到頂部</a></div>'
44    $('#back_top').remove()
45    if (IsPC()) {
46      $('body').append(dom)
47    }
48    $(window).scroll(function () {
49      if ($(window).scrollTop() > 0) {
50        $("#back_top").fadeIn(400);
51      } else { $("#back_top").fadeOut(400); }
52    });
53    $("#back_top").click(function () {
54      $('body,html').animate({ scrollTop: 0 }, 200);
55      return false;
56    });
57  }
58  function MobiBackTop() {
59    var dom = '<div id="mobi_back_top" class="m_back_top pchide"><a>回到頂部</a></div>'
60    $('#mobi_back_top').remove()
61    if (!IsPC()) {
62      $('body').append(dom)
63    }else{
64      $('#mobi_back_top').remove()
65    }
66    $(window).scroll(function () {
67      if ($(window).scrollTop() > 0) {
68        $("#mobi_back_top").fadeIn(400);
69      } else { $("#mobi_back_top").fadeOut(400); }
70    });
71    $("#mobi_back_top").click(function () {
72      $('body,html').animate({ scrollTop: 0 },200);
73      return false;
74    });
75  }
76  function SearchFn(){
77    $('#searchBtn').on('click',function(){
78      var winWidth = $(window).width();
79      $(this).toggleClass('active');
80      $('.header .searchBox').toggleClass('active');
81      if($(this).hasClass('active')){
82        $('.search_mi').focus()
83      }
84      if ($("#iframe_header").length > 0 && $('.header >.pchide:visible').length >0) {
85        $("#iframe_header_p",parent.document).height(Math.ceil($("#iframe_header").outerHeight()*winWidth/750));
86      }
87    })
88  }
89  function Tabs (dom) {
90    var index = null
91    $(dom+' .nav').on('mouseover','span',function(){
92      index = $(this).index()
93      $(this).addClass('active').siblings().removeClass('active');
94      $(dom).find('.ctx .item').eq(index).addClass('active').siblings().removeClass('active');
95    })
96  }
97  function H5Banner () {
98
99  }
100
101  return {
102    IsPC: IsPC,
103    IsIE8: IsIE8,
104    PcBackTop: PcBackTop,
105    MobiBackTop:MobiBackTop,
106    SearchFn: SearchFn,
107    Tabs: Tabs,
108    H5Banner: H5Banner
109  }
110})();
111
112/*** 註冊登錄等  ***/
113function gettime() {
114  var d = new Date();
115  var formatNumber = function(num) {
116    return num > 0 && num < 10 ? '0' + num : num;
117  };
118  return d.getFullYear() + "" + formatNumber(d.getMonth() + 1) + formatNumber(d.getDate()) + formatNumber(d.getHours()) + formatNumber(d.getMinutes()) + formatNumber(d.getSeconds());
119}
120
121function GetQueryString(name) {
122  var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
123  var r = decodeURI(window.location.search).substr(1).match(reg);
124  if(r!=null)return  r[2]; return null;
125}
126
127var servicecode = GetQueryString("servicecode");
128// var gourl = document.referrer;
129var gourl = encodeURI(top.location.href);
130var time = GetQueryString("time");
131var sign = GetQueryString("sign");
132var showname = GetQueryString("showname");
133if(servicecode==null||servicecode==""||time==null||time==""||sign==null||sign==""){
134  servicecode = "trs";
135  time = gettime();
136  sign = hex_md5(servicecode + 'CfQ9MR5u' + time);
137}
138
139$(function (){
140  idm.config({
141    debug: false, // 開啟調試模式,調用的所有api的返回值會在客戶端alert
142    url:'http://big5.www.gov.cn/gate/big5/user.www.gov.cn',		// 必填,idm地址
143    servicecode: servicecode, 				// 必填,接入代碼
144    time: time,
145    sign: sign,	// 必填,簽名
146    success:function(){	// 回調函數(成功)
147      isloginNew();
148    },
149    fail:function(r)	{	// 回調函數(失敗)
150      $(".nologin").removeClass("hide");
151    }
152  });
153
154  $('#userreg, #userreg1').click(function(){
155    idm.user.openreg ({
156      redirect:true,
157      gourl: gourl,// 業務地址:非必填。回調總入口將以sp參數返回
158      extargs: ''		// 擴展參數:非必填。回調將回傳
159    });
160  });
161  $('#userlogin, #userlogin1').click(function(){
162    idm.user.openlogin ({
163      redirect:true,
164      gourl: gourl,// 業務地址:非必填。回調總入口將以sp參數返回
165      extargs: ''		// 擴展參數:非必填。回調將回傳
166    });
167  });
168  $('#usercenter').click(function(){
169    idm.user.openedit ({
170      // gourl: gourl	// 票據:非必填。
171    });
172  });
173  $('#showname1').click(function(){ // wap
174    idm.user.open ({
175      ticket: ''	// 票據:非必填。
176    });
177  });
178  $("#logout, #logOutBtn1").click(function(){
179    idm.user.logout({
180      success:function(){	// 回調函數(成功)
181        if(gourl!=null&&gourl!=""){
182          top.location.href = gourl;
183        }else{
184          top.location.href = 'http://big5.www.gov.cn/gate/big5/user.www.gov.cn';
185        }
186      },
187      fail:function(r)	{	// 回調函數(失敗)
188
189      }
190    });
191  });
192  $("#logOutBtn1").click(function(){ // wap
193    idm.user.logout({
194      success:function(){	// 回調函數(成功)
195        var gourlM = GetQueryString("gourl");
196        if(gourlM!=null&&gourlM!=""){
197          top.location.href = gourlM;
198        }else{
199          top.location.href = 'http://big5.www.gov.cn/gate/big5/user.www.gov.cn';
200        }
201      },
202      fail:function(r)	{	// 回調函數(失敗)
203
204      }
205    });
206  });
207
208  // 查看電腦版
209  $('#godesktop').on('click', function () {
210    var isShowPc = localStorage.setItem('isShowPc', true)
211    $("meta[name='viewport']").attr("content", "width=1280, target-densitydpi=device-dpi")
212    $('body').append('<div id="showMobi" class="showMobi"><img src="/images/trs_mobiIcon.png" ignoreapd="true" />返回手機版</div>')
213  });
214  // 返回手機版
215  $('body').on('click', '#showMobi', function () {
216    var isShowPc = localStorage.setItem('isShowPc', false)
217    $("meta[name='viewport']").attr("content", "width=750, user-scalable=no, target-densitydpi=device-dpi")
218    $('#showMobi').remove()
219  });
220
221});
222
223function isloginNew(){
224  idm.user.islogin ({
225    success:function(r){	// 回調函數(成功)
226      var showname = r.showname;
227      if(showname==undefined){
228        showname = "****";
229      }
230      //注意 這個脫敏手機號進行了修改 頁面上顯示只能達到八個字符
231      if(showname.length==11){
232        showname = showname.replace('****','*');
233      }else{
234        showname = "  "+showname;
235      }
236      $("#showname, #showname1").html(showname);
237      $(".yeslogin").removeClass("hide");
238      $(".nologin").addClass("hide");
239    },
240    fail:function(r)	{	// 回調函數(失敗)
241      $(".nologin").removeClass("hide");
242      $(".yeslogin").addClass("hide");
243    }
244  });
245}
246
247

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.