CB2-20200827ONU\Administrator
2021-09-22 4d584101e46ff34b2694e88af706b9b2e92364bc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
 
var Sponsor = null;
 
//吴辉
//前台登录框
function Islogin(isRefresh, sponsor) {
    if (sponsor) {
        Sponsor = sponsor;
    }
    var Common = {
        getEvent: function () {//ie/ff
            if (document.all) {
                return window.event;
            }
            func = getEvent.caller;
            while (func != null) {
                var arg0 = func.arguments[0];
                if (arg0) {
                    if ((arg0.constructor == Event || arg0.constructor == MouseEvent) || (typeof (arg0) == "object" && arg0.preventDefault && arg0.stopPropagation)) {
                        return arg0;
                    }
                }
                func = func.caller;
            }
            return null;
        },
        getMousePos: function (ev) {
            if (!ev) {
                ev = this.getEvent();
            }
            if (ev.pageX || ev.pageY) {
                return {
                    x: ev.pageX,
                    y: ev.pageY
                };
            }
 
            if (document.documentElement && document.documentElement.scrollTop) {
                return {
                    x: ev.clientX + document.documentElement.scrollLeft - document.documentElement.clientLeft,
                    y: ev.clientY + document.documentElement.scrollTop - document.documentElement.clientTop
                };
            }
            else if (document.body) {
                return {
                    x: ev.clientX + document.body.scrollLeft - document.body.clientLeft,
                    y: ev.clientY + document.body.scrollTop - document.body.clientTop
                };
            }
        },
        getItself: function (id) {
            return "string" == typeof id ? document.getElementById(id) : id;
        },
        getViewportSize: { w: (window.innerWidth) ? window.innerWidth : (document.documentElement && document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body.offsetWidth, h: (window.innerHeight) ? window.innerHeight : (document.documentElement && document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.offsetHeight },
        isIE: document.all ? true : false,
        setOuterHtml: function (obj, html) {
            var Objrange = document.createRange();
            obj.innerHTML = html;
            Objrange.selectNodeContents(obj);
            var frag = Objrange.extractContents();
            obj.parentNode.insertBefore(frag, obj);
            obj.parentNode.removeChild(obj);
        }
    }
 
    ///------------------------------------------------------------------------------------------------------
    var Class = {
        create: function () {
            return function () { this.init.apply(this, arguments); }
        }
    }
    var Drag = Class.create();
    Drag.prototype = {
        init: function (titleBar, dragDiv, Options) {
            //设置点击是否透明,默认不透明
            titleBar = Common.getItself(titleBar);
            dragDiv = Common.getItself(dragDiv);
            this.dragArea = { maxLeft: 0, maxRight: Common.getViewportSize.w - dragDiv.offsetWidth - 2, maxTop: 0, maxBottom: Common.getViewportSize.h - dragDiv.offsetHeight - 2 };
            if (Options) {
                this.opacity = Options.opacity ? (isNaN(parseInt(Options.opacity)) ? 100 : parseInt(Options.opacity)) : 100;
                this.keepOrigin = Options.keepOrigin ? ((Options.keepOrigin == true || Options.keepOrigin == false) ? Options.keepOrigin : false) : false;
                if (this.keepOrigin) { this.opacity = 50; }
                if (Options.area) {
                    if (Options.area.left && !isNaN(parseInt(Options.area.left))) { this.dragArea.maxLeft = Options.area.left };
                    if (Options.area.right && !isNaN(parseInt(Options.area.right))) { this.dragArea.maxRight = Options.area.right };
                    if (Options.area.top && !isNaN(parseInt(Options.area.top))) { this.dragArea.maxTop = Options.area.top };
                    if (Options.area.bottom && !isNaN(parseInt(Options.area.bottom))) { this.dragArea.maxBottom = Options.area.bottom };
                }
            }
            else {
                this.opacity = 100, this.keepOrigin = false;
            }
            this.originDragDiv = null;
            this.tmpX = 0;
            this.tmpY = 0;
            this.moveable = false;
 
            var dragObj = this;
 
            titleBar.onmousedown = function (e) {
                var ev = e || window.event || Common.getEvent();
                //只允许通过鼠标左键进行拖拽,IE鼠标左键为1 FireFox为0
                if (Common.isIE && ev.button == 1 || !Common.isIE && ev.button == 0) {
                }
                else {
                    return false;
                }
 
                if (dragObj.keepOrigin) {
                    dragObj.originDragDiv = document.createElement("div");
                    dragObj.originDragDiv.style.cssText = dragDiv.style.cssText;
                    dragObj.originDragDiv.style.display = "none";
                    dragObj.originDragDiv.style.width = dragDiv.offsetWidth;
                    dragObj.originDragDiv.style.height = dragDiv.offsetHeight;
                    dragObj.originDragDiv.innerHTML = dragDiv.innerHTML;
                    dragDiv.parentNode.appendChild(dragObj.originDragDiv);
                }
 
                dragObj.moveable = true;
                dragDiv.style.zIndex = dragObj.GetZindex() + 1111;
                var downPos = Common.getMousePos(ev);
                dragObj.tmpX = downPos.x - dragDiv.offsetLeft;
                dragObj.tmpY = downPos.y - dragDiv.offsetTop;
 
                titleBar.style.cursor = "move";
                if (Common.isIE) {
                    dragDiv.setCapture();
                } else {
                    window.captureEvents(Event.MOUSEMOVE);
                }
 
                dragObj.SetOpacity(dragDiv, dragObj.opacity);
 
                //FireFox 去除容器内拖拽图片问题
                if (ev.preventDefault) {
                    ev.preventDefault();
                    ev.stopPropagation();
                }
 
                document.onmousemove = function (e) {
                    if (dragObj.moveable) {
                        var ev = e || window.event || Common.getEvent();
                        //IE 去除容器内拖拽图片问题
                        if (document.all) //IE
                        {
                            ev.returnValue = false;
                        }
 
                        var movePos = Common.getMousePos(ev);
                        dragDiv.style.left = Math.max(Math.min(movePos.x - dragObj.tmpX, dragObj.dragArea.maxRight), dragObj.dragArea.maxLeft) + "px";
                        dragDiv.style.top = Math.max(Math.min(movePos.y - dragObj.tmpY, dragObj.dragArea.maxBottom), dragObj.dragArea.maxTop) + "px";
 
                    }
                };
 
                document.onmouseup = function () {
                    if (dragObj.keepOrigin) {
                        if (Common.isIE) {
                            dragObj.originDragDiv.outerHTML = "";
                        }
                        else {
                            Common.setOuterHtml(dragObj.originDragDiv, "");
                        }
                    }
                    if (dragObj.moveable) {
                        if (Common.isIE) {
                            dragDiv.releaseCapture();
                        }
                        else {
                            window.releaseEvents(Event.MOUSEMOVE);
                        }
                        dragObj.SetOpacity(dragDiv, 100);
                        titleBar.style.cursor = "move";
                        dragObj.moveable = false;
                        dragObj.tmpX = 0;
                        dragObj.tmpY = 0;
                    }
                };
            }
        },
        SetOpacity: function (dragDiv, n) {
            if (Common.isIE) {
                dragDiv.filters.alpha.opacity = n;
            }
            else {
                dragDiv.style.opacity = n / 100;
            }
 
        },
        GetZindex: function () {
            var maxZindex = 0;
            var divs = document.getElementsByTagName("div");
            for (z = 0; z < divs.length; z++) {
                maxZindex = Math.max(maxZindex, divs[z].style.zIndex);
            }
            return maxZindex;
        }
    }
 
    $.ajax({
        url: "/Pages/common/CommonAjax.aspx?data=" + (new Date()).valueOf(),
        type: "POST",
        dataType: "html",
        data: { lg_datetype: "IsLogin" },
        global: false,
        cache: false,
        async: false,
        success: function (data) {
            if (data == "1") {
                //                document.getElementById("btn_submit").click();
                if (Sponsor != null) {
                    $(Sponsor).next("#btn_submit")[0].click();
                }
                else {
                    document.getElementById("btn_submit").click();
                }
            } else {
                var loginHtml = '<div id=\"AllDesk\"></div><div id=\"dragDiv\"><table cellpadding=\"3\" cellspacing=\"0\"><tr id=\"FirstDesk\"  class=\"FirstDesk\"><td colspan=\"2\"><strong>登录</strong><a id="CloseDesk" style=\"float: right; font-size: 22px; cursor: pointer;font-weight: bold;\">×</a></td></tr><tr><td  class=\"w100px\">帐号</td><td><input type=\"text\" id=\"LoginId\" class=\"txt\" maxlength=\"30\" /></td></tr> <tr><td class=\"w100px\">密码</td><td><input type=\"password\" id=\"PassWord\" class=\"txt\" maxlength=\"30\" /></td></tr><tr><td></td><td><input type=\"button\" class=\"btn\" id=\"btn_login_desk\" value=\"  \" name=\"btn_login_desk\" /><span id=\"TipsDesk\">&nbsp;</span></td></tr><tr><td class=\"LastDesk\"></td><td class=\"LastDesk\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"/register.html\" target=\"_blank\">立即注册</a></td></tr></table></div> ';
 
                $("body").append(loginHtml);
 
                ReLogin();
 
                new Drag("FirstDesk", "dragDiv", { opacity: 100, keepOrigin: false });
 
                window.onresize = function () {
                    try {
                        document.getElementById("AllDesk").width = document.body.clientWidth;
                        $("#AllDesk").height($("body").height());
                        $("#dragDiv").css({ top: ($(window).height() / 2 + $(document).scrollTop() - $("#dragDiv").height() / 2), left: ($(window).width() / 2 - $("#dragDiv").width() / 2) }).show();
                    }
                    catch (e) {
                        
                    }
                }
 
                $("#CloseDesk").click(function () {
                    $("#AllDesk").remove();
                    $("#dragDiv").remove();
                });
 
                $("#btn_login_desk").click(function () {
                    var LoginId = $.trim($("#LoginId").val());
                    var PassWord = $("#PassWord").val();
                    if (LoginId == "") {
                        $("#TipsDesk").html("帐号不能为空");
                    } else if (PassWord == "") {
                        $("#TipsDesk").html("密码不能为空");
                    } else {
                        $("#TipsDesk").html("");
                        $.ajax({
                            url: "/Pages/common/CommonAjax.aspx",
                            type: "POST",
                            dataType: "html",
                            data: { lg_datetype: "login", LoginId: LoginId, LoginPwd: PassWord },
                            global: false,
                            cache: false,
                            success: function (data) {
                                if (data == "success") {
                                    if (isRefresh == "yes") {
                                        window.location = location;
                                    } else {
                                        alertMsg("登录成功!");
                                        $("#AllDesk").remove();
                                        $("#dragDiv").remove();
                                    }
                                } else {
                                    $("#TipsDesk").html(data);
                                }
                            }
                        });
                    }
                });
            }
        }
    });
}
 
function ReLogin() {
    document.getElementById("AllDesk").width = document.body.clientWidth;
    $("#AllDesk").height($("body").height());
    $("#dragDiv").css({ top: ($(window).height() / 2 + $(document).scrollTop() - $("#dragDiv").height() / 2), left: ($(window).width() / 2 - $("#dragDiv").width() / 2) }).show();
    return false;
}