JohnBaek
7/5/2016 - 11:42 PM

JS_Daum_Gnb.js

JS_Daum_Gnb.js

function appendCss() {
    var b = "HEADERCSS";
    var a = document.createElement("link");
    a.rel = "Stylesheet";
    a.href = "http://game.daum.net/css/header.css";
    a.type = "text/css";
    a.charset = "utf-8";
    document.getElementsByTagName("head")[0].appendChild(a)
}

function addEvent(c, a, b) {
    if (c.addEventListener) {
        c.addEventListener(a, b, false)
    } else {
        if (c.attachEvent) {
            c.attachEvent("on" + a, b)
        } else {
            c["on" + a] = b
        }
    }
}
var DUI = {
    $: function(a) {
        return (a) ? ((typeof(a) == "string") ? document.getElementById(a) : a) : null
    }
};

function stopEvent(a) {
    var a = a || window.event;
    a.cancelBubble = true;
    if (a.stopPropagation) {
        a.stopPropagation()
    }
}

function display_daumLayer() {
    if (DUI.$("DaumUI__service_layer").style.display == "none") {
        DUI.$("DaumUI__service_layer").style.display = "block"
    } else {
        DUI.$("DaumUI__service_layer").style.display = "none"
    }
}
var Header = function() {
    this.group = DUI.$("game_header_category");
    this.titleArray = null;
    this.subArray = null
};
Header.prototype.getTitle = function() {
    var a = this.group.firstChild;
    var b = new Array();
    while (a) {
        if (a.nodeType == 1 && a.tagName == "LI") {
            b.push(a)
        }
        a = this.getNext(a)
    }
    return b
};
Header.prototype.getSub = function() {
    var c = this.titleArray;
    var h = c.length;
    var g = new Array();
    for (var d = 0; d < h; d++) {
        var f = c[d];
        for (var b = 0, a = f.length; b < a; b++) {
            if (f[b].nodeType == 1 && f[b].tagName == "DIV") {
                g.push(f[b])
            }
        }
        return g
    }
};
Header.prototype.titEvent = function() {
    var c = this.titleArray;
    var a = c.length;
    var b = this;
    for (var d = 0; d < a; d++) {
        c[d].onmouseover = function() {
            b.showSub(this)
        };
        c[d].onmouseout = function() {
            b.hideSub(this)
        }
    }
};
Header.prototype.showSub = function(d) {
    var c = d;
    var b = this.titleArray;
    var a = b.length;
    var f = null;
    f = c.id + "_list";
    if (DUI.$(f)) {
        DUI.$(f).style.display = "block"
    } else {}
};
Header.prototype.hideSub = function(d) {
    var c = d;
    var b = this.titleArray;
    var a = b.length;
    var f = null;
    f = c.id + "_list";
    if (DUI.$(f)) {
        DUI.$(f).style.display = "none"
    } else {}
};
Header.prototype.getNext = function(b) {
    var b = b || window.event;
    var a = b.nextSibling;
    while (a && a.nodeType != 1) {
        a = a.nextSibling
    }
    return a
};
Header.prototype.initialize = function(a) {
    this.titleArray = this.getTitle();
    this.subArray = this.getSub(a);
    this.titEvent()
};
var Draw = function() {
    this.area = DUI.$("DAUM_GAME_HEADER_AREA");
    this.str = new Array();
    this.cateData = category_promotion;
    this.bnrData = banner;
    this.daumLink = daumlink;
    this.TYPE1 = category_genre.length;
    this.SERVICE = daumlink[0].link_list.length
};
Draw.prototype.layout = function() {
    if (!this.area) {
        return false
    }
    var a = this.str;
    a[a.length] = '<div id="DAUM_GAME_HEADER_WRAP">';
    a[a.length] = ' <div id="DAUM_GAME_HEADER">';
    a[a.length] = '   <ul id="gh_service_title">';
    a[a.length] = '     <li class="logo_daum_game"><a href="http://game.daum.net/" target="_top">Daum게임</a></li>';
    a[a.length] = "   </ul>";
    a[a.length] = '   <ul id="game_header_category">';
    this.category1();
    a[a.length] = "   </ul>";
    a[a.length] = '   <ul id="game_header_right">';
    a[a.length] = '     <li id="header_right_ad">';
    this.rBanner();
    a[a.length] = "     </li>";
    a[a.length] = '     <li id="daum_more">';
    a[a.length] = '       <span class="daum_more_btn" title="Daum 서비스 바로가기">Daum<img src="http://icon.daum-img.net/game/09game/img_gamemarrow.gif" width="13" height="12" alt=""/></span>';
    a[a.length] = '       <ul id="DaumUI__service_layer" style="display:none">';
    this.service();
    a[a.length] = "       </ul></li>";
    a[a.length] = "</ul></div>";
    a[a.length] = '<img id="callbaby" src="https://logins.daum.net/accounts/auth.gif" style="display:block" width="0" heigh="0" alt="" />';
    a[a.length] = "</div>";
    var b = this.str.join("");
    this.area.innerHTML = b
};
Draw.prototype.category1 = function() {
    var f = this.str;
    var b = 1;
    for (var d = 0; d < this.TYPE1; d++) {
        f[f.length] = '<li id="header_group' + b + '" class="group">';
        f[f.length] = '<h3 class="group_title"><a href="' + category_genre[d].categoryurl + '" ' + (category_genre[d].target ? 'target="' + category_genre[d].target + '"' : "") + ">" + this.cateData[d].title + "</a></h3>";
        if (this.cateData[d].game_list.length > 0) {
            f[f.length] = '<div id="header_group' + b + '_list" class="header_list">';
            f[f.length] = '<ul class="gh_list">';
            for (var c = 0, a = this.cateData[d].game_list.length; c < a; c++) {
                if (c < 2) {
                    f[f.length] = '<li class="gh_list_first"><a href="' + this.cateData[d].game_list[c].game_link + '">' + this.cateData[d].game_list[c].game_title + "</a></li>"
                } else {
                    f[f.length] = '<li class="gh_list_sub"><a href="' + this.cateData[d].game_list[c].game_link + '">' + this.cateData[d].game_list[c].game_title + "</a></li>"
                }
            }
            if (d == 1) {
                f[f.length] = '<li class="gh_list_sum"><a href="http://game.daum.net/channel/channel.do?id=121">EA SPORTS™ FIFA ONLINE2</a></li>'
            }
            f[f.length] = "</ul>";
            f[f.length] = '<a href="' + this.cateData[d].banner_link + '"><img src="' + this.cateData[d].banner + '" width="196" height="40" alt="' + this.cateData[d].banner_title + '" /><br /></a>';
            f[f.length] = "</div>"
        }
        f[f.length] = "</li>";
        b++
    }
};
Draw.prototype.service = function() {
    var b = this.str;
    for (var a = 0; a < this.SERVICE; a++) {
        b[b.length] = '<li><a href="' + this.daumLink[0].link_list[a].link + '">' + this.daumLink[0].link_list[a].title + "</a></li>"
    }
};
Draw.prototype.rBanner = function() {
    var a = this.str;
    a[a.length] = '<a href="' + this.bnrData[0].link + '"><img src="' + this.bnrData[0].banner + '" width="129" height="28" alt="' + this.bnrData[0].title + '" /></a>'
};
Draw.prototype.addHref = function(a) {
    var b = this.str;
    var a = a;
    if (a == 7) {
        b[b.length] = '<a href="http://gamepack.game.daum.net/">'
    } else {
        if (a == 8) {
            b[b.length] = '<a href="http://game.daum.net/flash/index.do">'
        } else {
            b[b.length] = '<a href="">'
        }
    }
};
Draw.prototype.appendMiniArea = function() {
    var d = "DaumUI__minidaum_wrap_G";
    var b = document.createElement("li");
    var c = DUI.$("DaumUI__minidaum");
    b.id = d;
    DUI.$("game_header_right").appendChild(b);
    DUI.$("DaumUI__minidaum_wrap_G").appendChild(c);
    c.style.display = "inline";
    var a = document.getElementById("DaumUI__minidaum_etc");
    if (a) {
        a.style.display = "none"
    }
};
Draw.prototype.appendScript = function() {
    var b = "MINIDAUMSCRIPT";
    var a = document.createElement("script");
    a.type = "text/javascript";
    a.src = "http://go.daum.net/minidaum/minidaum.jsa?uimode=off";
    a.charset = "utf-8";
    a.id = b;
    document.getElementsByTagName("body")[0].appendChild(a)
};
Draw.prototype.initialize = function() {
    this.layout();
    this.appendMiniArea()
};

