var mapp_o={}; mapp_o.r_session=""; mapp_o.TEST_REAL="real"; mapp_o.iframe=null; mapp_o.userAgent=window.navigator.userAgent.toLowerCase(); mapp_o.isAndroid=/\bandroid\b/.test(mapp_o.userAgent); mapp_o.isIphone=/like mac os x/.test(mapp_o.userAgent) && /\biphone\b/.test(mapp_o.userAgent); mapp_o.isIpad=/like mac os x/.test(mapp_o.userAgent) && /\bipad\b/.test(mapp_o.userAgent); mapp_o.isIOS=mapp_o.isIphone || mapp_o.isIpad; mapp_o.viewBySeq=function(obj, win_attr){ if(mapp_o.r_session!="dmookviewer" || (!mapp_o.isAndroid && !mapp_o.isIOS)){ var url=""; for(var key in obj){ url=url+"&"+key+"="+encodeURIComponent(obj[key]); } if(url) url=url.substring(1); mapp_o.opwin("/gallery/view.asp?"+url, win_attr); return; } var seq=(obj.seq)?obj.seq:-1; var path=(obj.path)?obj.path:""; var prodseq=(obj.prodseq)?obj.prodseq:0; var dom=mapp_o.loadXml("/smart/dbookinfo.asp?seq="+seq+"&path="+path+"&prodseq="+prodseq); var doc=dom.documentElement; var errcode=doc.getAttribute("errcode"); if(errcode!="0"){ alert("공개된 DBook이 아니거나 DBook정보를 찾을수 없습니다."); return; } doc.setAttribute("fid", "kr") doc.setAttribute("uid", "") doc.setAttribute("uno", "") doc.setAttribute("billing", "-1") doc.setAttribute("grade", "0") var xmlStr=""; if(doc.xml) xmlStr=doc.xml; else if(window.XMLSerializer){ var xmls=new XMLSerializer(); xmlStr=xmls.serializeToString(doc); } var customURI="com.kdmt.dmookviewer://http://www.albummania.co.kr/?xml="+encodeURIComponent(xmlStr) var callBackURL=""; if(window.opener){ try{ if(callBackURL=="") callBackURL=(window.opener.top.document)?window.opener.top.document.location.href:window.opener.document.location.href; }catch(e){} }else if(window.parent && window.parent!=window){ try{ if(callBackURL=="") callBackURL=(window.parent.top.document)?window.parent.top.document.location.href:window.parent.document.location.href; }catch(e){} }else if(document.referrer){ try{ if(callBackURL=="") callBackURL=document.referrer; }catch(e){} }else{ callBackURL=(window.top && window.top.document)?window.top.document.location.href:document.location.href; } callBackURL=callBackURL.replace(/:/g, "%3A").replace(/\//g, "%2F").replace(/\?/g, "%3F").replace(/\=/g, "%3D").replace(/\&/g, "%26"); if(mapp_o.isAndroid){ var timerID=-1; var iframe=document.createElement("iframe"); iframe.style.position="absolute"; iframe.style.left="-300px"; iframe.style.height="1px"; iframe.style.width="1px"; document.body.appendChild(iframe); iframe.onload=function(){ clearTimeout(timerID); document.body.removeChild(iframe); if(confirm("DBook Reader를 설치하시겠습니까?")){ var installURL="market://details?id=air.com.kdmt.dmookviewer7"; try{ if(window.opener){ try{ window.opener.top.location=installURL; window.opener.top.focus(); self.close(); }catch(ae){ window.opener.location=installURL; window.opener.focus(); self.close(); } }else if(window.parent){ try{ window.parent.top.location=installURL; window.parent.top.focus(); }catch(ae){ window.parent.location=installURL; window.parent.focus(); } }else{ window.location=installURL; } }catch(e){ window.location=installURL; } }else if(window.opener){ self.close(); } }; iframe.contentWindow.location=customURI+"&url="+callBackURL; if(window.opener){ timerID=setTimeout(function(){ window.close(); }, 1000); }else{ timerID=setTimeout(function(){ if(callBackURL.indexOf("http%3A%2F%2Fm.facebook.com")==0){ document.location.history.go(-1); window.close(); }else document.location.history.back(); }, 1000); } }else if(mapp_o.isIOS){ var iOSTimeOut; if(mapp_o.isIphone){ iOSTimeOut=10000; }else{ iOSTimeOut=1000; } window.onload=function(){ var start=new Date(); setTimeout(function(){ if(new Date()-start>iOSTimeout+1000){ return; } if(confirm("DBook Reader를 설치하시겠습니까?")){ var installURL="itms-apps://itunes.com/app/DBookReader"; try{ if(window.opener){ try{ window.opener.top.location=installURL; window.opener.top.focus(); self.close(); }catch(ae){ window.opener.location=installURL; window.opener.focus(); self.close(); } }else if(window.parent){ try{ window.parent.top.location=installURL; window.parent.top.focus(); }catch(ae){ window.parent.location=installURL; window.parent.focus(); } }else{ window.location=installURL; } }catch(e){ window.location=installURL; } }else if(window.opener){ window.close(); } }, iOSTimeOut); window.location=customURI+"&url="+callBackURL; if(window.opener){ timerID=setTimeout(function(){ window.close(); }, 1000); }else{ timerID=setTimeout(function(){ if(callBackURL.indexOf("http%3A%2F%2Fm.facebook.com")==0){ document.location.history.go(-3); }else document.location.history.back(); }, 1000); } } } }; mapp_o.viewBySeqNew=function(seq, path){ if(mapp_o.r_session!="dmookviewer" || (!mapp_o.isAndroid && !mapp_o.isIOS)){ mapp_o.opwin("/gallery/view.asp?seq="+seq+"&path="+path, ""); return; } }; mapp_o.view=function(win_url, win_attr){ if(mapp_o.r_session!="dmookviewer" || (!mapp_o.isAndroid && !mapp_o.isIOS)){ mapp_o.opwin(win_url, win_attr); return; } if(mapp_o.iframe){ try{ document.body.removeChild(mapp_o.iframe); }catch(e){} } var iframe=document.createElement("iframe"); iframe.style.position="absolute"; iframe.style.left="0px"; iframe.style.top="0px"; iframe.style.height="1px"; iframe.style.width="1px"; document.body.appendChild(iframe); mapp_o.iframe=iframe; iframe.src=win_url; }; mapp_o.opwin=function(win_url, win_attr){ if(!win_attr){ var w=window.screen.availWidth; var h=window.screen.availHeight; win_attr="width="+w+",height="+h; } var bFull=false if(window.navigator.userAgent.indexOf("MSIE")>0){ var nS=window.navigator.userAgent.indexOf("MSIE")+5; var nE=window.navigator.userAgent.indexOf(";", nS); var ver=eval(window.navigator.userAgent.substring(nS,nE)); if(ver>=7.0) bFull=true; } var win; if(bFull) win=window.open(win_url, "", "scrollbars=yes, scrolling=yes, resizable=yes"); else win=window.open(win_url, "", win_attr+", left=0, top=0, scrollbars=yes, scrolling=yes, menubar=no, resizable=yes"); try{win.focus();}catch(e){} }; mapp_o.loadXml=function(path){ var dom; try{ if(window.XMLHttpRequest){ var xreq=new XMLHttpRequest(); xreq.open("GET", path, false); xreq.send(null); dom=xreq.responseXML; }else if(window.ActiveXObject){ dom=new ActiveXObject("Msxml2.DOMDocument.3.0"); dom.setProperty("SelectionLanguage", "XPath"); dom.async=false; dom.validateOnParse=false; dom.resolveExternals=false; dom.load(path); } }catch(e){} if(typeof(dom)=="undefined" && document.implementation && document.implementation.createDocument){ try{ dom=document.implementation.createDocument("", "", null); dom.async=false; dom.load(path); }catch(e){alert(e.message);} } return dom; };