(function(){ var orientationSet = false; var info = null; var ortDiv = null; var normalDiv = null; // var mobileType = 0; FZ.GameBase.MOBILE_IPAD = 10; FZ.GameBase.MOBILE_IPHONE = 20; FZ.GameBase.Width = 700; FZ.GameBase.Height = 500; FZ.GameBase.Name = "DreamFarmLinkHtml5"; FZ.TARGET_DEF = {}; FZ.TARGET_DEF.PC = "pc"; FZ.TARGET_DEF.MOBILE = "mobile"; FZ.TARGET_DEF.IPHONE = "iPhone"; FZ.TARGET_DEF.IPAD = "iPad"; FZ.TARGET_DEF.ANDRIOD = "Android"; FZ.TargetPort = FZ.TARGET_DEF.PC;// pc, mobile FZ.TargetMobile = FZ.TARGET_DEF.IPHONE; FZ.EVENT_DEF = {}; FZ.EVENT_DEF.M_OVER = "mouseover"; FZ.EVENT_DEF.M_OUT = "mouseout"; FZ.EVENT_DEF.M_MOVE = "mousemove"; FZ.EVENT_DEF.M_CLICK = "click"; FZ.EVENT_DEF.T_START = "touchstart"; FZ.EVENT_DEF.T_MOVE = "touchmove"; FZ.EVENT_DEF.T_END = "touchend"; FZ.GameBase.setCss = function(div, info){ div.style.width = info.w + "px"; div.style.height = info.h + "px"; div.style.left = info.x + "px"; div.style.top = info.y + "px"; div.style.position = "absolute"; div.style.backgroundRepeat = "no-repeat"; div.style.backgroundImage = "url(imgs/" + info.fileURL + ")"; }; FZ.PrintLog = function(str){ // var hintDiv = document.getElementById("strHint"); // hintDiv.value = str; }; var createOrientationDiv = function(){ var img = null; if (orientationSet) { return true; } img = FZ.ResourceManager.ResourceLib["OrientationWarning"]; if (!img) { //image not load return false; } info = FZ.getImgInfo("OrientationWarning"); ortDiv.style.backgroundRepeat = "no-repeat"; ortDiv.style.backgroundImage = "url(imgs/" + info.fileURL + ")"; ortDiv.style.backgroundPositionX = "50%"; ortDiv.style.backgroundPositionY = "50%"; ortDiv.style.backgroundColor = "#fff"; orientationSet = true; return true; }; var windowOrientationChangeFunction = function(){ if ((90 === window.orientation) || (-90 === window.orientation)) { // FZ.DivManager.setOverflow("visible"); // FZ.DivManager.addChild(orientationDiv); normalDiv.style.display = "none"; ortDiv.style.display = "inline"; FZ.Game.GameState.pageHide(); } else if (0 === window.orientation) { normalDiv.style.display = "inline"; ortDiv.style.display = "none"; FZ.Game.GameState.pageShow(); } var offsetx = 0; var offsety = 0; if (FZ.TARGET_DEF.ANDRIOD === FZ.TargetMobile) { offsety = 1; } setTimeout(function(){ // window.scrollTo(offsetx, offsety); }, 10); // setTimeout(function () { // window.scrollTo(0,0); // }, 10); // alert(window.orientation); }; var windowonscroll = function(){ /*var offsetx = 0; var offsety = 0; if (FZ.TARGET_DEF.ANDRIOD === FZ.TargetMobile) { offsety = 1; } setTimeout(function(){ window.scrollTo(offsetx, offsety); }, 1000);*/ }; var windowtouchStart = function(evt){ evt.stopPropagation(); //evt.preventDefault(); return false; }; var windowInit = function(){ // updateShare(0,0); var metas = null; var heads = null; FZ.GameBase.loadGame(); //FZ.GameBase.SaveObject.m_cur_level = 9; if (undefined === FZ.GameBase.SaveObject.m_cur_level) { //create the default game record. FZ.GameBase.SaveObject.m_cur_level = 0; FZ.GameBase.SaveObject.pass = false; FZ.GameBase.SaveObject.score = 0; FZ.GameBase.SaveObject.m_hint = FZ.GameDefs.LEVEL_HINT_NUMBER[1]; // FZ.GameBase.SaveObject.m_gamein = false; FZ.GameBase.SaveObject.m_cur_score = 0; // FZ.GameBase.SaveObject.m_level_high_score = 0; FZ.GameBase.SaveObject.m_cur_hintCount = FZ.GameDefs.LEVEL_HINT_NUMBER[1]; FZ.GameBase.SaveObject.m_cur_left_pet = FZ.GameDefs.ALL_PET_NUM; FZ.GameBase.SaveObject.m_level_usedTime = 0; FZ.GameBase.SaveObject.m_usedTime = 0; if (FZ.TargetMobile !== FZ.TARGET_DEF.ANDRIOD) { FZ.GameBase.SaveObject.m_sound = true; } var index = 0; var tmp = null; var tmpPetArr = null; tmpPetArr = []; for (index = 0; index < FZ.GameDefs.ALL_GENERAL; index++) { tmp = {}; // tmp.line = 0; // tmp.col = 0; tmp.style = -1; tmp.state = FZ.GameDefs.DREAMPET_INIT; tmpPetArr.push(tmp); } FZ.GameBase.SaveObject.m_data = tmpPetArr; FZ.GameBase.saveGame(); } normalDiv = FZ.$("mainDiv"); ortDiv = FZ.$("orientationDiv"); FZ.GameBase.animDiv = FZ.$("animDiv"); // FZ.GameBase.animDiv.style.overflow = "visible"; ortDiv.style.display = "none"; if (/(iPhone|iPad|iPod|Android)/i.test(window.navigator.appVersion)) { FZ.TargetPort = FZ.TARGET_DEF.MOBILE; FZ.TargetMobile = FZ.TARGET_DEF.IPHONE; if (-1 !== navigator.userAgent.indexOf("iPad")) { FZ.TargetMobile = FZ.TARGET_DEF.IPAD; } else if (-1 !== navigator.userAgent.indexOf("Android")) { FZ.TargetMobile = FZ.TARGET_DEF.ANDRIOD; } } metas = document.createElement("meta"); heads = document.getElementsByTagName("head"); if (FZ.TARGET_DEF.IPAD === FZ.TargetMobile) { // mobileType = FZ.GameBase.MOBILE_IPAD; metas.setAttribute("name", "viewport"); metas.setAttribute("content", "width=device-width, initial-scale=2.0, maximum-scale=2.0,user-scalable=no"); heads[0].appendChild(metas); // var Metas = document.getElementsByTagName("meta"); // for (var i=0;i