PageSourceSearch

https://img.chinaz.com/2020/js/uc1.js?20210906

js chinaz.com collected 2026-10-01 09:19:13 UTC 6,098 bytes, 166 lines download raw bytes

1var url = "https://uc.chinaz.com";
2$(function () {
3    xrLoginHtml();
4	var ucCookie = getCookie("ucvalidate");
5    if (ucCookie === null || ucCookie === "") {
6        delCookie("chinaz_zxuser");
7    }
8    var ticket = getCookie("chinaz_zxuser");
9    if (ticket === null || ticket === "") {
10        $.ajax({
11            type: "get",
12            url: url + "/api/open/checklogin",
13            data: { f: "news", p: "pc" },
14            xhrFields: {
15                withCredentials: true
16            },
17            dataType:"JSON",
18            success: function (msg) {
19                if (msg.code === 0) {
20                    setCookie("chinaz_zxuser", msg.data.ticket);
21                    GetUserInfo(msg.data.ticket);
22                }
23                else {
24                    let html = '<div class="login-div">  <a href="javascript:void(0);" onclick="OpenLogin()" class="login-btn login-before">[登录/注册]</a><div class="user-infor"></div>'
25                    $("#chinaz_topbar").html(html);
26
27                }
28            },
29            error: function () {
30            }
31        });
32    }
33    else {
34        GetUserInfo(ticket);
35    }
36
37    /**
38     * iframe登录需要监听子页面返回
39     */
40    // 监听前判断只能调用一次
41    // message只需触发一次,调用多次会多次返回结果
42    window.addEventListener('message', function (event) {
43        var type = event.data.type;
44        var data = event.data.data;
45
46        // 判断反馈类型
47        switch (type) {
48            case 'CLOSE_LOGIN': // 关闭登录,自行处理,关闭或删除iframe就好
49                closeLoginPop();
50                break;
51            case 'SUCCESS_LOGIN': // 成功登录,返回ticket,自行处理,但也需要关闭或删除iframe
52                setCookie("chinaz_zxuser", data.ticket);
53                GetUserInfo(data.ticket);
54                closeLoginPop();
55                break;
56            case 'REPEAT_LOGIN': // 重复登录,用户在其他栏目、平台、页面登录时触发
57                // 无返回参数,可以自行刷新页面或其他处理
58                location.reload();
59                break;
60            case 'CLIENT_JUMP': // 客户端调整连接(不是客户端调用可以删除)
61                console.log('需要客户端来跳转的连接:', data);
62                break;
63        }
64    }, false);
65
66});
67
68function OpenLogin() {
69    $("#my-login").attr('src', 'https://uc.chinaz.com/?t=2&p=pc&f=news&r=https://www.chinaz.com&i=1&o=1');
70    $(".com-login-box").show();
71}
72
73// 添加登录弹窗
74function xrLoginHtml() {
75    let ifmBoxHtml = '<div class="com-login-box">';
76    ifmBoxHtml += ' <iframe  id="my-login" scrolling="no" frameborder="0" src=""></iframe>'
77    ifmBoxHtml += '</div>'
78    $("body").append(ifmBoxHtml)
79}
80
81function closeLoginPop() {
82    $(".com-login-box").hide()
83    $("#my-login").attr('src', '')
84}
85
86function GetUserInfo(ticket) {
87    $.ajax({
88        url: 'https://comment.chinaz.com/api/Login/GetUserInfo',
89        type: 'POST',
90        dataType: 'JSON',
91        data: "ticket=" + ticket,
92	    xhrFields: {
93            withCredentials: true
94        },
95        success: function (msg) {
96            if (msg.code === 0) {
97				let html = ' <div class="userbar user-infor" style="display: block;">'
98				html += ' <a class="username item-expand" href="https://uc.chinaz.com/user/mine" id="top_link_center" target="_blank"><span>用户中心</span><i class="iconfont icon-xiangxia is-rotate"></i></a>'
99				html += '<div class="dropdownmenu-wrap menu-setting" id="settingpopup"><div class="dropdownmenu"><div class="clearfix dropdownmenu-inner"><ul class="menu-setting-list"><li><a href="https://mt.chinaz.com/media-index.aspx" target="_blank">传媒中心</a></li><li><a href="//my.chinaz.com/ToolMember/Member/Account"target="_blank">工具中心</a></li><li><a href="https://user.chinaz.net/consoleOverview/index" target="_blank">开放平台 </a></li></ul></div></div></div>'
100                html += '</div>'
101				html += ' <div class="user-infor">'
102				html += ' <a href="javascript:void(0);" onclick="loginout(\''+ ticket + '\')" class="logout">退出</a>'
103				html += '</div>'
104                $("#chinaz_topbar").html(html);
105				userMenu()
106            }
107        }
108    });
109}
110
111
112function loginout(ticket) {
113    $.ajax({
114        url: 'https://comment.chinaz.com/api/Login/LoginOut',
115        type: 'POST',
116        dataType: 'JSON',
117        contentType: 'application/x-www-form-urlencoded',
118        data: "ticket=" + ticket,
119        success: function (msg) {
120            if (msg.code === 0) {
121                delCookie("chinaz_zxuser");
122                window.location.href = "https://www.chinaz.com";
123            }
124        }
125    });
126}
127
128//读取cookies 
129function getCookie(cookieName) {
130    var cookieContent = '';
131    var cookieAry = document.cookie.split("; ");//得到Cookie数组   
132    for (var i = 0; i < cookieAry.length; i++) {
133        var temp = cookieAry[i].split("=");
134        if (temp[0] === cookieName) {
135            cookieContent = unescape(temp[1]);
136        }
137    }
138    return cookieContent;
139}
140
141//设置cookie值
142function setCookie(name, value) {
143    //document.cookie.setPath("/");
144    var hour = 8 * 29;
145    var exp = new Date();
146    exp.setTime(exp.getTime() + hour * 60 * 60 * 1000);
147    document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString() + ";Domain=.chinaz.com;path=/";
148}
149
150
151//删除cookie
152function delCookie(name) {
153    var exp = new Date();
154    exp.setTime(exp.getTime() - 1);
155    var cval = getCookie(name);
156    if (cval != null) {
157        document.cookie = name + "=" + cval + ";Domain=.chinaz.com;path=/;expires=" + exp.toGMTString();
158    }
159}
160
161function userMenu(){
162	var userbar = $('.userbar');
163	userbar.mouseleave(function(){$('.menu-setting').css({"display":"none"})})
164	userbar.mouseover(function(){$('.menu-setting').css({"display":"block"})})
165	
166}

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.