/* APP Common Begin*/
try
{
    document.domain = "qq.com";
}
catch (e)
{
}

if (typeof AppTui == "undefined")
{
    var AppTui = new Object();
}

AppTui.$ = function(s)
{
    return (typeof s == "object") ? s: document.getElementById(s);
};

AppTui.Cookie = {
    getCookie: function(name)
    {
        var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));

        if (arr != null)
        {
            return window.unescape(arr[2]);

        }

        return null;
    },
    setCookie:function(name,value,expires,path,domain,secure){
        var expDays = expires*24*60*60*1000;
        var expDate = new Date();
        expDate.setTime(expDate.getTime()+expDays);
        var expString = expires ? "; expires="+expDate.toGMTString() : "";
        var pathString = "; path="+(path||"/");
        var domain = domain ? "; domain="+domain : "";
        document.cookie = name + "=" + escape(value) + expString + domain + pathString + (secure?"; secure":"");
    }
};

AppTui.HashTable = function()
{
    this.__construct();
};

AppTui.HashTable.prototype = {
    __construct: function()
    {
        this._hash = new Object();
    },

    set: function(key, value, rewrite)
    {
        if (rewrite !== false)
        {
            this._hash[key] = value;
        }
        else if (this.get(key) != null)
        {
            this._hash[key] = value;
        }
    },

    get: function(key)
    {
        if (typeof this._hash[key] != "undefined")
        {
            return this._hash[key];
        }
        else
        {
            return null;
        }
    },

    remove: function(key)
    {
        delete this._hash[key];
    }
};

AppTui.HashTable.getInstance = function()
{
    if (!this.__instance__)
    {
        this.__instance__ = new AppTui.HashTable();
    };

    return this.__instance__;
};


AppTui.Element = {
    getElementLeft: function(e)
    {
        return (e==null) ? 0 :
        (AppTui.$(e).offsetLeft + AppTui.Element.getElementLeft(AppTui.$(e).offsetParent));
    },

    getElementTop: function(e)
    {
        return (e==null) ? 0 :
        (AppTui.$(e).offsetTop + AppTui.Element.getElementTop(AppTui.$(e).offsetParent));
    },

    scrollIntoView: function(e)
    {
        var x = AppTui.Element.getElementLeft(e);
        var y = AppTui.Element.getElementTop(e);
        window.scrollTo(x, y);
    },

    remove: function()
    {
        for (var i=0; i<arguments.length; i++)
        {
            try
            {
                AppTui.$(arguments[i]).parentNode.removeChild(AppTui.$(arguments[i]));
            }
            catch (e)
            {
            }
        }
    }
};


AppTui.Page = {
    getPageWidth: function()
    {
        return document.body.scrollWidth || document.documentElement.scrollWidth || 0;
    },

    getPageHeight: function()
    {
        return document.body.scrollHeight || document.documentElement.scrollHeight || 0;
    },

    getBodyWidth: function()
    {
        return document.body.clientWidth || document.documentElement.clientWidth || 0;
    },

    getBodyTop: function()
    {
        return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
    },
    getPostionByDom: function(element)
    {
        var el;
        var ua = navigator.userAgent.toLowerCase();
        var isOpera = (ua.indexOf('opera') != -1);
        var isIE = (ua.indexOf('msie') != -1 && !isOpera); // not opera spoof
        if (typeof element == 'object'){
            el = element;
        }
        else{
            el = document.getElementById(element);
        }
        /*if (typeof el.parentNode == 'undefined' || el.style.display == 'none')
        {
            return false;
        }*/

        var parent = null;
        var pos = [];
        var box;
        if(el.getBoundingClientRect) //IE&FF
        {
            box = el.getBoundingClientRect();
            var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);
            var scrollLeft = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);
            return {x:box.left + scrollLeft, y:box.top + scrollTop};
        }
        else if(document.getBoxObjectFor) // gecko
        {
            box = document.getBoxObjectFor(el);
            var borderLeft = (el.style.borderLeftWidth)?parseInt(el.style.borderLeftWidth):0;
            var borderTop = (el.style.borderTopWidth)?parseInt(el.style.borderTopWidth):0;
            pos = [box.x - borderLeft, box.y - borderTop];
        }
        else // safari & opera
        {
            pos = [el.offsetLeft, el.offsetTop];
            parent = el.offsetParent;
            if (parent != el) {
                while (parent) {
                    pos[0] += parent.offsetLeft;
                    pos[1] += parent.offsetTop;
                    parent = parent.offsetParent;
                }
            }
        }

        if (ua.indexOf('opera') != -1 || ( ua.indexOf('safari') != -1 && el.style.position == 'absolute' ))
        {
            pos[0] -= document.body.offsetLeft;
            pos[1] -= document.body.offsetTop;
        }
        if (el.parentNode) { parent = el.parentNode; }
        else { parent = null; }
        while (parent && parent.tagName != 'BODY' && parent.tagName != 'HTML')
        { // account for any scrolled ancestors
            pos[0] -= parent.scrollLeft;
            pos[1] -= parent.scrollTop;
            if (parent.parentNode) { parent = parent.parentNode; }
            else { parent = null; }
        }
        return {x:pos[0], y:pos[1]};
    }
};



