Skip to content

Instantly share code, notes, and snippets.

@JohnBaek
Created June 30, 2016 05:40
Show Gist options
  • Save JohnBaek/f13d1d63e30692ce101e99c962c2b277 to your computer and use it in GitHub Desktop.
Save JohnBaek/f13d1d63e30692ce101e99c962c2b277 to your computer and use it in GitHub Desktop.
JS_HanbitOn_Mobile_Header.js
function HanbitOnMobileHeader() {
this._game = decodeURI(this.getQueryString("Game"));
this._titleUrl = decodeURI(this.getQueryString("Turl"));
};
HanbitOnMobileHeader.prototype.init = function()
{
this.createDiv("mHead", "mHead", this.getHeaderTable());
};
HanbitOnMobileHeader.prototype.getQueryString = function(name) {
var url = document.getElementById("hanbitOnMobielHeaderScript").src;
var retUrl = function(index)
{
var ret = url.substr(index + name.length + 2).indexOf("&");
if (ret == -1)
return url.substr(index + name.length + 2);
return url.substr(index + name.length + 2, ret);
};
if (url.indexOf("?" + name + "=") == -1)
return (url.indexOf("&" + name + "=") == -1) ? "" : retUrl(url.indexOf("&" + name + "="));
return retUrl(url.indexOf("?" + name + "="));
};
HanbitOnMobileHeader.prototype.createDiv= function(id, style, innertag) {
var divObj = this.createTag("div",id, style);
divObj.innerHTML = innertag;
document.getElementById('wrap').insertBefore(divObj, document.getElementById('wrap').firstChild);
};
HanbitOnMobileHeader.prototype.createTag = function(tag, id, classname) {
var ret = document.createElement(tag);
ret.setAttribute("id", id);
ret.setAttribute("name", id);
ret.className= classname;
return ret;
};
HanbitOnMobileHeader.prototype.getHeaderTable= function() {
var ret = "";
ret +="<h1><a href=\"http://m.hanbiton.com\"><img src=\"http://m.hanbiton.com/images/common/hanbiton.png\" alt=\"한빛온\" /></a></h1>";
ret +="<p><a href=\"#\" onclick=\"HanbitOnMobileHeaderHandler.SetLayerDisplay('gameList'); return false;\">전체게임<img src=\"http://m.hanbiton.com/images/common/ico_bottom.gif\" alt=\"▼\" /></a></p>";
ret +="<div class=\"gameList\" style=\"display:none;\" id=\"gameList\">";
ret +=" <ul>";
ret +=" <li><a href=\"http://m.fcm.hanbiton.com\">FC매니저</a></li>";
ret +=" <li><a href=\"http://m.hanbiton.com/GameInfo/audition.html\">오디션</a></li>";
// ret +=" <li><a href=\"http://m.hanbiton.com/GameInfo/hg.html\">헬게이트-도쿄</a></li>";
ret +=" <li><a href=\"http://m.aika.hanbiton.com\">에이카</a></li>";
ret +=" <li><a href=\"http://m.hanbiton.com/home/sitemap.aspx\">전체게임</a></li>";
ret +=" </ul>";
ret +="</div>";
var url = 'http://' + document.domain;
if(this._titleUrl) {
ret +="<h2><a href='" + String(this._titleUrl) + "'>"+this._game+"</a></h2><!-- 게임타이틀 -->";
} else {
ret +="<h2><a href='/'>"+this._game+"</a></h2><!-- 게임타이틀 -->";
}
return ret;
};
HanbitOnMobileHeader.prototype.SetLayerDisplay= function(id) {
var el = document.getElementById(id);
if(el.style.display=='none') { el.style.display='block'; overlay(id,'block'); } else { el.style.display='none'; overlay(id,'none'); }
return false;
};
if(typeof(HanbitOnMobileHeaderHandler) =='undefined')
{
HanbitOnMobileHeaderHandler = new HanbitOnMobileHeader();
HanbitOnMobileHeaderHandler.init();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment