!function(){function updateByLang(){var e=editor.get();if(e){"en-US"==lang?c2e(e):e2c(e);editor.set(e)}}function getPath(){var e=input.value;if(!e){alert("please input json file path");return null}if(!/.js$/.test(e)){e=e.replace(/\/$/,"")+"/JSON.js";input.value=e}match=/^(dev\/)?(.+)/.exec(e);return e}function open(){var path=getPath();if(match[1]){var ret=qyremote.downloadFile("dev",match[2]);if(!ret.success){alert("download file failed");return}code=ret.result}else code=qyboot.getRemoteFile(path);eval(code);"en-US"!=lang&&e2c(json);editor.set(json)}function save(){getPath();if(match){var e=editor.get();if(e){"en-US"!=lang&&c2e(e);var t="window.json="+JSON.stringify(e)+";",n=match[1]||(/^debug\//.test(match[2])?"debug":"deployed");qyremote.uploadFile(n,match[2],t)}else alert("please open file first")}else alert("please input json file path")}function rewriteUrl(e,t){if(e instanceof Array){goog.array.forEach(e,function(e){rewriteUrl(e)});return e}if("object"!=typeof e)return e;for(var n in e)"fill"==n?e[n]=t+e[n]:"urls"==n?e[n]=goog.array.map(e[n],function(e){return t+e}):rewriteUrl(e[n],t)}function run(){gamerunner.style.visibility="visible";if(window.json){delete game.start_scene;var e=goog.cloneObject(editor.get());"en-US"!=lang&&c2e(e);rewriteUrl(e,"/"+qyboot.dirname(match[2])+"/");window.toRun=e;engine.start(e,gamerunner)}else alert("please open json file first")}function transform(e,t){if("object"!=typeof e)return e;if(e instanceof Array)return goog.array.map(e,function(e){return transform(e,t)});for(var n in e){var r=t[n];if(r){e[r]=transform(e[n],t);delete e[n]}else e[n]=transform(e[n],t)}return e}function e2c(e){return transform(e,e2cWords)}function c2e(e){return transform(e,c2eWords)}var container=document.getElementById("jsoneditor"),editor=window.editor=new jsoneditor.JSONEditor(container),input=document.getElementById("Input"),gamerunner=window.gamerunner=document.getElementById("gamerunner"),select=document.getElementById("select_lang"),lang=qyboot.getCurrentLocaleName(),match,code;select.value=lang;select.onchange=function(){lang=select.value;qyboot.switchLocale(lang);updateByLang()};document.getElementById("Input").onkeydown=function(e){13==e.keyCode&&open()};document.getElementById("Open").onclick=open;document.getElementById("Run").onclick=run;document.getElementById("Save").onclick=save;var e2cWords=window.e2cWords={sprites:"图片列表",backgrounds:"背景列表",objects:"对象列表",sounds:"声音列表",timelines:"时间轴列表",scripts:"脚本列表",scenes:"场景列表",global:"全局",paths:"路径列表",displayFPS:"显示帧速",renderer:"渲染器",gravity:"重力",start_scene:"开始场景",debugDraw:"绘制碰撞图",size:"大小",width:"宽度",height:"高度",position:"位置",anchorPoint:"锚点",fill:"填充",opacity:"不透明度",method:"方法",background:"背景",layers:"层列表",defaultLayer:"缺省使用的层",points:"点列表",polygon:"多边形",id:"唯一标识符",events:"事件列表",actions:"动作列表"},c2eWords=window.c2eWords={};for(var w in e2cWords)c2eWords[e2cWords[w]]=w;window.e2c=e2c;window.c2e=c2e}();