wide/static/js/wide.min.js

13 lines
68 KiB
JavaScript

var Tabs=function(e){e._$tabsPanel=$(e.id+" > .tabs-panel"),e._$tabs=$(e.id+" > .tabs"),e._stack=[],this.obj=e,this.obj.STACKSIZE=64,this._init(e);var i=this;$(e.id+" > .tabs > div").each(function(){var t=$(this).data("index");e._stack.length===i.obj.STACKSIZE&&e._stack.splice(0,1),e._stack[e._stack.length-1]!==t&&i.obj._stack.push(t)})};$.extend(Tabs.prototype,{_init:function(r){var n=this;r._$tabs.on("click","div",function(t){if($(this).hasClass("current"))return!1;var e=$(this).data("index");n.setCurrent(e),"function"==typeof r.clickAfter&&r.clickAfter(e)}),r._$tabs.on("click",".ico-close",function(t){var e=$(this).parent().data("index"),i=!0;"function"==typeof r.removeBefore&&(i=r.removeBefore(e)),i&&n.del(e),t.stopPropagation()})},_hasId:function(t){return 0!==this.obj._$tabs.find('div[data-index="'+t+'"]').length},add:function(t){if(this.getCurrentId()===t.id)return!1;if(this._hasId(t.id))return this.setCurrent(t.id),!1;var e=this.obj._$tabsPanel;this.obj._$tabs.append('<div data-index="'+t.id+'">'+t.title+' <span class="ico-close font-ico"></span></div>'),e.append('<div data-index="'+t.id+'">'+t.content+"</div>"),this.setCurrent(t.id),"function"==typeof t.after&&t.after()},del:function(t){var e,i=this.obj._$tabsPanel,r=this.obj._$tabs,n=this.obj._stack;r.children("div[data-index='"+t+"']").remove(),i.children("div[data-index='"+t+"']").remove();for(var a=0;a<n.length;a++)t===n[a]&&(n.splice(a,1),a--);e=n[n.length-1],"function"==typeof this.obj.removeAfter&&this.obj.removeAfter(t,e),this.setCurrent(e)},getCurrentId:function(){return this.obj._$tabs.children(".current").data("index")},setCurrent:function(t){if(!t)return!1;var e=this.obj._$tabsPanel,i=this.obj._$tabs;if(i.children(".current").data("index")===t)return!1;var r=this.obj._stack;r.length===this.obj.STACKSIZE&&r.splice(0,1),r[r.length-1]!==t&&this.obj._stack.push(t),i.children("div").removeClass("current"),e.children("div").hide(),i.children('div[data-index="'+t+'"]').addClass("current"),e.children('div[data-index="'+t+'"]').show(),"function"==typeof this.obj.setAfter&&this.obj.setAfter();var n=this.getCurrentId();if("startPage"!==n){var a=tree.getTIdByPath(n),s=tree.fileTree.getNodeByTId(a);tree.fileTree.selectNode(s),wide.curNode=s;for(var d=0,o=editors.data.length;d<o;d++)if(editors.data[d].id===n){wide.curEditor=editors.data[d].editor;break}if(wide.curEditor){var c=wide.curEditor.getCursor();wide.curEditor.setCursor(c),wide.curEditor.focus(),wide.refreshOutline(),$(".footer .cursor").text("| "+(c.line+1)+":"+(c.ch+1)+" |")}}}});
!function(p){p.fn.extend({dialog:{version:"0.0.1.7",author:"v@b3log.org"}});var t=(new Date).getTime(),n="dialog",e=function(){this._defaults={styleClass:{background:"dialog-background",panel:"dialog-panel",main:"dialog-main",footer:"dialog-footer",headerMiddle:"dialog-header-middle",headerBg:"dialog-header-bg",closeIcon:"dialog-close-icon",closeIconHover:"dialog-close-icon-hover",title:"dialog-title"}}};p.extend(e.prototype,{_attach:function(t,e){t.id||(this.uuid++,t.id="dp"+this.uuid);var i=this._newInst(p(t));i.settings=p.extend({},e||{}),p.data(t,n,i),this._init(t)},_newInst:function(t){return{id:t[0].id.replace(/([^A-Za-z0-9_])/g,"\\\\$1")}},_getInst:function(t){try{return p.data(t,n)}catch(t){throw"Missing instance data for this dialog"}},_destroyDialog:function(t){var e=p.dialog._getInst(t),i=e.id;p.removeData(t,n),p(t).prependTo("#"+i+"Wrap").unwrap(),p(t).removeAttr("style");var o=this._getDefaults(p.dialog._defaults,e.settings,"styleClass");p("."+o.background).remove(),p("#"+i+"Dialog").remove()},_init:function(t){var e=this._getInst(t),i=e.id,o=e.settings,n=p(window).height(),a=p(window).width(),l=this._getDefaults(p.dialog._defaults,o,"styleClass"),s=o.height?o.height:parseInt(.6*n),d=o.width?o.width:parseInt(.6*a);o.title=o.title?o.title:"",o.okText=o.okText?o.okText:"Ok",o.cancelText=o.cancelText?o.cancelText:"Cancel";var r="",c="<div class='"+l.headerBg+"'><div class='"+l.title+"'>"+o.title+"</div><a href='javascript:void(0);' class='ico-close font-ico "+l.closeIcon+"'></a></div>";o.hideFooter||(o.hiddenOk||(r="<button>"+o.okText+"</button>"),r+="<button>"+o.cancelText+"</button>");var h="<div id='"+i+"Dialog' class='"+l.panel+"' style='width: "+d+"px;' onselectstart='return false;'>"+c+"<div class='"+l.main+"'><div style='overflow: auto; height: "+s+"px;'></div><div class='"+l.footer+"'>"+r+"</div></div>",g="";o.modal&&0===p("."+l.background).length&&(g="<div style='height:"+(n<document.documentElement.scrollHeight?document.documentElement.scrollHeight:n)+"px;' class='"+l.background+"'></div>");p("#"+i).wrap("<div id='"+i+"Wrap'></div>");var u=p(t).clone(!0);p(t).remove(),p("body").append(g+h),p(p("#"+i+"Dialog ."+l.main+" div").get(0)).append(u),p(u).show(),p("#"+i+"Dialog ."+l.closeIcon).bind("click",function(){p.dialog._close(i,o)});var f=p("#"+i+"Dialog ."+l.footer+" button");p(f.get(1)).bind("click",function(){p.dialog._close(i,o)}),p(f.get(0)).bind("click",function(){(void 0===o.ok||o.ok())&&p.dialog._close(i,o)}),this._bindMove(i,l.headerBg,s,d),p(window).keyup(function(t){27===t.keyCode&&p.dialog._close(i,o)}),p(window).resize(function(){var t=p("body").height()>p(window).height()?p("body").height():p(window).height();p(".dialog-background").height(t)}),"function"==typeof o.afterInit&&o.afterInit()},_bindMove:function(i,t){p("#"+i+"Dialog ."+t).mousedown(function(t){var e=document;t||(t=window.event);var o=document.getElementById(i+"Dialog"),n=t.clientX-parseInt(o.style.left),a=t.clientY-parseInt(o.style.top);e.ondragstart="return false;",e.onselectstart="return false;",e.onselect="document.selection.empty();",this.setCapture?this.setCapture():window.captureEvents&&window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP),e.onmousemove=function(t){t||(t=window.event);var e=t.clientX-n,i=t.clientY-a;e<0&&(e=0),e>p(window).width()-p(o).width()&&(e=p(window).width()-p(o).width()),i>p(window).height()-p(o).height()&&(i=p(window).height()-p(o).height()),i<0&&(i=0),o.style.left=e+"px",o.style.top=i+"px"},e.onmouseup=function(){this.releaseCapture?this.releaseCapture():window.captureEvents&&window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP),e.onmousemove=null,e.onmouseup=null,e.ondragstart=null,e.onselectstart=null,e.onselect=null}})},_close:function(t,e){if("none"!==p("#"+t+"Dialog").css("display")&&(void 0===e.close||e.close())&&(p("#"+t+"Dialog").hide(),e.modal)){var i=this._getDefaults(p.dialog._defaults,e,"styleClass");p("."+i.background).hide()}},_closeDialog:function(t){var e=this._getInst(t),i=e.id,o=e.settings;p.dialog._close(i,o)},_openDialog:function(t,e){var i=this._getInst(t),o=i.id,n=i.settings,a="",l="",s=p("#"+o+"Dialog"),d=p(window).height(),r=p(window).width(),c=n.height?n.height:parseInt(.6*d),h=n.width?n.width:parseInt(.6*r);if(l=n.position?(a=n.position.top,n.position.left):((a=parseInt((d-c-43)/2))<0&&(a=0),parseInt((r-h)/2)),s.css({top:a+"px",left:l+"px"}).show(),n.modal){var g=this._getDefaults(p.dialog._defaults,n,"styleClass");p("."+g.background).show()}"function"==typeof n.afterOpen&&n.afterOpen(e),p("#"+o+"Dialog .dialog-footer button:eq(0)").focus()},_updateDialog:function(t,e){var i=this._getInst(t),o=i.id,n=i.settings,a=this._getDefaults(p.dialog._defaults,n,"styleClass");p.extend(n,e);var l=p("#"+o+"Dialog");e.position&&l.css({top:e.position.top,left:e.position.left}),e.width&&(l.width(e.width+26),l.find("."+a.main+" div")[0].style.width=e.width+"px",l.find("."+a.headerBg).width(e.width+18)),e.height&&(l.find("."+a.main+" div")[0].style.height=e.height+"px"),e.title&&l.find("."+a.title).html(e.title),void 0!==e.modal&&(e.modal?p("."+a.background).show():p("."+a.background).hide()),void 0!==e.hideFooter&&(e.hideFooter?l.find("."+a.footer).hide():l.find("."+a.footer).show())},_getDefaults:function(t,e,i){if("styleClass"===i){if("default"===e.theme||void 0===e.theme)return t.styleClass;for(var o in e.styleClass={},t[i])e.styleClass[o]=e.theme+"-"+t.styleClass[o]}else{if("height"===i||"width"===i)return null===e[i]||void 0===e[i]?"auto":e[i]+"px";if(null===e[i]||void 0===e[i])return t[i]}return e[i]}}),p.fn.dialog=function(t){var e=Array.prototype.slice.call(arguments);return"string"==typeof t?(e.shift(),p.dialog["_"+t+"Dialog"].apply(p.dialog,[this[0]].concat(e))):this.each(function(){p.dialog._attach(this,t)})},p.dialog=new e,window["DP_jQuery_"+t]=p}(jQuery);
var editors={autocompleteMutex:!1,data:[],tabs:{},getEditorByPath:function(e){for(var t=0,o=editors.data.length;t<o;t++)if(editors.data[t].editor.options.path===e)return editors.data[t].editor},close:function(){$('.edit-panel .tabs > div[data-index="'+$(".edit-panel .frame").data("index")+"]").find(".ico-close").click()},closeOther:function(){var t=$(".edit-panel .frame").data("index"),o=[];if($(".edit-panel .tabs > div").each(function(e){t!==$(this).data("index")&&o.push($(this).data("index"))}),0===o.length)return!1;var e=o.splice(0,1);$("#dialogCloseEditor").data("removeData",o),$('.edit-panel .tabs > div[data-index="'+e+'"]').find(".ico-close").click()},_removeAllMarker:function(){var e=$("#dialogCloseEditor").data("removeData");if(e&&0<e.length){var t=e.splice(0,1);$("#dialogCloseEditor").data("removeData",e),$('.edit-panel .tabs > div[data-index="'+t+'"] .ico-close').click()}wide.curEditor&&wide.curEditor.focus()},_initClose:function(){new ZeroClipboard($("#copyFilePath")),$(".edit-panel").on("mouseup",".tabs > div",function(e){if(e.stopPropagation(),0===e.button)return $(".edit-panel .frame").hide(),!1;var t=e.screenX;return"auto"!==$(".side").css("left")&&"0px"!==$(".side").css("left")||(t=e.screenX-$(".side").width()),$(".edit-panel .frame").show().css({left:t+"px",top:"21px"}).data("index",$(this).data("index")),$("#copyFilePath").attr("data-clipboard-text",$(this).find("span:eq(0)").attr("title")),!1})},init:function(){$("#dialogCloseEditor").dialog({modal:!0,height:90,width:260,title:config.label.tip,hideFooter:!0,afterOpen:function(e){$("#dialogCloseEditor > div:eq(0)").html(config.label.file+" <b>"+e+"</b>. "+config.label.confirm_save+"?"),$("#dialogCloseEditor button:eq(0)").focus()},afterInit:function(){$("#dialogCloseEditor button.save").click(function(){var e=$("#dialogCloseEditor").data("index");wide.fmt(editors.data[e].id,editors.data[e].editor),editors.tabs.del(editors.data[e].id),$("#dialogCloseEditor").dialog("close"),editors._removeAllMarker()}),$("#dialogCloseEditor button.discard").click(function(){var e=$("#dialogCloseEditor").data("index");editors.tabs.del(editors.data[e].id),$("#dialogCloseEditor").dialog("close"),editors._removeAllMarker()}),$("#dialogCloseEditor button.cancel").click(function(e){$("#dialogCloseEditor").dialog("close"),editors._removeAllMarker()})}}),editors.tabs=new Tabs({id:".edit-panel",setAfter:function(){wide.curEditor&&wide.curEditor.focus()},clickAfter:function(e){if("startPage"===e)return wide.curEditor=void 0,$(".footer .cursor").text(""),wide.refreshOutline(),!1},removeBefore:function(e){if("startPage"===e)return editors._removeAllMarker(),!0;for(var t=0,o=editors.data.length;t<o;t++)if(editors.data[t].id===e)return editors.data[t].editor.doc.isClean()?(editors._removeAllMarker(),!0):($("#dialogCloseEditor").dialog("open",$('.edit-panel .tabs > div[data-index="'+editors.data[t].id+'"] > span:eq(0)').text()),$("#dialogCloseEditor").data("index",t),!1)},removeAfter:function(e,t){0===$(".edit-panel .tabs > div").length&&menu.disabled(["close-all"]);for(var o=0,i=editors.data.length;o<i;o++)if(editors.data[o].id===e){editors.data.splice(o,1);break}return 0===editors.data.length?(menu.disabled(["save-all","build","run","go-test","go-vet","go-mod","go-install","find","find-next","find-previous","replace","replace-all","format","autocomplete","jump-to-decl","expr-info","find-usages","toggle-comment","edit"]),tree.fileTree.cancelSelectedNode(),wide.curNode=void 0,wide.curEditor=void 0,wide.refreshOutline(),$(".footer .cursor").text(""),!1):t?t!==editors.tabs.getCurrentId()&&void 0:(tree.fileTree.cancelSelectedNode(),wide.curNode=void 0,wide.curEditor=void 0,wide.refreshOutline(),$(".footer .cursor").text(""),!1)}}),this._initCodeMirrorHotKeys(),this.openStartPage(),this._initClose()},openStartPage:function(){wide.curEditor=void 0,wide.refreshOutline(),$(".footer .cursor").text("");var s=function(e,t){var o=new Date(e),i={"M+":o.getMonth()+1,"d+":o.getDate(),"h+":o.getHours(),"m+":o.getMinutes(),"s+":o.getSeconds(),"q+":Math.floor((o.getMonth()+3)/3),S:o.getMilliseconds()};for(var r in/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(o.getFullYear()+"").substr(4-RegExp.$1.length))),i)new RegExp("("+r+")").test(t)&&(t=t.replace(RegExp.$1,1===RegExp.$1.length?i[r]:("00"+i[r]).substr((""+i[r]).length)));return t};editors.tabs.add({id:"startPage",title:'<span title="'+config.label.start_page+'"><span class="ico-start font-ico"></span> '+config.label.start_page+"</span>",content:'<div id="startPage"></div>',after:function(){$("#startPage").load("/start?sid="+config.wideSessionId),$.ajax({url:"https://hacpai.com/apis/articles?tags=wide,golang&p=1&size=20",type:"GET",dataType:"jsonp",jsonp:"callback",success:function(e,t){var o=e.articles;if(0!==o.length){var i=o.length;9<i&&(i=9);for(var r="<ul><li class='title'>"+config.label.community+"<a href='https://hacpai.com/article/1437497122181' target='_blank' class='fn-right'>边看边练</li>",a=0;a<i;a++){var n=o[a];r+="<li><a target='_blank' href='"+n.articlePermalink+"'>"+n.articleTitle+"</a>&nbsp; <span class='date'>"+s(n.articleCreateTime,"yyyy-MM-dd")}$("#startPage .news").html(r+"</ul>")}}})}})},getCurrentId:function(){var e=editors.tabs.getCurrentId();return"startPage"===e&&(e=null),e},getCurrentPath:function(){var e=$(".edit-panel .tabs .current span:eq(0)").attr("title");return e===config.label.start_page&&(e=null),e},_initCodeMirrorHotKeys:function(){CodeMirror.registerHelper("hint","go",function(a){for(var e=/[\w$]+/,t=(a=wide.curEditor).getCursor(),o=a.getLine(t.line),i=t.ch,r=i;r<o.length&&e.test(o.charAt(r));)++r;for(;i&&e.test(o.charAt(i-1));)--i;var n=newWideRequest();n.path=$(".edit-panel .tabs .current > span:eq(0)").attr("title"),n.code=a.getValue(),n.cursorLine=t.line,n.cursorCh=t.ch;var s=[];if(!editors.autocompleteMutex||!a.state.completionActive)return editors.autocompleteMutex=!0,$.ajax({async:!1,type:"POST",url:"/autocomplete",data:JSON.stringify(n),dataType:"json",success:function(e){var t=e[1];if(t)for(var o=0;o<t.length;o++){var i="",r=t[o].name;switch(t[o].class){case"type":i='<span class="fn-clear"><span class="ico-type ico"></span><b>'+t[o].name+"</b> "+t[o].type+"</span>";break;case"const":i='<span class="fn-clear"><span class="ico-const ico"></span><b>'+t[o].name+"</b> "+t[o].type+"</span>";break;case"var":i='<span class="fn-clear"><span class="ico-var ico"></span><b>'+t[o].name+"</b> "+t[o].type+"</span>";break;case"package":i='<span class="fn-clear"><span class="ico-package ico"></span><b>'+t[o].name+"</b> "+t[o].type+"</span>";break;case"func":i='<span><span class="ico-func ico"></span><b>'+t[o].name+"</b>"+t[o].type.substring(4)+"</span>",r+="()";break;default:console.warn("Can't handle autocomplete ["+t[o].class+"]")}s[o]={displayText:i,text:r}}a.doc.markClean(),$(".edit-panel .tabs .current > span:eq(0)").removeClass("changed")}}),setTimeout(function(){editors.autocompleteMutex=!1},20),{list:s,from:CodeMirror.Pos(t.line,i),to:CodeMirror.Pos(t.line,r)}}),CodeMirror.commands.autocompleteAfterDot=function(e){var t=e.getMode();if(t&&"go"!==t.name)return CodeMirror.Pass;var o=e.getTokenAt(e.getCursor());return"comment"===o.type||"string"===o.type||setTimeout(function(){e.state.completionActive||e.showHint({hint:CodeMirror.hint.go,completeSingle:!1})},50),CodeMirror.Pass},CodeMirror.commands.autocompleteAnyWord=function(e){e.showHint({hint:CodeMirror.hint.auto})},CodeMirror.commands.gotoLine=function(e){$("#dialogGoLinePrompt").dialog("open")},CodeMirror.commands.doNothing=function(e){},CodeMirror.commands.exprInfo=function(e){var t=wide.curEditor.getCursor(),o=newWideRequest();o.path=$(".edit-panel .tabs .current > span:eq(0)").attr("title"),o.code=wide.curEditor.getValue(),o.cursorLine=t.line,o.cursorCh=t.ch,$.ajax({type:"POST",url:"/exprinfo",data:JSON.stringify(o),dataType:"json",success:function(e){if(e.succ){var t=wide.curEditor.cursorCoords();$("body").append('<div style="top:'+(t.top+15)+"px;left:"+t.left+'px" class="edit-exprinfo">'+e.data+"</div>")}}})},CodeMirror.commands.copyLinesDown=function(e){var t="",o=e.listSelections()[0],i=o.anchor,r=o.head;i.line>r.line&&(i=o.head,r=o.anchor);for(var a=i.line,n=r.line;a<=n;a++)0===r.ch&&a===n||(t+="\n"+e.getLine(a));var s=r.line;0===r.ch&&(s=r.line-1),e.replaceRange(t,CodeMirror.Pos(s));var d=s-i.line+1;e.setSelection(CodeMirror.Pos(i.line+d,i.ch),CodeMirror.Pos(r.line+d,r.ch))},CodeMirror.commands.copyLinesUp=function(e){var t="",o=e.listSelections()[0],i=o.anchor,r=o.head;i.line>r.line&&(i=o.head,r=o.anchor);for(var a=i.line,n=r.line;a<=n;a++)0===r.ch&&a===n||(t+="\n"+e.getLine(a));var s=r.line;0===r.ch&&(s=r.line-1),e.replaceRange(t,CodeMirror.Pos(s)),e.setSelection(CodeMirror.Pos(i.line,i.ch),CodeMirror.Pos(r.line,r.ch))},CodeMirror.commands.moveLinesUp=function(e){var t=e.listSelections()[0],o=t.anchor,i=t.head;if(o.line>i.line&&(o=t.head,i=t.anchor),0===o.line)return!1;var r=i.line;0===i.ch&&(r=i.line-1),e.replaceRange("\n"+e.getLine(o.line-1),CodeMirror.Pos(r)),1===o.line?e.replaceRange("",CodeMirror.Pos(0,0),CodeMirror.Pos(1,0)):e.replaceRange("",CodeMirror.Pos(o.line-2,e.getLine(o.line-2).length),CodeMirror.Pos(o.line-1,e.getLine(o.line-1).length)),e.setSelection(CodeMirror.Pos(o.line-1,o.ch),CodeMirror.Pos(i.line-1,i.ch))},CodeMirror.commands.moveLinesDown=function(e){var t=e.listSelections()[0],o=t.anchor,i=t.head;if(o.line>i.line&&(o=t.head,i=t.anchor),i.line===e.lastLine())return!1;var r=i.line;0===i.ch&&(r=i.line-1),0===o.line?e.replaceRange(e.getLine(r+1)+"\n",CodeMirror.Pos(0,0)):e.replaceRange("\n"+e.getLine(r+1),CodeMirror.Pos(o.line-1)),e.replaceRange("",CodeMirror.Pos(r+1,e.getLine(r+1).length),CodeMirror.Pos(r+2,e.getLine(r+2).length)),e.setSelection(CodeMirror.Pos(o.line+1,o.ch),CodeMirror.Pos(i.line+1,i.ch))},CodeMirror.commands.jumpToDecl=function(e){var t=wide.curEditor.getCursor(),o=newWideRequest();o.path=$(".edit-panel .tabs .current > span:eq(0)").attr("title"),o.code=wide.curEditor.getValue(),o.cursorLine=t.line,o.cursorCh=t.ch,$.ajax({type:"POST",url:"/find/decl",data:JSON.stringify(o),dataType:"json",success:function(e){if(e.succ){var t=e.data,o=tree.getTIdByPath(t.path);wide.curNode=tree.fileTree.getNodeByTId(o),tree.fileTree.selectNode(wide.curNode),tree.openFile(wide.curNode,CodeMirror.Pos(t.cursorLine-1,t.cursorCh-1))}}})},CodeMirror.commands.findUsages=function(e){var t=wide.curEditor.getCursor(),o=newWideRequest();o.path=$(".edit-panel .tabs .current > span:eq(0)").attr("title"),o.code=wide.curEditor.getValue(),o.cursorLine=t.line,o.cursorCh=t.ch,$.ajax({type:"POST",url:"/find/usages",data:JSON.stringify(o),dataType:"json",success:function(e){e.succ&&editors.appendSearch(e.data,"usages","")}})},CodeMirror.commands.selectIdentifier=function(e){var t=e.getCursor(),o=e.findWordAt(t);e.extendSelection(o.anchor,o.head)}},appendSearch:function(e,t,o){for(var i='<ul class="list">',r=(o=o.toLowerCase(),0),a=e.length;r<a;r++){for(var n="",s=e[r].contents[0].toLowerCase().split(o),d=0,l=0,c=0,u=s.length;c<u;c++){l=(d=l+s[c].length)+o.length;var p=e[r].contents[0].substring(d,l);""!==p&&(p="<b>"+p+"</b>"),n+=e[r].contents[0].substring(d-s[c].length,d)+p}i+='<li title="'+e[r].path+'">'+n+"&nbsp;&nbsp;&nbsp;&nbsp;<span class='ft-small'>"+e[r].path+'<i class="position" data-line="'+e[r].line+'" data-ch="'+e[r].ch+'"> ('+e[r].line+":"+e[r].ch+")</i></span></li>"}0===e.length&&(i+="<li>"+config.label.search_no_match+"</li>"),i+="</ul>";var f=$(".bottom-window-group .search"),h=config.label.find_usages;"founds"===t&&(h=config.label.search_text),0===f.find("ul").length?(bottomGroup.searchTab=new Tabs({id:".bottom-window-group .search",removeAfter:function(e,t){1===f.find("ul").length&&f.find(".tabs").hide()}}),f.on("click","li",function(){f.find("li").removeClass("selected"),$(this).addClass("selected")}),f.on("dblclick","li",function(){var e=$(this),t=tree.getTIdByPath(e.attr("title"));tree.openFile(tree.fileTree.getNodeByTId(t)),tree.fileTree.selectNode(wide.curNode);var o=e.find(".position").data("line")-1,i=CodeMirror.Pos(o,e.find(".position").data("ch")-1),r=wide.curEditor;r.setCursor(i);var a=Math.floor(r.getScrollInfo().clientHeight/r.defaultTextHeight()/2),n=r.cursorCoords({line:i.line-a,ch:0},"local");r.scrollTo(0,n.top),wide.curEditor.focus()}),f.find(".tabs-panel > div").append(i),f.find(".tabs .first").text(h)):(f.find(".tabs").show(),bottomGroup.searchTab.add({id:"search"+(new Date).getTime(),title:h,content:i})),bottomGroup.tabs.setCurrent("search"),windows.flowBottom(),$(".bottom-window-group .search").focus()},newEditor:function(e,t){var o=wide.curNode.id;editors.tabs.add({id:o,title:'<span title="'+wide.curNode.path+'"><span class="'+wide.curNode.iconSkin+'ico"></span>'+wide.curNode.name+"</span>",content:'<textarea id="editor'+o+'"></textarea>'}),menu.undisabled(["save-all","close-all","build","run","go-test","go-vet","go-mod","go-install","find","find-next","find-previous","replace","replace-all","format","autocomplete","jump-to-decl","expr-info","find-usages","toggle-comment","edit"]);var i=document.getElementById("editor"+o);i.value=e.content;var r=CodeMirror.fromTextArea(i,{lineNumbers:!0,autofocus:!0,autoCloseBrackets:!0,matchBrackets:!0,highlightSelectionMatches:{showToken:/\w/},rulers:[{color:"#ccc",column:120,lineStyle:"dashed"}],styleActiveLine:!0,theme:config.editorTheme,tabSize:config.editorTabSize,indentUnit:4,indentWithTabs:!0,foldGutter:!0,cursorHeight:1,path:e.path,readOnly:wide.curNode.isGOAPI,profile:"xhtml",extraKeys:{"Ctrl-\\":"autocompleteAnyWord",".":"autocompleteAfterDot","Ctrl-/":"toggleComment","Ctrl-I":"exprInfo","Ctrl-L":"gotoLine","Ctrl-E":"deleteLine","Ctrl-D":"doNothing","Ctrl-B":"jumpToDecl","Ctrl-S":function(){wide.saveFile()},"Shift-Ctrl-S":function(){menu.saveAllFiles()},"Shift-Alt-F":function(){var e=editors.getCurrentPath();if(!e)return!1;wide.fmt(e,wide.curEditor)},"Alt-F7":"findUsages","Shift-Alt-Enter":function(){windows.isMaxEditor?windows.restoreEditor():windows.maxEditor()},"Shift-Ctrl-Up":"copyLinesUp","Shift-Ctrl-Down":"copyLinesDown","Shift-Alt-Up":"moveLinesUp","Shift-Alt-Down":"moveLinesDown","Shift-Alt-J":"selectIdentifier"}});"text/html"===e.mode&&emmetCodeMirror(r),r.on("cursorActivity",function(e){$(".edit-exprinfo").remove();var t=e.getCursor();$(".footer .cursor").text("| "+(t.line+1)+":"+(t.ch+1)+" |")}),r.on("blur",function(e){$(".edit-exprinfo").remove()}),r.on("changes",function(t){t.doc.isClean()?$(".edit-panel .tabs > div").each(function(){var e=$(this).find("span:eq(0)");e.attr("title")===t.options.path&&e.removeClass("changed")}):$(".edit-panel .tabs > div").each(function(){var e=$(this).find("span:eq(0)");e.attr("title")===t.options.path&&e.addClass("changed")})}),r.on("keydown",function(e,t){if(!(t.altKey||t.ctrlKey||t.shiftKey)){var o=t.which;o<48||57<o&&o<65||90<o||config.autocomplete&&.5<=Math.random()&&CodeMirror.commands.autocompleteAfterDot(e)}}),r.setSize("100%",$(".edit-panel").height()-$(".edit-panel .tabs").height()),r.setOption("mode",e.mode),r.setOption("gutters",["CodeMirror-lint-markers","CodeMirror-foldgutter"]),"wide"!==config.keymap&&r.setOption("keyMap",config.keymap),"text/x-go"!==e.mode&&"application/json"!==e.mode||r.setOption("lint",!0),"application/xml"!==e.mode&&"text/html"!==e.mode||r.setOption("autoCloseTags",!0),wide.curEditor=r,editors.data.push({editor:r,id:o}),$(".footer .cursor").text("| "+(t.line+1)+":"+(t.ch+1)+" |");var a=Math.floor(wide.curEditor.getScrollInfo().clientHeight/wide.curEditor.defaultTextHeight()/2),n=wide.curEditor.cursorCoords({line:t.line-a,ch:0},"local");wide.curEditor.scrollTo(0,n.top),r.setCursor(t),r.focus()}};
var notification={init:function(){$(".notification-count").click(function(){bottomGroup.tabs.setCurrent("notification"),$(".bottom-window-group .notification").focus(),$(this).hide()}),this._initWS()},_initWS:function(){var o=new ReconnectingWebSocket(config.channel+"/notification/ws?sid="+config.wideSessionId);o.onopen=function(){console.log("[notification onopen] connected")},o.onmessage=function(o){var n=JSON.parse(o.data),t=$(".bottom-window-group .notification > table"),i="";n.cmd&&"init-notification"===n.cmd?console.log("[notification onmessage]"+o.data):(i+='<tr><td class="severity">'+n.severity+'</td><td class="message">'+n.message+'</td><td class="type">'+n.type+"</td></tr>",t.append(i),$(".notification-count").show())},o.onclose=function(o){console.log("[notification onclose] disconnected ("+o.code+")")},o.onerror=function(o){console.log("[notification onerror]")}}};
var tree={fileTree:void 0,getCurrentNodeLastNode:function(e){var i=e.children[e.children.length-1];return i.open?tree.getCurrentNodeLastNode(i):i},getNextShowNode:function(e){return 0!==e.level?e.getParentNode().getNextNode()?e.getParentNode().getNextNode():tree.getNextShowNode(e.getParentNode()):e.getNextNode()},isBottomNode:function(e){return!e.open&&(e.getParentNode()?!!e.getParentNode().isLastNode&&tree.isBottomNode(e.getParentNode()):!!e.isLastNode)},getTIdByPath:function(e){for(var i=tree.fileTree.transformToArray(tree.fileTree.getNodes()),t=0,o=i.length;t<o;t++)if(i[t].path===e)return i[t].tId},getOpenPaths:function(){for(var e=tree.fileTree.transformToArray(tree.fileTree.getNodes()),i=[],t=0,o=e.length;t<o;t++)e[t].open&&i.push(e[t].path);return i},getAllParents:function(e,i){return i||(i=[]),e&&e.parentTId?(i.push(e.getParentNode()),tree.getAllParents(e.getParentNode(),i)):i},isParents:function(e,i){var t=tree.fileTree.getNodeByTId(e);if(t&&t.parentTId){var o=tree.fileTree.getNodeByTId(t.parentTId);return t.path===i||tree.isParents(o.tId,i)}return!1},isDir:function(){return 0===wide.curNode.iconSkin.indexOf("ico-ztree-dir")},newFile:function(e){if($(e).hasClass("disabled"))return!1;$("#dialogNewFilePrompt").dialog("open")},newDir:function(e){if($(e).hasClass("disabled"))return!1;$("#dialogNewDirPrompt").dialog("open")},removeIt:function(e){if(e){if($(e).hasClass("disabled"))return!1}else if(!wide.curNode.removable)return!1;$("#dialogRemoveConfirm").dialog("open")},rename:function(e){if(e&&$(e).hasClass("disabled"))return!1;$("#dialogRenamePrompt").dialog("open")},export:function(){var e=newWideRequest(),i=!1;e.path=wide.curNode.path,$.ajax({async:!1,type:"POST",url:"/file/zip/new",data:JSON.stringify(e),dataType:"json",success:function(e){if(!e.succ)return $("#dialogAlert").dialog("open",e.msg),!1;i=!0}}),i&&window.open("/file/zip?path="+wide.curNode.path+".zip")},crossCompile:function(e){var i=newWideRequest();i.path=wide.curNode.path,i.platform=e,$.ajax({async:!1,type:"POST",url:"/cross",data:JSON.stringify(i),dataType:"json",success:function(e){if(!e.succ)return $("#dialogAlert").dialog("open",e.msg),!1}})},refresh:function(e){if(e&&$(e).hasClass("disabled"))return!1;tree.fileTree.reAsyncChildNodes(wide.curNode,"refresh",!0)},init:function(){$("#file").click(function(){$(this).focus()});var e=newWideRequest();$.ajax({type:"POST",url:"/files",data:JSON.stringify(e),dataType:"json",success:function(e){if(e.succ){var r=$("#dirRMenu"),a=$("#fileRMenu"),i={data:{key:{title:"path"}},view:{showTitle:!0,selectedMulti:!1},async:{enable:!0,url:"/file/refresh",autoParam:["path"]},callback:{onDblClick:function(e,i,t){t&&tree.openFile(t)},onRightClick:function(e,i,t){if(t&&!t.isGOAPI){if(menu.undisabled(["import","export","git-clone"]),wide.curNode=t,tree.fileTree.selectNode(t),tree.isDir()){wide.curNode.removable?r.find(".remove").removeClass("disabled"):r.find(".remove").addClass("disabled"),wide.curNode.creatable?r.find(".create").removeClass("disabled"):r.find(".create").addClass("disabled");o=e.clientY-10;r.height()+o>$(".content").height()&&(o=o-r.height()-25),r.css({top:o+"px",left:e.clientX+"px",display:"block"}).show(),a.hide()}else{wide.curNode.removable?a.find(".remove").removeClass("disabled"):a.find(".remove").addClass("disabled"),-1===wide.curNode.path.indexOf("zip",wide.curNode.path.length-"zip".length)?a.find(".decompress").hide():a.find(".decompress").show(),-1===wide.curNode.path.indexOf("go",wide.curNode.path.length-"go".length)?a.find(".linux64").hide():a.find(".linux64").show();var o=e.clientY-10;a.height()+o>$(".content").height()&&(o=o-a.height()-25),a.css({top:o+"px",left:e.clientX+"px",display:"block"}).show(),r.hide(),menu.disabled(["import","git-clone"])}$("#files").focus()}},onClick:function(e,i,t,o){t&&(wide.curNode=t,tree.fileTree.selectNode(t),menu.undisabled(["import","export","git-clone"]),tree.isDir()||menu.disabled(["import","git-clone"]),$("#files").focus())}}};tree.fileTree=$.fn.zTree.init($("#files"),i,e.data.children),session.restore()}}}),this._initSearch(),this._initRename()},openFile:function(o,e){wide.curNode=o;for(var r=e,i=0,t=editors.data.length;i<t;i++)if(editors.data[i].id===o.path){editors.tabs.setCurrent(o.path),wide.curEditor=editors.data[i].editor,r||(r=wide.curEditor.getCursor()),$(".footer .cursor").text("| "+(r.line+1)+":"+(r.ch+1)+" |"),wide.curEditor.setCursor(r);var a=Math.floor(wide.curEditor.getScrollInfo().clientHeight/wide.curEditor.defaultTextHeight()/2),n=wide.curEditor.cursorCoords({line:r.line-a,ch:0},"local");return wide.curEditor.scrollTo(0,n.top),wide.curEditor.focus(),wide.refreshOutline(),!1}if(!tree.isDir()){var d=newWideRequest();d.path=o.path,$.ajax({async:!1,type:"POST",url:"/file",data:JSON.stringify(d),dataType:"json",success:function(e){if(!e.succ)return $("#dialogAlert").dialog("open",e.msg),!1;var i=e.data;if(!i.mode){var t=CodeMirror.findModeByFileName(o.path);i.mode=t?t.mime:"text/plain"}if(i.mode||console.error("Can't find mode by file name ["+o.path+"]"),"img"===i.mode){window.open(i.path);return!1}r||(r=CodeMirror.Pos(0,0)),editors.newEditor(i,r),wide.refreshOutline()}})}},_initSearch:function(){$("#dialogSearchForm > input:eq(0)").keyup(function(e){var i=$(this).closest(".dialog-main").find(".dialog-footer > button:eq(0)");13!==e.which||i.prop("disabled")||i.click(),""===$.trim($(this).val())?i.prop("disabled",!0):i.prop("disabled",!1)}),$("#dialogSearchForm > input:eq(1)").keyup(function(e){var i=$(this).closest(".dialog-main").find(".dialog-footer > button:eq(0)");13!==e.which||i.prop("disabled")||i.click()}),$("#dialogSearchForm").dialog({modal:!0,height:80,width:260,title:config.label.search,okText:config.label.search,cancelText:config.label.cancel,afterOpen:function(){$("#dialogSearchForm > input:eq(0)").val("").focus(),$("#dialogSearchForm > input:eq(1)").val(""),$("#dialogSearchForm").closest(".dialog-main").find(".dialog-footer > button:eq(0)").prop("disabled",!0)},ok:function(){var i=newWideRequest();wide.curNode?i.dir=wide.curNode.path:i.dir="",i.text=$("#dialogSearchForm > input:eq(0)").val(),i.extension=$("#dialogSearchForm > input:eq(1)").val(),$.ajax({type:"POST",url:"/file/search/text",data:JSON.stringify(i),dataType:"json",success:function(e){e.succ&&($("#dialogSearchForm").dialog("close"),editors.appendSearch(e.data,"founds",i.text))}})}})},_initRename:function(){$("#dialogRenamePrompt").dialog({modal:!0,height:52,width:260,title:config.label.rename,okText:config.label.rename,cancelText:config.label.cancel,afterOpen:function(){$("#dialogRenamePrompt").closest(".dialog-main").find(".dialog-footer > button:eq(0)").prop("disabled",!0),$("#dialogRenamePrompt > input").val(wide.curNode.name).select().focus()},ok:function(){var e=$("#dialogRenamePrompt > input").val(),i=newWideRequest();i.oldPath=wide.curNode.path,i.newPath=wide.curNode.path.substring(0,wide.curNode.path.lastIndexOf("/")+1)+e,$.ajax({type:"POST",url:"/file/rename",data:JSON.stringify(i),dataType:"json",success:function(e){if(!e.succ)return $("#dialogRenamePrompt").dialog("close"),bottomGroup.tabs.setCurrent("notification"),windows.flowBottom(),$(".bottom-window-group .notification").focus(),!1;$("#dialogRenamePrompt").dialog("close")}})}})}};
var wide={curNode:void 0,curEditor:void 0,curProcessId:void 0,refreshOutline:function(){if(!wide.curEditor||wide.curEditor&&"go"!==wide.curEditor.doc.getMode().name)return $("#outline").html(""),!1;var e=newWideRequest();e.code=wide.curEditor.getValue(),$.ajax({type:"POST",async:!1,url:"/outline",data:JSON.stringify(e),dataType:"json",success:function(e){if(e.succ){for(var t=e.data,o='<ul class="list">',i=["constDecls","varDecls","funcDecls","structDecls","interfaceDecls","typeDecls"],a=0,l=i.length;a<l;a++)for(var n=i[a],r=0,s=t[n].length;r<s;r++){var c=t[n][r];o+='<li data-ch="'+c.Ch+'" data-line="'+c.Line+'"><span class="ico ico-'+n.replace("Decls","")+'"></span> '+c.Name+"</li>"}$("#outline").html(o+"</ul>"),$("#outline li").dblclick(function(){var e=$(this),t=CodeMirror.Pos(e.data("line"),e.data("ch")),o=wide.curEditor;o.setCursor(t);var i=Math.floor(o.getScrollInfo().clientHeight/o.defaultTextHeight()/2),a=o.cursorCoords({line:t.line-i,ch:0},"local");o.scrollTo(0,a.top),o.focus()})}}})},_initDialog:function(){$(".dialog-prompt > input").keyup(function(e){var t=$(this).closest(".dialog-main").find(".dialog-footer > button:eq(0)");13!==e.which||t.prop("disabled")||t.click(),""===$.trim($(this).val())?t.prop("disabled",!0):t.prop("disabled",!1)}),$("#dialogAlert").dialog({modal:!0,height:40,width:350,title:config.label.tip,hiddenOk:!0,cancelText:config.label.confirm,afterOpen:function(e){$("#dialogAlert").html(e)}}),$("#dialogRemoveConfirm").dialog({modal:!0,height:36,width:260,title:config.label.delete,okText:config.label.delete,cancelText:config.label.cancel,afterOpen:function(){$("#dialogRemoveConfirm > b").html('"'+wide.curNode.name+'"')},ok:function(){var e=newWideRequest();e.path=wide.curNode.path,$.ajax({type:"POST",url:"/file/remove",data:JSON.stringify(e),dataType:"json",success:function(e){if(!e.succ)return $("#dialogRemoveConfirm").dialog("close"),bottomGroup.tabs.setCurrent("notification"),windows.flowBottom(),$(".bottom-window-group .notification").focus(),!1;$("#dialogRemoveConfirm").dialog("close")}})}}),$("#dialogNewFilePrompt").dialog({modal:!0,height:52,width:260,title:config.label.create_file,okText:config.label.create,cancelText:config.label.cancel,afterOpen:function(){$("#dialogNewFilePrompt > input").val("").focus(),$("#dialogNewFilePrompt").closest(".dialog-main").find(".dialog-footer > button:eq(0)").prop("disabled",!0)},ok:function(){var t=newWideRequest(),e=$("#dialogNewFilePrompt > input").val();t.path=wide.curNode.path+"/"+e,t.fileType="f",$.ajax({type:"POST",url:"/file/new",data:JSON.stringify(t),dataType:"json",success:function(e){if(!e.succ)return $("#dialogNewFilePrompt").dialog("close"),bottomGroup.tabs.setCurrent("notification"),windows.flowBottom(),$(".bottom-window-group .notification").focus(),!1;$("#dialogNewFilePrompt").dialog("close"),setTimeout(function(){var e=tree.getTIdByPath(t.path);tree.openFile(tree.fileTree.getNodeByTId(e)),tree.fileTree.selectNode(wide.curNode)},100)}})}}),$("#dialogNewDirPrompt").dialog({modal:!0,height:52,width:260,title:config.label.create_dir,okText:config.label.create,cancelText:config.label.cancel,afterOpen:function(){$("#dialogNewDirPrompt > input").val("").focus(),$("#dialogNewDirPrompt").closest(".dialog-main").find(".dialog-footer > button:eq(0)").prop("disabled",!0)},ok:function(){var e=$("#dialogNewDirPrompt > input").val(),t=newWideRequest();t.path=wide.curNode.path+"/"+e,t.fileType="d",$.ajax({type:"POST",url:"/file/new",data:JSON.stringify(t),dataType:"json",success:function(e){if(!e.succ)return $("#dialogNewDirPrompt").dialog("close"),bottomGroup.tabs.setCurrent("notification"),windows.flowBottom(),$(".bottom-window-group .notification").focus(),!1;$("#dialogNewDirPrompt").dialog("close")}})}}),$("#dialogGoFilePrompt").dialog({modal:!0,height:320,width:660,title:config.label.goto_file,okText:config.label.go,cancelText:config.label.cancel,afterInit:function(){$("#dialogGoFilePrompt").on("dblclick","li",function(){var e=tree.getTIdByPath($(this).find(".ft-small").text());tree.openFile(tree.fileTree.getNodeByTId(e)),tree.fileTree.selectNode(wide.curNode),$("#dialogGoFilePrompt").dialog("close"),wide.curEditor.focus()}),$("#dialogGoFilePrompt").on("click","li",function(){var e=$("#dialogGoFilePrompt > .list");e.find("li").removeClass("selected"),e.data("index",$(this).data("index")),$(this).addClass("selected")}),hotkeys.bindList($("#dialogGoFilePrompt > input"),$("#dialogGoFilePrompt > .list"),function(e){var t=tree.getTIdByPath(e.find(".ft-small").text());tree.openFile(tree.fileTree.getNodeByTId(t)),tree.fileTree.selectNode(wide.curNode),$("#dialogGoFilePrompt").dialog("close"),wide.curEditor.focus()}),$("#dialogGoFilePrompt > input").bind("input",function(){var e=$("#dialogGoFilePrompt > input").val(),t=newWideRequest();t.path="",t.name="*"+e+"*",wide.curNode&&(t.path=wide.curNode.path),$.ajax({type:"POST",url:"/file/find/name",data:JSON.stringify(t),dataType:"json",success:function(e){if(e.succ){for(var t=e.data,o="",i=0,a=t.length;i<a;i++){var l=t[i].path,n=l.substr(l.lastIndexOf("/")+1),r=wide.getClassBySuffix(n.split(".")[1]);o+=0===i?'<li data-index="'+i+'" class="selected" title="'+l+'"><span class="'+r+'ico"></span>'+n+'&nbsp;&nbsp;&nbsp;&nbsp;<span class="ft-small">'+l+"</span></li>":'<li data-index="'+i+'" title="'+l+'"><span class="'+r+'ico"></span>'+n+'&nbsp;&nbsp;&nbsp;&nbsp;<span class="ft-small">'+l+"</span></li>"}$("#dialogGoFilePrompt > ul").html(o)}}})})},afterOpen:function(){$("#dialogGoFilePrompt > input").val("").focus(),$("#dialogGoFilePrompt").closest(".dialog-main").find(".dialog-footer > button:eq(0)").prop("disabled",!0),$("#dialogGoFilePrompt .list").html("").data("index",0)},ok:function(){var e=tree.getTIdByPath($("#dialogGoFilePrompt .selected .ft-small").text());tree.openFile(tree.fileTree.getNodeByTId(e)),tree.fileTree.selectNode(wide.curNode),$("#dialogGoFilePrompt").dialog("close"),wide.curEditor.focus()}}),$("#dialogGoLinePrompt").dialog({modal:!0,height:52,width:260,title:config.label.goto_line,okText:config.label.go,cancelText:config.label.cancel,afterOpen:function(){$("#dialogGoLinePrompt > input").val("").focus(),$("#dialogGoLinePrompt").closest(".dialog-main").find(".dialog-footer > button:eq(0)").prop("disabled",!0)},ok:function(){var e=parseInt($("#dialogGoLinePrompt > input").val())-1;$("#dialogGoLinePrompt").dialog("close");var t=wide.curEditor,o=t.getCursor();t.setCursor(CodeMirror.Pos(e,o.ch));var i=Math.floor(t.getScrollInfo().clientHeight/t.defaultTextHeight()/2),a=t.cursorCoords({line:e-i,ch:o.ch},"local");t.scrollTo(0,a.top),t.focus()}})},_initWS:function(){var e=new ReconnectingWebSocket(config.channel+"/output/ws?sid="+config.wideSessionId);e.onopen=function(){console.log("[output onopen] connected")},e.onmessage=function(e){console.log("[output onmessage]"+e.data);var t=JSON.parse(e.data);(goLintFound&&(goLintFound=[]),"run"===t.nextCmd)&&((s=newWideRequest()).executable=t.executable,$.ajax({type:"POST",url:"/run",data:JSON.stringify(s),dataType:"json"}));switch(t.cmd){case"run":var o=$(".bottom-window-group .output > div").html();wide.curProcessId&&""!==o?bottomGroup.fillOutput(o.replace(/<\/pre>$/g,t.output+"</pre>")):bottomGroup.fillOutput(o+"<pre>"+t.output+"</pre>"),wide.curProcessId=t.pid;break;case"run-done":bottomGroup.fillOutput($(".bottom-window-group .output > div").html().replace(/<\/pre>$/g,t.output+"</pre>")),wide.curProcessId=void 0,$("#buildRun").removeClass("ico-stop").addClass("ico-buildrun").attr("title",config.label.build_n_run);break;case"start-build":case"start-test":case"start-vet":case"start-install":bottomGroup.fillOutput(t.output);break;case"go test":case"go vet":case"go install":bottomGroup.fillOutput($(".bottom-window-group .output > div").html()+t.output);break;case"git clone":bottomGroup.fillOutput($(".bottom-window-group .output > div").html()+t.output),tree.fileTree.reAsyncChildNodes(wide.curNode,"refresh",!1);break;case"build":case"cross-build":if(bottomGroup.fillOutput($(".bottom-window-group .output > div").html()+t.output),t.lints){for(var i={},a=0;a<t.lints.length;a++){var l=t.lints[a];goLintFound.push({from:CodeMirror.Pos(l.lineNo,0),to:CodeMirror.Pos(l.lineNo,0),message:l.msg,severity:l.severity}),i[l.file]=l.file}for(var n in $("#buildRun").removeClass("ico-stop").addClass("ico-buildrun").attr("title",config.label.build_n_run),i){var r=editors.getEditorByPath(n);CodeMirror.signal(r,"change",r)}}else if("cross-build"===t.cmd){var s=newWideRequest();n=null;s.path=t.executable,s.name=t.name,$.ajax({async:!1,type:"POST",url:"/file/zip/new",data:JSON.stringify(s),dataType:"json",success:function(e){if(!e.succ)return $("#dialogAlert").dialog("open",e.msg),!1;n=e.data}}),n&&window.open("/file/zip?path="+n+".zip")}}},e.onclose=function(e){console.log("[output onclose] disconnected ("+e.code+")")},e.onerror=function(e){console.log("[output onerror]")}},_initFooter:function(){$(".footer .cursor").dblclick(function(){$("#dialogGoLinePrompt").dialog("open")})},init:function(){this._initFooter(),this._initWS(),$("body").bind("mouseup",function(e){if(3===e.which)return!1;$(".frame").hide(),1!==$(e.target).closest(".frame").length&&"frame"!==e.target.className&&($(".menu > ul > li").unbind().removeClass("selected"),menu.subMenu())}),window.onbeforeunload=function(){if(0<editors.data.length)return config.label.confirm_save},document.oncontextmenu=function(){return!1},this._initDialog()},_save:function(t,o){if(!t)return!1;var e=newWideRequest();e.file=t,e.code=o.getValue(),$.ajax({type:"POST",url:"/file/save",data:JSON.stringify(e),dataType:"json",success:function(e){o.doc.markClean(),$(".edit-panel .tabs > div").each(function(){var e=$(this).find("span:eq(0)");e.attr("title")===t&&e.removeClass("changed")})}})},saveFile:function(){var e=editors.getCurrentPath();if(!e)return!1;var t=wide.curEditor;if(t.doc.isClean())return!1;if("text/x-go"===t.getOption("mode")){wide.gofmt(e,wide.curEditor);var o=newWideRequest();return o.file=e,o.code=t.getValue(),o.nextCmd="",$.ajax({type:"POST",url:"/build",data:JSON.stringify(o),dataType:"json",beforeSend:function(){bottomGroup.resetOutput()},success:function(e){}}),void wide.refreshOutline()}wide._save(e,wide.curEditor)},stop:function(){if($("#buildRun").hasClass("ico-buildrun"))return menu.run(),!1;if(!wide.curProcessId)return!1;var e=newWideRequest();e.pid=wide.curProcessId,$.ajax({type:"POST",url:"/stop",data:JSON.stringify(e),dataType:"json",success:function(e){$("#buildRun").removeClass("ico-stop").addClass("ico-buildrun").attr("title",config.label.build_n_run)}})},gofmt:function(t,o){var i=o.getCursor(),a=o.getScrollInfo(),e=newWideRequest();e.file=t,e.code=o.getValue(),e.cursorLine=i.line,e.cursorCh=i.ch,$.ajax({async:!1,type:"POST",url:"/go/fmt",data:JSON.stringify(e),dataType:"json",success:function(e){e.succ&&(o.setValue(e.data.code),o.setCursor(i),o.scrollTo(null,a.top),wide._save(t,o))}})},fmt:function(e,t){var o=t.getOption("mode"),i=t.getCursor(),a=t.getScrollInfo(),l=newWideRequest();l.file=e,l.code=t.getValue(),l.cursorLine=i.line,l.cursorCh=i.ch;var n=null;switch(o){case"text/x-go":$.ajax({async:!1,type:"POST",url:"/go/fmt",data:JSON.stringify(l),dataType:"json",success:function(e){e.succ&&(n=e.data.code)}});break;case"text/html":n=html_beautify(t.getValue());break;case"text/javascript":case"application/json":n=js_beautify(t.getValue());break;case"text/css":n=css_beautify(t.getValue())}n&&(t.setValue(n),t.setCursor(i),t.scrollTo(null,a.top),wide._save(e,t))},getClassBySuffix:function(e){var t="ico-ztree-other ";switch(e){case"html":case"htm":t="ico-ztree-html ";break;case"go":t="ico-ztree-go ";break;case"css":t="ico-ztree-css ";break;case"txt":t="ico-ztree-text ";break;case"sql":t="ico-ztree-sql ";break;case"properties":t="ico-ztree-pro ";break;case"md":t="ico-ztree-md ";break;case"json":t="ico-ztree-js ";break;case"xml":t="ico-ztree-xml ";break;case"jpg":case"jpeg":case"bmp":case"gif":case"png":case"svg":case"ico":t="ico-ztree-img "}return t}};$(document).ready(function(){wide.init(),tree.init(),menu.init(),hotkeys.init(),session.init(),notification.init(),editors.init(),windows.init(),bottomGroup.init()});
var session={init:function(){this._initWS();var s=function(e){var t="normal";return e.isClosed?t="min":e.size>=$("body").width()&&(t="max"),t};setInterval(function(){var e,t=newWideRequest(),o=[],n=editors.getCurrentId()?editors.getCurrentPath():"";editors.tabs.obj._$tabs.find("div").each(function(){var e=$(this);e.find("span:eq(0)").attr("title")!==config.label.start_page&&o.push(e.find("span:eq(0)").attr("title"))}),e=tree.getOpenPaths(),t.currentFile=n,t.fileTree=e,t.files=o,t.layout={side:{size:windows.outerLayout.west.state.size,state:s(windows.outerLayout.west.state)},sideRight:{size:windows.innerLayout.east.state.size,state:s(windows.innerLayout.east.state)},bottom:{size:windows.innerLayout.south.state.size,state:s(windows.innerLayout.south.state)}},$.ajax({type:"POST",url:"/session/save",data:JSON.stringify(t),dataType:"json",success:function(e){}})},3e4)},restore:function(){if(config.latestSessionContent){for(var e=config.latestSessionContent.fileTree,t=config.latestSessionContent.files,o=config.latestSessionContent.currentFile,n="",s=[],r=tree.fileTree.transformToArray(tree.fileTree.getNodes()),i=0,a=r.length;i<a;i++){for(var d=0,l=e.length;d<l;d++)if(r[i].path===e[d]){for(var c=tree.getAllParents(tree.fileTree.getNodeByTId(r[i].tId)),f=!0,g=0,p=c.length;g<p;g++)!1===c[g].open&&(f=!1);f?tree.fileTree.expandNode(r[i],!0,!1,!0):r[i].open=!0;break}for(var h=0,u=t.length;h<u;h++)if(r[i].path===t[h]){s.push(r[i]);break}r[i].path===o&&(n=r[i].path,tree.fileTree.selectNode(r[i]),wide.curNode=r[i])}for(var w=0,y=t.length;w<y;w++)for(var v=0,m=s.length;v<m;v++)if(s[v].path===t[w]){tree.openFile(s[v]);break}editors.tabs.setCurrent(n);var b=0;for(p=editors.data.length;b<p;b++)if(n===editors.data[b].id){wide.curEditor=editors.data[b].editor;break}}},_initWS:function(){var e=new ReconnectingWebSocket(config.channel+"/session/ws?sid="+config.wideSessionId);e.onopen=function(){console.log("[session onopen] connected");var e="Network",t="";t+='<tr><td class="severity">'+"INFO"+'</td><td class="message">'+("Connected to server [sid="+config.wideSessionId+"], "+function(e,t){var o=new Date(e),n={"M+":o.getMonth()+1,"d+":o.getDate(),"h+":o.getHours(),"m+":o.getMinutes(),"s+":o.getSeconds(),"q+":Math.floor((o.getMonth()+3)/3),S:o.getMilliseconds()};for(var s in/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(o.getFullYear()+"").substr(4-RegExp.$1.length))),n)new RegExp("("+s+")").test(t)&&(t=t.replace(RegExp.$1,1===RegExp.$1.length?n[s]:("00"+n[s]).substr((""+n[s]).length)));return t}((new Date).getTime(),"yyyy-MM-dd hh:mm:ss"))+'</td><td class="type">'+e+"</td></tr>",$(".bottom-window-group .notification > table").append(t)},e.onmessage=function(e){var t=JSON.parse(e.data);switch(t.cmd){case"create-file":var o=tree.fileTree.getNodeByTId(tree.getTIdByPath(t.dir)),n=t.path.replace(t.dir+"/",""),s=CodeMirror.findModeByFileName(n),r=wide.getClassBySuffix(n.split(".")[1]);t.type&&"f"===t.type?tree.fileTree.addNodes(o,[{id:t.path,name:n,iconSkin:r,path:t.path,mode:s,removable:!0,creatable:!0}]):tree.fileTree.addNodes(o,[{id:t.path,name:n,iconSkin:"ico-ztree-dir ",path:t.path,removable:!0,creatable:!0,isParent:!0}]);break;case"remove-file":case"rename-file":o=tree.fileTree.getNodeByTId(tree.getTIdByPath(t.path));tree.fileTree.removeNode(o);for(var i=tree.fileTree.transformToArray(o),a=0,d=i.length;a<d;a++)editors.tabs.del(i[a].path)}},e.onclose=function(e){console.log("[session onclose] disconnected ("+e.code+")");var t="Network",o="";o+='<tr><td class="severity">'+"ERROR"+'</td><td class="message">'+("Disconnected from server, trying to reconnect it [sid="+config.wideSessionId+"]")+'</td><td class="type">'+t+"</td></tr>",$(".bottom-window-group .notification > table").append(o),$(".notification-count").show()},e.onerror=function(e){console.log("[session onerror]")}}};
var menu={init:function(){this.subMenu(),this._initPreference(),this._initAbout(),this._initShare(),$(".menu .frame li").click(function(){$(".menu > ul > li").unbind().removeClass("selected"),menu.subMenu()})},_initShare:function(){$(".menu .ico-share").hover(function(){$(".menu .share-panel").show()}),$(".share-panel .font-ico").click(function(){var e=$(this).attr("class").split("-")[2],t="https://wide.b3log.org",a="https://wide.b3log.org/static/images/wide-logo.png",i={};i.email="mailto:?subject="+$("title").text()+"&body="+$("meta[name=description]").attr("content")+" "+t;var n=encodeURIComponent($("meta[name=description]").attr("content")+" "+t+" #golang");i.twitter="https://twitter.com/intent/tweet?status="+n,i.facebook="https://www.facebook.com/sharer/sharer.php?u="+t,i.googleplus="https://plus.google.com/share?url="+t;var o=encodeURIComponent($("title").text()+". \n"+$("meta[name=description]").attr("content")+" #golang#");i.weibo="http://v.t.sina.com.cn/share/share.php?title="+o+"&url="+t+"&pic="+a,i.qqz="https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url="+t+"&sharesource=qzone&title="+o+"&pics="+a,window.open(i[e],"_blank","top=100,left=200,width=648,height=618")})},_initAbout:function(){$("#dialogAbout").load("/about",function(){$("#dialogAbout").dialog({modal:!0,title:config.label.about,hideFooter:!0,afterOpen:function(){$.ajax({url:"https://rhythm.b3log.org/version/wide/latest",type:"GET",dataType:"jsonp",jsonp:"callback",success:function(e,t){$("#dialogAbout .version").text()===e.wideVersion?$(".upgrade").text(config.label.uptodate):$(".upgrade").html(config.label.new_version_available+config.label.colon+"<a href='"+e.wideDownload+"' target='_blank'>"+e.wideVersion+"</a>")}})}})})},disabled:function(e){for(var t=0,a=e.length;t<a;t++)$(".menu li."+e[t]).addClass("disabled")},undisabled:function(e){for(var t=0,a=e.length;t<a;t++)$(".menu li."+e[t]).removeClass("disabled")},subMenu:function(){$(".menu > ul > li").click(function(e){1!==$(e.target).closest(".frame").length&&($(this).find(".frame").show(),$(".menu > ul > li").removeClass("selected"),$(this).addClass("selected"),$(".menu > ul > li").unbind(),$(".menu > ul > li").mouseover(function(){1!==$(e.target).closest(".frame").length&&($(".menu .frame").hide(),$(this).find(".frame").show(),$(".menu > ul > li").removeClass("selected"),$(this).addClass("selected"))}))})},openPreference:function(){$("#dialogPreference").dialog("open")},saveAllFiles:function(){if($(".menu li.save-all").hasClass("disabled"))return!1;for(var e=0,t=editors.data.length;e<t;e++){var a=editors.data[e].id,i=editors.data[e].editor;"text/x-go"===i.getOption("mode")?wide.fmt(a,i):wide._save(a,i)}},closeAllFiles:function(){if($(".menu li.close-all").hasClass("disabled"))return!1;var t=[];$(".edit-panel .tabs > div").each(function(e){0!==e&&t.push($(this).data("index"))}),$("#dialogCloseEditor").data("removeData",t),$(".edit-panel .tabs .ico-close:eq(0)").click()},exit:function(){var e=newWideRequest();$.ajax({type:"POST",url:"/logout",data:JSON.stringify(e),dataType:"json",success:function(e){e.succ&&(window.location.href="/login")}})},openAbout:function(){$("#dialogAbout").dialog("open")},goinstall:function(){menu.saveAllFiles();var e=editors.getCurrentPath();if(!e)return!1;if($(".menu li.go-install").hasClass("disabled"))return!1;var t=newWideRequest();t.file=e,$.ajax({type:"POST",url:"/go/install",data:JSON.stringify(t),dataType:"json",beforeSend:function(){bottomGroup.resetOutput()},success:function(e){}})},test:function(){menu.saveAllFiles();var e=editors.getCurrentPath();if(!e)return!1;if($(".menu li.go-test").hasClass("disabled"))return!1;var t=newWideRequest();t.file=e,$.ajax({type:"POST",url:"/go/test",data:JSON.stringify(t),dataType:"json",beforeSend:function(){bottomGroup.resetOutput()},success:function(e){}})},govet:function(){menu.saveAllFiles();var e=editors.getCurrentPath();if(!e)return!1;if($(".menu li.go-vet").hasClass("disabled"))return!1;var t=newWideRequest();t.file=e,$.ajax({type:"POST",url:"/go/vet",data:JSON.stringify(t),dataType:"json",beforeSend:function(){bottomGroup.resetOutput()},success:function(e){}})},run:function(){if(menu.saveAllFiles(),$("#buildRun").hasClass("ico-stop"))return wide.stop(),!1;var e=editors.getCurrentPath();if(!e)return!1;if($(".menu li.run").hasClass("disabled"))return!1;var t=newWideRequest();t.file=e,t.code=wide.curEditor.getValue(),t.nextCmd="run",$.ajax({type:"POST",url:"/build",data:JSON.stringify(t),dataType:"json",beforeSend:function(){bottomGroup.resetOutput(),$("#buildRun").addClass("ico-stop").removeClass("ico-buildrun").attr("title",config.label.stop)},success:function(e){}})},build:function(){menu.saveAllFiles();var e=editors.getCurrentPath();if(!e)return!1;if($(".menu li.build").hasClass("disabled"))return!1;var t=newWideRequest();t.file=e,t.code=wide.curEditor.getValue(),t.nextCmd="",$.ajax({type:"POST",url:"/build",data:JSON.stringify(t),dataType:"json",beforeSend:function(){bottomGroup.resetOutput()},success:function(e){}})},_initPreference:function(){$("#dialogPreference").load("/preference",function(){$("#dialogPreference input").keyup(function(){var t=!1,a=[],e="";$("#dialogPreference input").each(function(){var e=$(this);e.val()!=e.data("value")&&(t=!0),""===$.trim(e.val())&&a.push(e)});var i=$("#dialogPreference").closest(".dialog-main").find(".dialog-footer > button:eq(0)");if(t?i.prop("disabled",!1):i.prop("disabled",!0),0===a.length)$("#dialogPreference").find(".tip").html(""),i.prop("disabled",!1);else{for(var n=0,o=a.length;n<o;n++){var l=a[n].closest("div").data("index"),r=$.trim(a[n].parent().text());e+="["+$('#dialogPreference .tabs > div[data-index="'+l+'"]').text()+"] -> ["+r.substr(0,r.length-1)+"]: "+config.label.no_empty+"<br/>"}$("#dialogPreference").find(".tip").html(e),i.prop("disabled",!0)}}),$("#dialogPreference select").on("change",function(){var e=!1;$("#dialogPreference select").each(function(){$(this).val()!==$(this).data("value")&&(e=!0)});var t=$("#dialogPreference").closest(".dialog-main").find(".dialog-footer > button:eq(0)");e?t.prop("disabled",!1):t.prop("disabled",!0)}),$("#dialogPreference").dialog({modal:!0,height:280,width:800,title:config.label.preference,okText:config.label.apply,cancelText:config.label.cancel,afterOpen:function(){$("#dialogPreference").closest(".dialog-main").find(".dialog-footer > button:eq(0)").prop("disabled",!0)},ok:function(){var e=newWideRequest(),t=$("#dialogPreference"),o=t.find("input[name=fontFamily]"),l=t.find("input[name=fontSize]"),r=t.find("select[name=goFmt]"),s=t.find("input[name=GoBuildArgsForLinux]"),d=t.find("input[name=GoBuildArgsForWindows]"),u=t.find("input[name=GoBuildArgsForDarwin]"),c=t.find("input[name=workspace]"),f=t.find("input[name=password]"),p=t.find("input[name=email]"),g=t.find("select[name=locale]"),v=t.find("select[name=theme]"),m=t.find("input[name=editorFontFamily]"),h=t.find("input[name=editorFontSize]"),b=t.find("input[name=editorLineHeight]"),w=t.find("select[name=editorTheme]"),y=t.find("input[name=editorTabSize]"),P=t.find("select[name=keymap]");$.extend(e,{fontFamily:o.val(),fontSize:l.val(),goFmt:r.val(),GoBuildArgsForLinux:s.val(),GoBuildArgsForWindows:d.val(),GoBuildArgsForDarwin:u.val(),workspace:c.val(),password:f.val(),locale:g.val(),theme:v.val(),editorFontFamily:m.val(),editorFontSize:h.val(),editorLineHeight:b.val(),editorTheme:w.val(),editorTabSize:y.val(),keymap:P.val()}),config.keymap!==P.val()&&window.location.reload(),$.ajax({type:"POST",url:"/preference",data:JSON.stringify(e),success:function(e,t,a){if(!e.succ)return!1;o.data("value",o.val()),l.data("value",l.val()),r.data("value",r.val()),s.data("value",s.val()),d.data("value",d.val()),u.data("value",u.val()),c.data("value",c.val()),f.data("value",f.val()),p.data("value",p.val()),g.data("value",g.val()),v.data("value",v.val()),m.data("value",m.val()),h.data("value",h.val()),b.data("value",b.val()),w.data("value",w.val()),y.data("value",y.val()),P.data("value",P.val()),config.keymap=P.val(),$("#dialogPreference").closest(".dialog-main").find(".dialog-footer > button:eq(0)").prop("disabled",!0),$("#themesLink").attr("href","/static/css/themes/"+v.val()+".css"),config.editorTheme=w.val();for(var i=0,n=editors.data.length;i<n;i++)editors.data[i].editor.setOption("theme",w.val())}})}}),new Tabs({id:".preference"})})}};
var windows={isMaxEditor:!1,outerLayout:{},innerLayout:{},init:function(){config.latestSessionContent||(config.latestSessionContent={fileTree:[],files:[],currentFile:""}),config.latestSessionContent.layout||(config.latestSessionContent.layout={side:{size:200,state:"normal"},sideRight:{size:200,state:"normal"},bottom:{size:100,state:"normal"}});var o=config.latestSessionContent.layout;this.outerLayout=$("body").layout({north__paneSelector:".menu",center__paneSelector:".content",south__paneSelector:".footer",north__size:22,south__size:19,spacing_open:2,north__spacing_open:0,south__spacing_open:0,defaults:{fxSpeed_open:300,fxSpeed_close:100,fxSettings_close:{easing:"easeOutQuint"},fxSettings_open:{easing:"easeInQuint"}},west:{size:o.side.size,paneSelector:".side",togglerLength_open:0,togglerLength_closed:15,togglerAlign_closed:"top",slideTrigger_open:"mouseover",spacing_closed:15,minSize:100,togglerClass:"ico-restore",togglerTip_open:config.label.min,togglerTip_closed:config.label.restore_side,resizerTip:config.label.resize,initClosed:"min"===o.side.state}}),this.innerLayout=$("div.content").layout({spacing_open:2,defaults:{fxSpeed_open:300,fxSpeed_close:100,fxSettings_close:{easing:"easeOutQuint"},fxSettings_open:{easing:"easeInQuint"}},center:{paneSelector:".edit-panel"},east:{size:o.sideRight.size,paneSelector:".side-right",togglerLength_open:0,togglerLength_closed:15,togglerAlign_closed:"top",slideTrigger_open:"mouseover",spacing_closed:15,minSize:100,togglerClass:"ico-restore",togglerTip_open:config.label.min,togglerTip_closed:config.label.restore_outline,resizerTip:config.label.resize,initClosed:"min"===o.sideRight.state},south:{size:o.bottom.size,paneSelector:".bottom-window-group",togglerLength_open:0,togglerLength_closed:15,togglerAlign_closed:"top",slideTrigger_open:"mouseover",spacing_closed:16,minSize:100,togglerClass:"ico-restore",togglerTip_open:config.label.min,togglerTip_closed:config.label.restore_bottom,resizerTip:config.label.resize,initClosed:"min"===o.bottom.state,ondrag_end:function(o,e){windows.refreshEditor(e,"drag")},onresize_end:function(o,e){windows.refreshEditor(e,"resize")},onclose_end:function(o,e){windows.refreshEditor(e,"close")},onopen_end:function(o,e){windows.refreshEditor(e,"open")},onshow_end:function(o,e){windows.refreshEditor(e,"show")}}}),this.outerLayout.addCloseBtn(".side .ico-min","west"),this.innerLayout.addCloseBtn(".side-right .ico-min","east"),this.innerLayout.addCloseBtn(".bottom-window-group .ico-min","south"),"max"===o.side.state&&windows.maxSide(),"max"===o.sideRight.state&&windows.maxSideRight(),"max"===o.bottom.state&&windows.maxBottom(),$(".toolbars .ico-max").click(function(){windows.toggleEditor()}),$(".edit-panel .tabs").on("dblclick",function(){windows.toggleEditor()}),$(".bottom-window-group .tabs").dblclick(function(){var o=$(".bottom-window-group");o.hasClass("bottom-window-group-max")?windows.restoreBottom():windows.maxBottom(o)}),$(".side .tabs").dblclick(function(){var o=$(".side");o.hasClass("side-max")?windows.restoreSide():windows.restoreSide(o)}),$(".side-right .tabs").dblclick(function(){var o=$(".side-right");o.hasClass("side-right-max")?windows.restoreSideRight():windows.maxSideRight(o)}),$(".bottom-window-group .search").height($(".bottom-window-group .tabs-panel").height()),$(window).resize(function(){windows.refreshEditor($(".bottom-window-group"))})},maxEditor:function(){var o=$(".toolbars .font-ico");windows.outerLayout.close("west"),windows.innerLayout.close("south"),windows.innerLayout.close("east"),o.removeClass("ico-max").addClass("ico-restore").attr("title",config.label.min),windows.isMaxEditor=!0},maxBottom:function(o){o.data("height",o.height()).addClass("bottom-window-group-max").find(".ico-min").hide(),windows.outerLayout.hide("west"),windows.innerLayout.hide("east"),windows.innerLayout.sizePane("south",$(".content").height())},maxSide:function(o){o.data("width",o.width()).addClass("side-max").find(".ico-min").hide(),$(".content").hide(),windows.outerLayout.sizePane("west",$("body").width())},maxSideRight:function(o){o.addClass("side-right-max").data("width",o.width()).find(".ico-min").hide(),windows.outerLayout.hide("west"),windows.innerLayout.hide("south"),windows.innerLayout.sizePane("east",$("body").width())},toggleEditor:function(){$(".toolbars .font-ico").hasClass("ico-restore")?windows.restoreEditor():windows.maxEditor()},restoreBottom:function(){var o=$(".bottom-window-group");o.removeClass("bottom-window-group-max").find(".ico-min").show(),windows.outerLayout.show("west"),windows.innerLayout.show("east"),windows.innerLayout.sizePane("south",o.data("height"))},restoreSide:function(){var o=$(".side");o.removeClass("side-max").find(".ico-min").show(),$(".content").show(),windows.outerLayout.sizePane("west",o.data("width"))},restoreSideRight:function(){var o=$(".side-right");o.removeClass("side-right-max").find(".ico-min").show(),windows.outerLayout.show("west"),windows.innerLayout.show("south"),windows.innerLayout.sizePane("east",o.data("width"))},restoreEditor:function(){windows.outerLayout.open("west"),windows.innerLayout.open("south"),windows.innerLayout.open("east"),windows.isMaxEditor=!1,$(".toolbars .font-ico").addClass("ico-max").removeClass("ico-restore").attr("title",config.label.max_editor)},refreshEditor:function(o,e){var t=editors.data,i=$(".content").height()-o.height()-24;switch(e){case"close":i=$(".content").height()-40}for(var n=0,s=t.length;n<s;n++)t[n].editor.setSize("100%",i);$(".bottom-window-group .search").height($(".bottom-window-group .tabs-panel").height())},flowBottom:function(){windows.innerLayout.south.state.isClosed&&windows.innerLayout.slideOpen("south")}};
var hotkeys={defaultKeyMap:{goEditor:{ctrlKey:!0,altKey:!1,shiftKey:!1,which:48,fun:function(){wide.curEditor&&wide.curEditor.focus()}},goFileTree:{ctrlKey:!0,altKey:!1,shiftKey:!1,which:49,fun:function(){windows.outerLayout.west.state.isClosed&&windows.outerLayout.slideOpen("west"),$("#files").focus()}},goOutline:{ctrlKey:!0,altKey:!1,shiftKey:!1,which:50,fun:function(){windows.innerLayout.east.state.isClosed&&windows.innerLayout.slideOpen("east"),$("#outline").focus()}},goOutput:{ctrlKey:!0,altKey:!1,shiftKey:!1,which:52,fun:function(){bottomGroup.tabs.setCurrent("output"),windows.flowBottom(),$(".bottom-window-group .output").focus()}},goSearch:{ctrlKey:!0,altKey:!1,shiftKey:!1,which:53,fun:function(){bottomGroup.tabs.setCurrent("search"),windows.flowBottom(),$(".bottom-window-group .search").focus()}},goNotification:{ctrlKey:!0,altKey:!1,shiftKey:!1,which:54,fun:function(){bottomGroup.tabs.setCurrent("notification"),windows.flowBottom(),$(".bottom-window-group .notification").focus()}},clearWindow:{ctrlKey:!1,altKey:!0,shiftKey:!1,which:67},changeEditor:{ctrlKey:!0,altKey:!1,shiftKey:!1,which:68},search:{ctrlKey:!0,altKey:!1,shiftKey:!1,which:70},closeCurEditor:{ctrlKey:!0,altKey:!1,shiftKey:!1,which:81},rename:{ctrlKey:!0,altKey:!1,shiftKey:!1,which:82},goFile:{ctrlKey:!1,altKey:!0,shiftKey:!0,which:79},build:{ctrlKey:!1,altKey:!1,shiftKey:!1,which:116},buildRun:{ctrlKey:!1,altKey:!1,shiftKey:!1,which:117}},bindList:function(e,o,d){o.data("index",0),e.keydown(function(e){var t=o.data("index"),i=o.find("li").length;if(0===i)return!0;38===e.which&&--t<0&&(t=i-1),40===e.which&&i-1<++t&&(t=0);var r=o.find("li:eq("+t+")");return 13===e.which&&d(r),o.find("li").removeClass("selected"),o.data("index",t),r.addClass("selected"),0===t?o.scrollTop(0):r[0].offsetTop+o.scrollTop()>o.height()?40===e.which?o.scrollTop(o.scrollTop()+r.height()):o.scrollTop(r[0].offsetTop):o.scrollTop(0),38!==e.which&&40!==e.which&&13!==e.which&&void 0})},_bindOutput:function(){$(".bottom-window-group .output").keydown(function(e){var t=hotkeys.defaultKeyMap;if(e.altKey===t.clearWindow.altKey&&e.which===t.clearWindow.which)return bottomGroup.clear("output"),void e.preventDefault()})},_bindFileTree:function(){$("#files").keydown(function(e){e.preventDefault();var t=hotkeys.defaultKeyMap;if(e.ctrlKey!==t.search.ctrlKey||e.which!==t.search.which)if(e.ctrlKey!==t.rename.ctrlKey||e.which!==t.rename.which)switch(e.which){case 46:tree.removeIt();break;case 13:if(!wide.curNode)return!1;if(tree.isDir()){if(wide.curNode.open)return!1;tree.fileTree.expandNode(wide.curNode,!0,!1,!0),$("#files").focus();break}tree.openFile(wide.curNode);break;case 38:var i={};if(wide.curNode){if(wide.curNode&&wide.curNode.isFirstNode&&0===wide.curNode.level)return!1;i=wide.curNode.getPreNode(),wide.curNode.isFirstNode&&wide.curNode.getParentNode()&&(i=wide.curNode.getParentNode());var r=wide.curNode.getPreNode();r&&tree.isDir()&&r.open&&(i=tree.getCurrentNodeLastNode(r))}else i=tree.fileTree.getNodeByTId("files_1");wide.curNode=i,tree.fileTree.selectNode(i),$("#files").focus();break;case 40:i={};if(wide.curNode){if(wide.curNode&&tree.isBottomNode(wide.curNode))return!1;i=wide.curNode.getNextNode(),tree.isDir()&&wide.curNode.open&&(i=wide.curNode.children[0]);var o=tree.getNextShowNode(wide.curNode);wide.curNode.isLastNode&&0!==wide.curNode.level&&!wide.curNode.open&&o&&(i=o)}else i=tree.fileTree.getNodeByTId("files_1");i&&(wide.curNode=i,tree.fileTree.selectNode(i)),$("#files").focus();break;case 37:if(!wide.curNode)return wide.curNode=tree.fileTree.getNodeByTId("files_1"),tree.fileTree.selectNode(wide.curNode),$("#files").focus(),!1;if(!tree.isDir()||!wide.curNode.open)return!1;tree.fileTree.expandNode(wide.curNode,!1,!1,!0),$("#files").focus();break;case 39:if(!wide.curNode)return wide.curNode=tree.fileTree.getNodeByTId("files_1"),tree.fileTree.selectNode(wide.curNode),$("#files").focus(),!1;if(!tree.isDir()||wide.curNode.open)return!1;tree.fileTree.expandNode(wide.curNode,!0,!1,!0),$("#files").focus();break;case 116:if(!wide.curNode||!tree.isDir())return!1;tree.refresh(wide.curNode)}else wide.curNode.removable&&$("#dialogRenamePrompt").dialog("open");else $("#dialogSearchForm").dialog("open")})},_bindDocument:function(){var l=this.defaultKeyMap;$(document).keydown(function(e){if(e.ctrlKey===l.goEditor.ctrlKey&&e.which===l.goEditor.which)return l.goEditor.fun(),void e.preventDefault();if(e.ctrlKey===l.goFileTree.ctrlKey&&e.which===l.goFileTree.which)return l.goFileTree.fun(),void e.preventDefault();if(e.ctrlKey===l.goOutline.ctrlKey&&e.which===l.goOutline.which)return l.goOutline.fun(),void e.preventDefault();if(e.ctrlKey===l.goOutput.ctrlKey&&e.which===l.goOutput.which)return l.goOutput.fun(),void e.preventDefault();if(e.ctrlKey===l.goSearch.ctrlKey&&e.which===l.goSearch.which)return l.goSearch.fun(),void e.preventDefault();if(e.ctrlKey===l.goNotification.ctrlKey&&e.which===l.goNotification.which)return l.goNotification.fun(),void e.preventDefault();if(e.ctrlKey===l.closeCurEditor.ctrlKey&&e.which===l.closeCurEditor.which)return $(".edit-panel .tabs > div.current").find(".ico-close").click(),void e.preventDefault();if(e.ctrlKey!==l.changeEditor.ctrlKey||e.which!==l.changeEditor.which)return e.which===l.build.which?(menu.build(),void e.preventDefault()):e.which===l.buildRun.which?(menu.run(),void e.preventDefault()):void(e.ctrlKey===l.goFile.ctrlKey&&e.altKey===l.goFile.altKey&&e.shiftKey===l.goFile.shiftKey&&e.which===l.goFile.which&&$("#dialogGoFilePrompt").dialog("open"));if("notification"===document.activeElement.className||"output"===document.activeElement.className||"search"===document.activeElement.className){for(var t=["output","search","notification"],i="",r=0,o=t.length;r<o;r++)if(bottomGroup.tabs.getCurrentId()===t[r]){i=r<o-1?t[r+1]:t[0];break}return bottomGroup.tabs.setCurrent(i),$(".bottom-window-group ."+i).focus(),e.preventDefault(),!1}if(1<editors.data.length){for(i="",r=0,o=editors.data.length;r<o;r++){var d=editors.getCurrentId();if(d&&d===editors.data[r].id){wide.curEditor=r<o-1?(i=editors.data[r+1].id,editors.data[r+1].editor):(i=editors.data[0].id,editors.data[0].editor);break}}editors.tabs.setCurrent(i);var c=tree.getTIdByPath(i);wide.curNode=tree.fileTree.getNodeByTId(c),tree.fileTree.selectNode(wide.curNode),wide.refreshOutline();var u=wide.curEditor.getCursor();$(".footer .cursor").text("| "+(u.line+1)+":"+(u.ch+1)+" |"),wide.curEditor.focus()}return e.preventDefault(),!1})},init:function(){this._bindFileTree(),this._bindOutput(),this._bindDocument()}};
var bottomGroup={tabs:void 0,searchTab:void 0,init:function(){this._initTabs(),this._initFrame(),$(".bottom-window-group .output").click(function(){$(this).focus()}),$(".bottom-window-group .output").on("click",".path",function(t){var o=$(this),i=tree.getTIdByPath(o.data("path"));return tree.openFile(tree.fileTree.getNodeByTId(i),CodeMirror.Pos(o.data("line")-1,o.data("column")-1)),t.preventDefault(),!1})},_initFrame:function(){$(".bottom-window-group .output").parent().mouseup(function(t){if(t.stopPropagation(),0!==t.button){var o=t.screenX,i=$(this);"auto"!==$(".side").css("left")&&"0px"!==$(".side").css("left")||(o=t.screenX-$(".side").width()),$(".bottom-window-group .frame").show().css({left:o+"px",top:t.offsetY+t.target.offsetTop-i.scrollTop()-10+"px"})}else $(".bottom-window-group .frame").hide()})},clear:function(t){$(".bottom-window-group ."+t+" > div").text("")},resetOutput:function(){this.clear("output"),bottomGroup.tabs.setCurrent("output"),windows.flowBottom()},_initTabs:function(){this.tabs=new Tabs({id:".bottom-window-group",clickAfter:function(t){this._$tabsPanel.find("."+t).focus()}})},fillOutput:function(t){var o=$(".bottom-window-group .output");-1!==(t=(t=t.replace(/\r/g,"")).replace(/\n/g,"<br/>")).indexOf("<br/>")&&(t=Autolinker.link(t)),o.find("div").html(t),o.parent().scrollTop(o[0].scrollHeight)}};
//# sourceMappingURL=wide.min.js.map