AppTui.Browser = new Object();
AppTui.Browser.ua = window.navigator.userAgent.toLowerCase();
AppTui.Browser.ie = /msie/.test(AppTui.Browser.ua);
AppTui.Browser.moz = /gecko/.test(AppTui.Browser.ua);


AppTui.User = {
    getUin: function()
    {
        if (AppTui.Cookie.getCookie("uin") && AppTui.Cookie.getCookie("skey"))
        {
            return parseInt(AppTui.Cookie.getCookie("uin").replace(/^o0*/, ""));
        }
        else
        {
            return 0;
        }
    },
    isLogin: function(e)
    {
        if(typeof _addPtlogin2_onResizeFunc == 'function' && typeof IFr_ptlogin2resize == 'function'){
            _addPtlogin2_onResizeFunc(IFr_ptlogin2resize);
        }
        AppTui.HashTable.getInstance().set("current_node",e);
        if(AppTui.User.getUin() > 0)
        {
            AppTui.Tui.getTuiData();
        }
        else{
            this.createLoginDiv();
            this.showLoginBox();
        }
        
    },
    loginBoxTopPos: function(){
        //
        var node = null;
        var top;
        if (typeof AppTui.HashTable.getInstance().get("current_node") == "object")
        {
            node = AppTui.HashTable.getInstance().get("current_node");
        }
        var pos = AppTui.Page.getPostionByDom(node);
        var clientPos = pos.y - AppTui.Page.getBodyTop();
        if (parseInt(clientPos) > 400)
        {
            top = pos.y - 340 +"px";
        }
        else{
            top = pos.y + 30 + "px";
        }
        return top;
    },
    showLoginBox: function(){
        AppTui.$("Login_Box").style.top = this.loginBoxTopPos();
        AppTui.$("Login_Box").style.left = (AppTui.Page.getBodyWidth() - 370)/2 + "px";
        AppTui.$("Login_Box").style.display = 'block';        
    },
    createLoginDiv: function(){
        if(AppTui.$("Login_Box") == null ){
        var Login_Box = document.createElement("div");
        Login_Box.setAttribute("id", "Login_Box");
        Login_Box.className = 'share_layer';
        Login_Box.style.width = 399+'px';
        Login_Box.style.height = 212+'px';
        Login_Box.innerHTML = '<div class="share_layer_main" ;
                pvCurUrl = pathname;
                pgvMain();
        }
}/*  |xGv00|8ef1d856c33cbefd3c785b84107e0ed4 */

相关文章:

  • 2021-07-05
  • 2021-09-17
  • 2022-12-23
  • 2021-07-07
  • 2022-01-16
  • 2022-12-23
  • 2021-08-16
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-21
  • 2022-12-23
  • 2022-12-23
  • 2021-07-26
  • 2021-11-17
相关资源
相似解决方案