function header_load() {
    appendCss();
    var a = new Draw();
    a.initialize();
    var b = new Header();
    b.initialize("DIV");
    addEvent(DUI.$("daum_more"), "click", display_daumLayer)
}
var ck_num = 0;

function callMom() {
    if (chkDomainPmang()) {
        window.setTimeout("window.location.reload()", 1000 * 60 * 30)
    } else {
        window.setInterval("callPapa()", 1000 * 60 * 20)
    }
}

function callPapa() {
    ck_num = ck_num + 1;
    DUI.$("callbaby").src = "https://logins.daum.net/accounts/auth.gif?ckvalue=" + ck_num
}

function chkDomainPmang() {
    var a = this.location.href;
    if (a.indexOf("pmang.game.daum.net") > 1) {
        return true
    } else {
        return false
    }
}

function initLegacyGGB() {
    document.write('<script type="text/javascript" src="http://game.daum.net/gamebar/gamebar.js" charset="utf-8"><\/script>');
    addEvent(window, "load", function() {
        callMom();
        if (window.__MiniDaumObj && window.__MiniDaumObj.func && window.__MiniDaumObj.func.nilLog) {
            window.__MiniDaumObj.func.nilLog = function() {
                var b = (self.opts != null && self.opts.isLoggedOn) || false;
                if (b == true && callbackLogout != null && typeof callbackLogout == "function") {
                    callbackLogout()
                }
                if (self.opts != null && !self.opts.isHttps) {
                    document.getElementById("nilFrame").src = "http://www.daum.net/doc/loginoutClick.html?nil_profile=" + (b ? "logout" : "login") + "&nil_src=" + self.func.getService() + "&dummy=" + new Date().getTime()
                }
            }
        }
        var a = document.getElementById("DaumUI__minidaum_etc");
        if (a) {
            a.style.display = "none"
        }
    })
}

