PageSourceSearch

https://logintool.hexun.com/OtherInterFace/js/popup.js

js hexun.com collected 2026-10-01 08:52:25 UTC 15,095 bytes, 426 lines download raw bytes

1var move = false, _X, _Y;
2var targetGourl = "";
3var isIE = document.all ? true : false;
4var loginHost = getPopupLoginHost();
5// 财道没有 /qrcode/login,弹窗登录页是 /iframe/login.html(与和讯同一前端组件,参数一致)
6var loginPath = /homeway\.com\.cn$/.test(loginHost) ? '/iframe/login.html' : '/qrcode/login';
7
8/**
9 * 按宿主页面品牌 + 环境得到弹窗登录域名(POPBRAND-DEV-1、DEV-2)
10 */
11function getPopupLoginHost() {
12    var host = window.location.hostname.toLowerCase();
13    var brandHost = /(^|\.)homeway\.com\.cn$/.test(host) ? ['testreg.homeway.com.cn', 'reg.homeway.com.cn']
14        : /(^|\.)licaike\.com$/.test(host) ? ['test-reg.intcoop.licaike.com', 'reg.licaike.com']
15        : ['test-reg.hexun.com', 'reg.hexun.com'];
16    // 宿主页面是测试域名,或脚本从测试 logintool 加载,都按测试环境处理
17    var testRe = /(test|127\.0\.|localhost)/i;
18    var src = document.currentScript ? document.currentScript.src : '';
19    if (!src) {
20        var scripts = document.getElementsByTagName('script');
21        for (var i = 0; i < scripts.length; i++) {
22            if (/\/\/(test-)?logintool\.hexun\.com\/.*popup[^\/]*\.js/i.test(scripts[i].src)) {
23                src = scripts[i].src;
24                break;
25            }
26        }
27    }
28    var srcHost = src.replace(/^\w*:?\/\//, '').split(/[\/:?#]/)[0];
29    var isTest = testRe.test(host) || testRe.test(srcHost);
30    return isTest ? brandHost[0] : brandHost[1];
31}
32
33/**
34 * 定义准备拖拽的函数 按下鼠标onMousedown
35 * @param {any} e
36 */
37function StartDrag(e) {  //定义准备拖拽的函数 按下鼠标onMousedown
38
39    var parentwin = document.getElementById("alertFram");
40
41    var d = document;
42
43    var e = e ? e : event;
44
45    if (isIE) {
46        parentwin.setCapture(); //对当前对象的鼠标动作进行跟踪
47
48    } else {
49
50        window.captureEvents(Event.MOUSEMOVE | Event.MOUSEUP);
51
52    }
53
54    move = true;
55
56    //获取鼠标相对内容层坐标
57
58    //_X = parentwin.offsetLeft - e.clientX;
59
60    //_Y = parentwin.offsetTop - e.clientY;
61
62    var mx = e.pageX || e.clientX + document.documentElement.scrollLeft;
63    var my = e.pageY || e.clientY + document.documentElement.scrollTop;
64    var ox = parentwin.offsetLeft + 103;
65    var oy = parentwin.offsetTop + (isIE ? -40 : 75);
66    //alert(e.pageY)
67    //alert(e.clientY)
68    d.onmousemove = function (e) {//定义拖拽函数 鼠标放上拖动onMousemove
69        var e = e ? e : event;
70
71        if (move) {
72
73            //var parentwin = document.getElementById("alertFram");
74
75            //var x = e.clientX + _X;
76
77            //var y = e.clientY + _Y;
78            var mouseX = e.pageX || e.clientX + document.documentElement.scrollLeft;
79            var mouseY = e.pageY || e.clientY + document.documentElement.scrollTop;
80
81            //if (x <= 0)
82
83            //    x = 0
84
85            //if (y <= 0)
86
87            //    y = 0
88
89
90
91            //parentwin.style.left = (x) + "px";
92
93            //parentwin.style.top = (y) + "px";
94            parentwin.style.left = ox + mouseX - mx + "px";
95
96            parentwin.style.top = oy + mouseY - my + "px";
97
98            parentwin.style.cursor = "move";
99
100        }
101
102    }
103
104    d.onmouseup = function () {//定义停止拖拽函数 松开鼠标onMouseup
105
106        //停止对当前对象的鼠标跟踪
107
108        if (isIE) { parentwin.releaseCapture(); }
109
110        else { window.releaseEvents(Event.MOUSEMOVE | Event.MOUSEUP); }
111        d.onmousemove = null;
112        move = false;
113
114    }
115
116
117
118}
119
120//@mql_modify 2013-4-22 start-------
121//g_myBodyInstance = (document.documentElement ? document.documentElement : window);
122
123//window.onscroll = function () {
124//    var parentwin = document.getElementById("alertFram");
125
126//    if (parentwin != null) {
127//        parentwin.style.top = (window.screen.height * 0.2 + g_myBodyInstance.scrollTop) + "px";
128//    }
129//};
130
131//@mql_modify 2013-4-22 end-------
132
133var popup_state = false;
134/**
135 * 显示登录
136 */
137function popupLogin() {
138    popup('登录', '//'+loginHost+loginPath+'?gourl=' + encodeURIComponent(window.location.href), encodeURIComponent(window.location.href), 532);
139}
140
141/**
142 * 显示登录
143 */
144function popupLogin(select,tab) {
145    popup('登录', '//'+loginHost+loginPath+'?default='+(select||'qrcode')+'&tab='+(tab||'visible')+'&gourl=' + encodeURIComponent(window.location.href), encodeURIComponent(window.location.href), 532);
146}
147
148/**
149 * 显示注册
150 */
151function popupReg() {
152    popup('注册', '//'+loginHost+loginPath+'?gourl=' + encodeURIComponent(window.location.href), encodeURIComponent(window.location.href), 532);
153}
154
155/**
156 * 显示注册
157 */
158function popupReg(select,tab) {
159    popup('注册', '//'+loginHost+loginPath+'?default='+(select||'qrcode')+'&tab='+(tab||'visible')+'&gourl=' + encodeURIComponent(window.location.href), encodeURIComponent(window.location.href), 532);
160}
161
162
163/**
164 * 显示登录
165 */
166function popupLoginLck(){
167    popup('登录', '//'+loginHost+loginPath+'?lck=1&gourl=' + encodeURIComponent(window.location.href), encodeURIComponent(window.location.href), 532);
168}
169
170/**
171 * 弹窗
172 * @param {any} topic
173 * @param {any} frameurl
174 * @param {any} gourl
175 * @param {any} height
176 */
177function popup(topic, frameurl, gourl, height) {
178    targetGourl = gourl;
179    if (popup_state == false) {
180        popup_state = true;
181        popupW(topic, frameurl, 520, height);
182    }
183    return;
184}
185
186/**
187 * 改链接
188 */
189function changeHref() {
190    var obj = document.getElementById('ifrmlink');
191    var objT = document.getElementById('ifrmTitle');
192    if (obj.innerHTML == "注册") {
193        obj.href = "//"+loginHost+loginPath+"?gourl=" + targetGourl;
194        obj.innerHTML = "登录";
195        objT.innerHTML = "注册";
196    } else {
197        obj.href = "//"+loginHost+loginPath+"?gourl=" + targetGourl;
198        obj.innerHTML = "注册";
199        objT.innerHTML = "登录";
200    }
201}
202
203/**
204 * 带有宽度的调用
205 * @param {any} topic
206 * @param {any} frameurl
207 * @param {any} Pwidth
208 * @param {any} height
209 */
210function popupW(topic, frameurl, Pwidth, height) {
211    var showTxt = "注册";
212    var showTitle = "登录";
213    var linkUrl = "//"+loginHost+loginPath+"?gourl=" + targetGourl;
214    if (topic == "注册") {
215        showTitle = "注册";
216        showTxt = "登录";
217        linkUrl = "//"+loginHost+loginPath+"?gourl=" + targetGourl;
218    }
219    var eSrc;
220    try {
221        eSrc = (window.parent.document.all) ? window.event.srcElement : arguments[1];
222    } catch (e) { }
223
224    var shield = window.parent.document.createElement("DIV");
225    shield.id = "shield";
226    shield.style.position = "absolute";
227    shield.style.left = "0px";
228    shield.style.top = "0px";
229    shield.style.width = ((window.parent.document.documentElement.clientWidth > window.parent.document.documentElement.scrollWidth) ? window.parent.document.documentElement.clientWidth : window.parent.document.documentElement.scrollWidth) + "px"; ;
230    shield.style.height = ((window.parent.document.documentElement.clientHeight > window.parent.document.documentElement.scrollHeight) ? window.parent.document.documentElement.clientHeight : window.parent.document.documentElement.scrollHeight) + "px";
231    shield.style.background = "#333";
232    shield.style.textAlign = "center";
233    shield.style.zIndex = "10000";
234    shield.style.filter = "alpha(opacity=30)";
235    shield.style.opacity = 0.3;
236    var alertFram = window.parent.document.createElement("DIV");
237    var isIE = (document.all) ? true : false;
238    var isIE6 = isIE && ([/MSIE (\d+)\.0/i.exec(navigator.userAgent)][0][1] == 6);
239    alertFram.id = "alertFram";
240    //@mql_modify 2013-4-22 start----------
241    // alertFram.style.position = "absolute";
242    alertFram.style.position = "fixed";
243    //@mql_modify 2013-4-22 end;-----------
244    alertFram.style.left = "50%";
245    alertFram.style.top = "14%";
246    alertFram.style.marginLeft = "-230px";
247    //alertFram.style.marginTop = -75 + window.parent.document.documentElement.scrollTop + "px";
248    alertFram.style.width = Pwidth + "px";
249    alertFram.style.height = height + "px";
250    alertFram.style.background = "";
251    alertFram.style.textAlign = "center";
252    //alertFram.style.lineHeight = "150px";
253    alertFram.style.zIndex = "10001";
254
255    strHtml = "<style>#alertFram{width:520px;height:532px; border:solid 1px #ffffff;background:#FAF8FA;overflow: hidden;box-shadow: 0 2px 6px rgb(0 0 0 / 10%);border-radius: 8px;}\
256#alertFram dl{height:568px; overflow:hidden}\
257#alertFram dl,#alertFram dd,#alertFram dt{ margin:0px; padding:0px; border:0px;background:#f7f7f7}\
258#alertFram dt{ overflow:hidden;height: auto;}\
259#alertFram dd { padding:4px 6px 4px 9px; height:20px; overflow:hidden; zoom:1}\
260#alertFram .login_right{ float:right; padding-top:4px}\
261#alertFram .login_right .zc{ float:right; font-size:12px; color:#495a92; text-decoration:none; padding-right:6px; line-height:16px}\
262#alertFram .login_right .zc:hover{ text-decoration:underline; color:#990000}\
263#alertFram dd .memberLogin_topicClass{ float:left; font-size:16px; font-family:\"Microsoft YaHei\"; color:#000; margin:0px; padding:0px}\
264#alertFram dd .close{ background:url(https://logintool.hexun.com/img/v2/close.png) no-repeat 0 0;width:16px; height:16px;display:block; float:right;text-indent:-999px}</style>";
265    strHtml += "<dl><dd><div class='login_right'><a style='cursor:pointer;' onclick='closePop()' class='close'></a></div></dd>";
266    strHtml += "<dt><iframe sandbox=\"allow-scripts allow-top-navigation allow-same-origin allow-forms\" id=\"ifrReg\" name=\"ifrReg\" style=\"position:relative\" src='" + frameurl + "' scrolling='no' width='100%' frameborder='0' height='" + height + "px'></iframe></dt></dl>";
267
268
269    alertFram.innerHTML = strHtml;
270
271    window.parent.document.body.appendChild(alertFram);
272    window.parent.document.body.appendChild(shield);
273    //@mql_modify 2013-4-22 start-------
274    (function (win, doc) {
275        var isIE6 = !!document.all && doc.documentMode == undefined,
276            div = doc.getElementById("alertFram"),
277            html = doc.getElementsByTagName('html')[0],
278            divTop = 0;
279        if (isIE6 && doc.body.currentStyle.backgroundAttachment !== 'fixed') {//IE下防抖动
280            html.style.backgroundImage = 'url(about:blank)';
281            html.style.backgroundAttachment = 'fixed';
282            div.style.position = "absolute";
283            divTop = parseFloat(div.currentStyle.top) || 200;
284            win.onscroll = fixedHandle;
285        };
286        function fixedHandle() {
287            div.style.top = doc.documentElement.scrollTop + divTop + 'px';
288        }
289    })(window, document)
290    //@mql_modify 2013-4-22 end-------
291
292    this.setOpacity = function (obj, opacity) {
293        if (opacity >= 1) opacity = opacity / 100;
294        try { obj.style.opacity = opacity; } catch (e) { }
295        try {
296            if (obj.filters.length > 0 && obj.filters("alpha")) {
297                obj.filters("alpha").opacity = opacity * 100;
298            } else {
299                obj.style.filter = "alpha(opacity=\"" + (opacity * 100) + "\")";
300            }
301        } catch (e) { }
302    }
303    var c = 0;
304    this.doAlpha = function () {
305        if (++c > 30) { clearInterval(ad); return 0; }
306        setOpacity(shield, c);
307    }
308    var ad = setInterval("doAlpha()", 1);
309    this.doOk = function () {
310        alertFram.style.display = "none";
311        shield.style.display = "none";
312        try {
313            eSrc.focus();
314        } catch (e) { }
315    }
316    try {
317        eSrc.blur();
318    } catch (e) { }
319}
320
321/**
322 * 弹窗
323 * @param {any} topic
324 * @param {any} frameurl
325 * @param {any} height
326 */
327function popupHTML(topic, frameurl, height) {
328    popupWHTML(topic, frameurl, 520, height)
329}
330
331/**
332 * 弹窗
333 * @param {any} topic
334 * @param {any} popHtm
335 * @param {any} width
336 * @param {any} height
337 */
338function popupWHTML(topic, popHtm, width, height) {
339    var eSrc;
340    try {
341        eSrc = (window.parent.document.all) ? window.event.srcElement : arguments[1];
342    } catch (e) { }
343    var shield = window.parent.document.createElement("DIV");
344    shield.id = "shield";
345    shield.style.position = "absolute";
346    shield.style.left = "0px";
347    shield.style.top = "0px";
348    shield.style.width = "100%";
349    shield.style.height = ((window.parent.document.documentElement.clientHeight > window.parent.document.documentElement.scrollHeight) ? window.parent.document.documentElement.clientHeight : window.parent.document.documentElement.scrollHeight) + "px";
350    shield.style.background = "#333";
351    shield.style.textAlign = "center";
352    shield.style.zIndex = "10000";
353    shield.style.filter = "alpha(opacity=30)";
354    shield.style.opacity = 0.3;
355    var alertFram = window.parent.document.createElement("DIV");
356    alertFram.id = "alertFram";
357    alertFram.style.position = "absolute";
358    alertFram.style.left = "50%";
359    alertFram.style.top = "14%";
360    alertFram.style.marginLeft = "-225px";
361    alertFram.style.marginTop = -75 + window.parent.document.documentElement.scrollTop + "px";
362    alertFram.style.width = width + "px";
363    // alertFram.style.height ="600px";
364    alertFram.style.background = "";
365    alertFram.style.textAlign = "center";
366    //alertFram.style.lineHeight = "150px";
367    alertFram.style.zIndex = "10001";
368
369    var strHtml = "<dl><dd><h3>" + topic + "</h3><a style='cursor:hand;' onclick='closePop1()' class='close'>关闭</a></dd>";
370    //debugger;
371    //popHtm = HTMLEncode(popHtm);
372    strHtml += "<dt><table width=100% height=" + height + "px><tr><td valign=top align=left>" + popHtm + "</td></tr></table></dt></dl>";
373
374
375    alertFram.innerHTML = strHtml;
376    window.parent.document.body.appendChild(alertFram);
377    window.parent.document.body.appendChild(shield);
378    this.setOpacity = function (obj, opacity) {
379        if (opacity >= 1) opacity = opacity / 100;
380        try { obj.style.opacity = opacity; } catch (e) { }
381        try {
382            if (obj.filters.length > 0 && obj.filters("alpha")) {
383                obj.filters("alpha").opacity = opacity * 100;
384            } else {
385                obj.style.filter = "alpha(opacity=\"" + (opacity * 100) + "\")";
386            }
387        } catch (e) { }
388    }
389    var c = 0;
390    this.doAlpha = function () {
391        if (++c > 30) { clearInterval(ad); return 0; }
392        setOpacity(shield, c);
393    }
394    var ad = setInterval("doAlpha()", 1);
395    this.doOk = function () {
396        alertFram.style.display = "none";
397        shield.style.display = "none";
398        try {
399            eSrc.focus();
400        } catch (e) { }
401    }
402    try {
403        eSrc.blur();
404    } catch (e) { }
405}
406
407/**
408 * 关闭检查
409 */
410function closePopHtml() {
411    try {
412        window.parent.document.body.removeChild(window.parent.document.getElementById("shield"));
413        window.parent.document.body.removeChild(window.parent.document.getElementById("alertFram"));
414    } catch (e) { }
415}
416
417/**
418 * 关闭检查
419 */
420function closePop() {
421    try {
422        parent.document.body.removeChild(parent.document.getElementById("shield"));
423        parent.document.body.removeChild(parent.document.getElementById("alertFram"));
424        popup_state = false;
425    } catch (e) { }
426}

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.