!function(){function e(e,t){var r=t.length,i="",s=e.match(/\d+/);if(!s)return e;for(var n,l=0;s.length;){n=e.indexOf(s[0]);i+=e.slice(0,n);i+=t.slice(0,r-s[0].length)+s[0];l=n+s[0].length;e=e.substr(l);s=e.match(/\d+/);if(!s||!s.length)break}return i}$.utils||($.utils={});$.utils.supportedProjType=["gamemei","pigVsWolf","heyinliao","jump","queqiaohui","loveJourney","hoohoo","larva","chowhound","kissMe","daoxiong","menglv","flappybird"];$.utils.filemgmtDialog=function(){$.currentProj?$.utils.checkProjExisted($.currentProj)?$.utils.openDialog({className:"filemgmt-dialog",title:i18n("filemgmt"),method:"filemgmtDialog"}):$.utils.alert(i18n("proj_not_existed")):$.utils.alert(i18n("select_proj_first"))};$.utils.selectImage=function(e){var t=$(".select-image-dialog");t.length||(t=$("<div class = 'select-image-dialog'></div>").selectImageDialog());t.selectImageDialog("option",e).selectImageDialog("refresh").dialog("open");return t};$.utils.sortFiles=function(t){var r=0;t.forEach(function(e){r=Math.max(e.length,r)});for(var i="";i.length<r;)i+="0";t.sort(function(t,r){var s=e(t,i),n=e(r,i);return s>n?1:-1});return t};$.utils.getUserProjJs=function(){var e=$.user.userid,t=qyremote.downloadFile("dev",e+"/projs.js");if(t&&t.success)return JSON.parse(t.result);$.utils.alert(i18n(t.result));return{projs:{},slns:{}}};$.utils.startNewProject=function(e,t,r){if(e&&$.utils.validName(e)){t||(t="gamemei");var i=$.utils.getUserProjJs(),s=i.projs;if(s[e]&&!r){$.utils.alert(i18n("existed"));return!1}var n=qyremote.createProj(t,$.user.userid+"/"+e);if(n.success||"exist"===n.result){try{qyremote_async.initVersionControl($.user.userid+"/"+e,$.noop)}catch(l){}if(s&&!s[e]){i.projs[e]={type:"gamemei",sln:void 0};var n=qyremote_async.uploadFile("dev",$.user.userid+"/projs.js",JSON.stringify(i),function(e){e&&e.success||$.utils.alert(i18n(e.result))});return!0}}return!1}};$.utils.checkProjExisted=function(e){var t,r=e.split("/"),i=$.user.userid;if(2===r.length){e=r[1];t=qyremote.expandFolder("dev",i+"/"+r[0])}else t=qyremote.expandFolder("dev",i);if(t&&t.success){t=t.result;if(t.folders&&t.folders.indexOf(e)>-1)return!0}return!1};$.utils.expandFolder=function(e){var t;try{t=qyremote.expandFolder("dev",e);if(t&&t.success)return t.result}catch(r){}if(t)try{if($.utils.makeFolder("dev",e))return{files:[],folders:[]}}catch(r){}return null};$.utils.deleteSysFile=function(e,t,r){if(!(r instanceof Function))return qyremote.remove(e,t);qyremote_async.remove(e,t,r);return void 0};$.utils.renameSysFile=function(e,t,r){var i=qyremote.rename(e,t,r);return i};$.utils.makeFolder=function(e,t){var r=qyremote.makeFolder(e,t);if(r&&r.success)return!0;$.utils.alert(r.result);return!1};$.utils.copyFile=function(e,t,r){if(!e||!t){$.utils.alert(can_not_find(i18n("file")));return!1}var i=qyremote.copyFile("dev",e,"dev",t);if(i&&i.success)return!0;r||(r=failed(i18n("copy"))+": ");$.utils.alert(r+i18n(i.result));return!1};$.utils.copyFile_async=function(e,t,r,i){if(!e||!t){$.utils.alert(can_not_find(i18n("file")));return!1}qyremote_async.copyFile("dev",e,"dev",t,function(e){if(e&&e.success)i&&i(!0);else{i&&i(!1);r||(r=failed(i18n("copy"))+": ");$.utils.alert(r+i18n(e.result))}})};$.utils.cutFile=function(e,t){var r=failed(i18n("cut"))+": ",i=$.utils.copyFile(e,t,r);if(i){i=qyremote.remove("dev",e);if(i&&i.success)return!0;$.utils.alert(r+i18n(i.result));return!1}return i};$.utils.cutFile_async=function(e,t,r){var i=failed(i18n("cut"))+": ";$.utils.copyFile_async(e,t,i,function(t){t?qyremote_async.remove("dev",e,function(e){e&&e.success?r&&r(!0):$.utils.alert(i+i18n(e.result))}):r&&r(!1)})};$.utils.deployCurrentProj=function(e){if(!e)return qyremote.deployProj(projPath());qyremote_async.deployProj(projPath(),e);return void 0}}();