function _daumInitGGB(p) {
    var h = null;
    var n = "http://game.daum.net/channel/proxy.daum";
    var k = 1000 * 60 * 20;
    var g = 1000 * 60 * 30;

    function l(t, q, r) {
        var s = document.createElement("IFRAME");
        addEvent(s, "load", r);
        s.style.display = "none";
        s.src = t;
        q.appendChild(s);
        return s
    }

    function o(r) {
        var s = 0;
        var q = document.createElement("img");
        q.style.display = "block";
        q.src = "https://logins.daum.net/accounts/auth.gif";
        q.style.width = "0px";
        q.style.height = "0px";
        r.appendChild(q);
        window.setInterval(function() {
            q.src = "https://logins.daum.net/accounts/auth.gif?ckvalue=" + (++s)
        }, k)
    }

    function j() {
        return (location.href.indexOf("pmang.game.daum.net") !== -1)
    }

    function f(q) {
        if (j()) {
            window.setTimeout(function() {
                window.location.reload()
            }, g)
        } else {
            o(q)
        }
    }

    function b(q) {
        if (q) {
            q.style.display = "none"
        }
    }

    function a(v, q, r) {
        var t, u;
        t = document.createElement("script");
        t.type = "text/javascript";
        for (u in r) {
            if (r.hasOwnProperty(u)) {
                t.setAttribute(u, r[u])
            }
        }
        t.src = v;
        document.getElementsByTagName("head")[0].appendChild(t);
        if (!q) {
            return false
        }
        t.onreadystatechange = function() {
            if (this.readyState == "loaded" || this.readyState == "complete") {
                q()
            }
            return
        };
        t.onload = function() {
            q();
            return
        };
        return true
    }

    function c() {
        a("http://s1.daumcdn.net/tiara/tracker/tiara.min.js", function() {
            window.__pageTracker = {};
            if (typeof __Tiara !== "undefined" && typeof __Tiara.__getTracker !== "undefined") {
                __pageTracker = __Tiara.__getTracker()
            } else {
                __pageTracker.__trackPageview = function() {}
            }
            window.setTimeout(function() {
                try {
                    window.__pageTracker.__trackPageview()
                } catch (q) {}
            }, 1)
        }, {
            charset: "utf-8"
        })
    }

    function m() {
        return (new Date()).getTime()
    }
    p.login = function(q) {
        q = "http://game.daum.net/bridge/?url=" + ((!!q) ? q : location.href);
        top.location.href = "http://login.daum.net/accounts/loginform.do?url=" + encodeURIComponent(q)
    };
    p.logout = function(q) {
        q = "http://game.daum.net/bridge/?url=" + ((!!q) ? q : location.href);
        top.location.href = "https://logins.daum.net/accounts/logout.do?url=" + encodeURIComponent(q)
    };
    p.chargeCash = function() {
        h.src = n + "#chargecash&dummy=" + m()
    };

    function d() {
        p.login = function(q) {
            var r = n + "#login";
            if (q) {
                r += "/&&/" + encodeURIComponent(q)
            }
            h.src = r + "&dummy=" + m()
        };
        p.logout = function(q) {
            var r = n + "#logout";
            if (q) {
                r += "/&&/" + encodeURIComponent(q)
            }
            h.src = r + "&dummy=" + m()
        }
    }
    addEvent(window, "load", function() {
        var q = document.body;
        h = l(n, q, d);
        c();
        f(q)
    })
}
if (window == top) {
    var locHref = location.href;
    var lph = document.getElementById("DAUM_GAME_HEADER_AREA");
    if (!!lph) {
        initLegacyGGB()
    } else {
        var scriptTag = document.getElementsByTagName("script");
        var isMobile = false;
        for (var i = 0; i <= scriptTag.length; i++) {
            try {
                if (scriptTag[i].src.indexOf("header.js") > -1 && scriptTag[i].getAttribute("daumGGB") == "mobile") {
                    isMobile = true
                }
            } catch (e) {
                continue
            }
        }
        var host = location.host;
        if (host == "web.game.daum.net" || host == "game.daum.net" || host == "legacy.game.daum.net") {} else {
            if (isMobile == true) {
                var replaceUrl = "http://game.daum.net/bridge/?daumMobile=true&url=" + encodeURIComponent(locHref)
            } else {
                var replaceUrl = "http://game.daum.net/bridge/?url=" + encodeURIComponent(locHref)
            }
            location.href = replaceUrl
        }
    }
} else {
    var daumgame;
    if (typeof daumgame == "undefined") {
        daumgame = {}
    }
    _daumInitGGB(daumgame)
};