wide/static/js/wide.min.js

13 lines
71 KiB
JavaScript

var Tabs=function(t){t._$tabsPanel=$(t.id+" > .tabs-panel"),t._$tabs=$(t.id+" > .tabs"),t._stack=[],this.obj=t,this.obj.STACKSIZE=64,this._init(t);var e=this;$(t.id+" > .tabs > div").each(function(){var i=$(this).data("index");t._stack.length===e.obj.STACKSIZE&&t._stack.splice(0,1),t._stack[t._stack.length-1]!==i&&e.obj._stack.push(i)})};$.extend(Tabs.prototype,{_init:function(t){var e=this;t._$tabs.on("click","div",function(i){if($(this).hasClass("current"))return!1;var r=$(this).data("index");e.setCurrent(r),"function"==typeof t.clickAfter&&t.clickAfter(r)}),t._$tabs.on("click",".ico-close",function(i){var r=$(this).parent().data("index"),a=!0;"function"==typeof t.removeBefore&&(a=t.removeBefore(r)),a&&e.del(r),i.stopPropagation()})},_hasId:function(t){var e=this.obj._$tabs;return 0===e.find('div[data-index="'+t+'"]').length?!1:!0},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,i=this.obj._$tabs;i.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=this.obj._$tabsPanel,i=this.obj._$tabs,r=this.obj._stack,a=null;i.children("div[data-index='"+t+"']").remove(),e.children("div[data-index='"+t+"']").remove();for(var n=0;n<r.length;n++)t===r[n]&&(r.splice(n,1),n--);a=r[r.length-1],"function"==typeof this.obj.removeAfter&&this.obj.removeAfter(t,a),this.setCurrent(a)},getCurrentId:function(){var t=this.obj._$tabs;return t.children(".current").data("index")},setCurrent:function(t){if(!t)return!1;var e=this.obj._$tabsPanel,i=this.obj._$tabs,r=i.children(".current");if(r.data("index")===t)return!1;var a=this.obj._stack;a.length===this.obj.STACKSIZE&&a.splice(0,1),a[a.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 s=tree.getTIdByPath(n),d=tree.fileTree.getNodeByTId(s);tree.fileTree.selectNode(d),wide.curNode=d;for(var o=0,c=editors.data.length;c>o;o++)if(editors.data[o].id===n){wide.curEditor=editors.data[o].editor;break}if(wide.curEditor){var h=wide.curEditor.getCursor();wide.curEditor.setCursor(h),wide.curEditor.focus(),wide.refreshOutline(),$(".footer .cursor").text("| "+(h.line+1)+":"+(h.ch+1)+" |")}}}});
!function(t){t.fn.extend({dialog:{version:"0.0.1.7",author:"lly219@gmail.com"}});var e=(new Date).getTime(),i="dialog",o=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"}}};t.extend(o.prototype,{_attach:function(e,o){e.id||(this.uuid++,e.id="dp"+this.uuid);var n=this._newInst(t(e));n.settings=t.extend({},o||{}),t.data(e,i,n),this._init(e)},_newInst:function(t){var e=t[0].id.replace(/([^A-Za-z0-9_])/g,"\\\\$1");return{id:e}},_getInst:function(e){try{return t.data(e,i)}catch(o){throw"Missing instance data for this dialog"}},_destroyDialog:function(e){var o=t.dialog._getInst(e),n=o.id;t.removeData(e,i),t(e).prependTo("#"+n+"Wrap").unwrap(),t(e).removeAttr("style");var a=this._getDefaults(t.dialog._defaults,o.settings,"styleClass");t("."+a.background).remove(),t("#"+n+"Dialog").remove()},_init:function(e){var i=this._getInst(e),o=i.id,n=i.settings,a=t(window).height(),l=t(window).width(),s=this._getDefaults(t.dialog._defaults,n,"styleClass"),d=n.height?n.height:parseInt(.6*a),r=n.width?n.width:parseInt(.6*l);n.title=n.title?n.title:"",n.okText=n.okText?n.okText:"Ok",n.cancelText=n.cancelText?n.cancelText:"Cancel";var c="",h="<div class='"+s.headerBg+"'><div class='"+s.title+"'>"+n.title+"</div><a href='javascript:void(0);' class='ico-close font-ico "+s.closeIcon+"'></a></div>";n.hideFooter||(n.hiddenOk||(c="<button>"+n.okText+"</button>"),c+="<button>"+n.cancelText+"</button>");var g="<div id='"+o+"Dialog' class='"+s.panel+"' style='width: "+r+"px;' onselectstart='return false;'>"+h+"<div class='"+s.main+"'><div style='overflow: auto; height: "+d+"px;'></div><div class='"+s.footer+"'>"+c+"</div></div>",u="";if(n.modal&&0===t("."+s.background).length){var f=a<document.documentElement.scrollHeight?document.documentElement.scrollHeight:a;u="<div style='height:"+f+"px;' class='"+s.background+"'></div>"}t("#"+o).wrap("<div id='"+o+"Wrap'></div>");var v=t(e).clone(!0);t(e).remove(),t("body").append(u+g),t(t("#"+o+"Dialog ."+s.main+" div").get(0)).append(v),t(v).show(),t("#"+o+"Dialog ."+s.closeIcon).bind("click",function(){t.dialog._close(o,n)});var p=t("#"+o+"Dialog ."+s.footer+" button");t(p.get(1)).bind("click",function(){t.dialog._close(o,n)}),t(p.get(0)).bind("click",function(){(void 0===n.ok||n.ok())&&t.dialog._close(o,n)}),this._bindMove(o,s.headerBg,d,r),t(window).keyup(function(e){27===e.keyCode&&t.dialog._close(o,n)}),t(window).resize(function(){var e=t("body").height()>t(window).height()?t("body").height():t(window).height();t(".dialog-background").height(e)}),"function"==typeof n.afterInit&&n.afterInit()},_bindMove:function(e,i){t("#"+e+"Dialog ."+i).mousedown(function(i){var o=document;i||(i=window.event);var n=document.getElementById(e+"Dialog"),a=i.clientX-parseInt(n.style.left),l=i.clientY-parseInt(n.style.top);o.ondragstart="return false;",o.onselectstart="return false;",o.onselect="document.selection.empty();",this.setCapture?this.setCapture():window.captureEvents&&window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP),o.onmousemove=function(e){e||(e=window.event);var i=e.clientX-a,o=e.clientY-l;0>i&&(i=0),i>t(window).width()-t(n).width()&&(i=t(window).width()-t(n).width()),o>t(window).height()-t(n).height()&&(o=t(window).height()-t(n).height()),0>o&&(o=0),n.style.left=i+"px",n.style.top=o+"px"},o.onmouseup=function(){this.releaseCapture?this.releaseCapture():window.captureEvents&&window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP),o.onmousemove=null,o.onmouseup=null,o.ondragstart=null,o.onselectstart=null,o.onselect=null}})},_close:function(e,i){if("none"!==t("#"+e+"Dialog").css("display")&&(void 0===i.close||i.close())&&(t("#"+e+"Dialog").hide(),i.modal)){var o=this._getDefaults(t.dialog._defaults,i,"styleClass");t("."+o.background).hide()}},_closeDialog:function(e){var i=this._getInst(e),o=i.id,n=i.settings;t.dialog._close(o,n)},_openDialog:function(e,i){var o=this._getInst(e),n=o.id,a=o.settings,l="",s="",d=t("#"+n+"Dialog"),r=t(window).height(),c=t(window).width(),h=a.height?a.height:parseInt(.6*r),g=a.width?a.width:parseInt(.6*c);if(a.position?(l=a.position.top,s=a.position.left):(l=parseInt((r-h-43)/2),0>l&&(l=0),s=parseInt((c-g)/2)),d.css({top:l+"px",left:s+"px"}).show(),a.modal){var u=this._getDefaults(t.dialog._defaults,a,"styleClass");t("."+u.background).show()}"function"==typeof a.afterOpen&&a.afterOpen(i),t("#"+n+"Dialog .dialog-footer button:eq(0)").focus()},_updateDialog:function(e,i){var o=this._getInst(e),n=o.id,a=o.settings,l=this._getDefaults(t.dialog._defaults,a,"styleClass");t.extend(a,i);var s=t("#"+n+"Dialog");i.position&&s.css({top:i.position.top,left:i.position.left}),i.width&&(s.width(i.width+26),s.find("."+l.main+" div")[0].style.width=i.width+"px",s.find("."+l.headerBg).width(i.width+18)),i.height&&(s.find("."+l.main+" div")[0].style.height=i.height+"px"),i.title&&s.find("."+l.title).html(i.title),void 0!==i.modal&&(i.modal?t("."+l.background).show():t("."+l.background).hide()),void 0!==i.hideFooter&&(i.hideFooter?s.find("."+l.footer).hide():s.find("."+l.footer).show())},_getDefaults:function(t,e,i){if("styleClass"===i){if("default"===e.theme||void 0===e.theme)return t.styleClass;e.styleClass={};for(var o in 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]}}),t.fn.dialog=function(e){var i=Array.prototype.slice.call(arguments);return"string"==typeof e?(i.shift(),t.dialog["_"+e+"Dialog"].apply(t.dialog,[this[0]].concat(i))):this.each(function(){t.dialog._attach(this,e)})},t.dialog=new o,window["DP_jQuery_"+e]=t}(jQuery);
var editors={autocompleteMutex:!1,data:[],tabs:{},getEditorByPath:function(e){for(var t=0,o=editors.data.length;o>t;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 e=$(".edit-panel .frame").data("index"),t=[];if($(".edit-panel .tabs > div").each(function(o){e!==$(this).data("index")&&t.push($(this).data("index"))}),0===t.length)return!1;var o=t.splice(0,1);$("#dialogCloseEditor").data("removeData",t),$('.edit-panel .tabs > div[data-index="'+o+'"]').find(".ico-close").click()},_removeAllMarker:function(){var e=$("#dialogCloseEditor").data("removeData");if(e&&e.length>0){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){return"startPage"===e?(wide.curEditor=void 0,$(".footer .cursor").text(""),wide.refreshOutline(),!1):void 0},removeBefore:function(e){if("startPage"===e)return editors._removeAllMarker(),!0;for(var t=0,o=editors.data.length;o>t;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;i>o;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-get","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()?!1: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 e=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()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(o.getFullYear()+"").substr(4-RegExp.$1.length)));for(var r in 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(config.context+"/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(t,o){var i=t.articles;if(0!==i.length){var r=i.length;r>9&&(r=9);for(var n="<ul><li class='title'>"+config.label.community+"</li>",a=0;r>a;a++){var d=i[a];n+="<li><a target='_blank' href='"+d.articlePermalink+"'>"+d.articleTitle+"</a>&nbsp; <span class='date'>"+e(d.articleCreateTime,"yyyy-MM-dd")}$("#startPage .news").html(n+"</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(e){e=wide.curEditor;for(var t=/[\w$]+/,o=e.getCursor(),i=e.getLine(o.line),r=o.ch,n=r;n<i.length&&t.test(i.charAt(n));)++n;for(;r&&t.test(i.charAt(r-1));)--r;var a=newWideRequest();a.path=$(".edit-panel .tabs .current > span:eq(0)").attr("title"),a.code=e.getValue(),a.cursorLine=o.line,a.cursorCh=o.ch;var d=[];return editors.autocompleteMutex&&e.state.completionActive?void 0:(editors.autocompleteMutex=!0,$.ajax({async:!1,type:"POST",url:config.context+"/autocomplete",data:JSON.stringify(a),dataType:"json",success:function(t){var o=t[1];if(o)for(var i=0;i<o.length;i++){var r="",n=o[i].name;switch(o[i]["class"]){case"type":r='<span class="fn-clear"><span class="ico-type ico"></span><b>'+o[i].name+"</b> "+o[i].type+"</span>";break;case"const":r='<span class="fn-clear"><span class="ico-const ico"></span><b>'+o[i].name+"</b> "+o[i].type+"</span>";break;case"var":r='<span class="fn-clear"><span class="ico-var ico"></span><b>'+o[i].name+"</b> "+o[i].type+"</span>";break;case"package":r='<span class="fn-clear"><span class="ico-package ico"></span><b>'+o[i].name+"</b> "+o[i].type+"</span>";break;case"func":r='<span><span class="ico-func ico"></span><b>'+o[i].name+"</b>"+o[i].type.substring(4)+"</span>",n+="()";break;default:console.warn("Can't handle autocomplete ["+o[i]["class"]+"]")}d[i]={displayText:r,text:n}}e.doc.markClean(),$(".edit-panel .tabs .current > span:eq(0)").removeClass("changed")}}),setTimeout(function(){editors.autocompleteMutex=!1},20),{list:d,from:CodeMirror.Pos(o.line,r),to:CodeMirror.Pos(o.line,n)})}),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?CodeMirror.Pass:(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:config.context+"/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 n=i.line,a=r.line;a>=n;n++)(0!==r.ch||n!==a)&&(t+="\n"+e.getLine(n));var d=r.line;0===r.ch&&(d=r.line-1),e.replaceRange(t,CodeMirror.Pos(d));var s=d-i.line+1;e.setSelection(CodeMirror.Pos(i.line+s,i.ch),CodeMirror.Pos(r.line+s,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 n=i.line,a=r.line;a>=n;n++)(0!==r.ch||n!==a)&&(t+="\n"+e.getLine(n));var d=r.line;0===r.ch&&(d=r.line-1),e.replaceRange(t,CodeMirror.Pos(d)),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:config.context+"/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:config.context+"/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">',o=o.toLowerCase(),r=0,n=e.length;n>r;r++){for(var a="",d=e[r].contents[0].toLowerCase(),s=d.split(o),l=0,c=0,u=0,p=s.length;p>u;u++){l=c+s[u].length,c=l+o.length;var f=e[r].contents[0].substring(l,c);""!==f&&(f="<b>"+f+"</b>"),a+=e[r].contents[0].substring(l-s[u].length,l)+f}i+='<li title="'+e[r].path+'">'+a+"&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 g=$(".bottom-window-group .search"),h=config.label.find_usages;"founds"===t&&(h=config.label.search_text),0===g.find("ul").length?(bottomGroup.searchTab=new Tabs({id:".bottom-window-group .search",removeAfter:function(e,t){1===g.find("ul").length&&g.find(".tabs").hide()}}),g.on("click","li",function(){g.find("li").removeClass("selected"),$(this).addClass("selected")}),g.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 n=Math.floor(r.getScrollInfo().clientHeight/r.defaultTextHeight()/2),a=r.cursorCoords({line:i.line-n,ch:0},"local");r.scrollTo(0,a.top),wide.curEditor.focus()}),g.find(".tabs-panel > div").append(i),g.find(".tabs .first").text(h)):(g.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-get","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();return e?void wide.fmt(e,wide.curEditor):!1},"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(e){return e.doc.isClean()?void $(".edit-panel .tabs > div").each(function(){var t=$(this).find("span:eq(0)");t.attr("title")===e.options.path&&t.removeClass("changed")}):void $(".edit-panel .tabs > div").each(function(){var t=$(this).find("span:eq(0)");t.attr("title")===e.options.path&&t.addClass("changed")})}),r.on("keydown",function(e,t){if(!(t.altKey||t.ctrlKey||t.shiftKey)){var o=t.which;48>o||o>57&&65>o||o>90||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 n=Math.floor(wide.curEditor.getScrollInfo().clientHeight/wide.curEditor.defaultTextHeight()/2),a=wide.curEditor.cursorCoords({line:t.line-n,ch:0},"local");wide.curEditor.scrollTo(0,a.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),i=$(".bottom-window-group .notification > table"),t="";return n.cmd&&"init-notification"===n.cmd?void console.log("[notification onmessage]"+o.data):(t+='<tr><td class="severity">'+n.severity+'</td><td class="message">'+n.message+'</td><td class="type">'+n.type+"</td></tr>",i.append(t),void $(".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 t=e.children[e.children.length-1];return t.open?tree.getCurrentNodeLastNode(t):t},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?!1:e.getParentNode()?e.getParentNode().isLastNode?tree.isBottomNode(e.getParentNode()):!1:e.isLastNode?!0:!1},getTIdByPath:function(e){for(var t=tree.fileTree.transformToArray(tree.fileTree.getNodes()),i=0,o=t.length;o>i;i++)if(t[i].path===e)return t[i].tId},getOpenPaths:function(){for(var e=tree.fileTree.transformToArray(tree.fileTree.getNodes()),t=[],i=0,o=e.length;o>i;i++)e[i].open&&t.push(e[i].path);return t},getAllParents:function(e,t){return t||(t=[]),e&&e.parentTId?(t.push(e.getParentNode()),tree.getAllParents(e.getParentNode(),t)):t},isParents:function(e,t){var i=tree.fileTree.getNodeByTId(e);if(i&&i.parentTId){var o=tree.fileTree.getNodeByTId(i.parentTId);return i.path===t?!0:tree.isParents(o.tId,t)}return!1},isDir:function(){return 0===wide.curNode.iconSkin.indexOf("ico-ztree-dir")?!0:!1},newFile:function(e){return $(e).hasClass("disabled")?!1:void $("#dialogNewFilePrompt").dialog("open")},newDir:function(e){return $(e).hasClass("disabled")?!1:void $("#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){return e&&$(e).hasClass("disabled")?!1:void $("#dialogRenamePrompt").dialog("open")},"export":function(){var e=newWideRequest(),t=!1;e.path=wide.curNode.path,$.ajax({async:!1,type:"POST",url:config.context+"/file/zip/new",data:JSON.stringify(e),dataType:"json",success:function(e){return e.succ?void(t=!0):($("#dialogAlert").dialog("open",e.msg),!1)}}),t&&window.open(config.context+"/file/zip?path="+wide.curNode.path+".zip")},crossCompile:function(e){var t=newWideRequest();t.path=wide.curNode.path,t.platform=e,$.ajax({async:!1,type:"POST",url:config.context+"/cross",data:JSON.stringify(t),dataType:"json",success:function(e){return e.succ?void 0:($("#dialogAlert").dialog("open",e.msg),!1)}})},decompress:function(){var e=newWideRequest();e.path=wide.curNode.path,$.ajax({async:!1,type:"POST",url:config.context+"/file/decompress",data:JSON.stringify(e),dataType:"json",success:function(e){if(!e.succ)return $("#dialogAlert").dialog("open",e.msg),!1;var t=wide.curNode.getParentNode();tree.fileTree.reAsyncChildNodes(t,"refresh")}})},refresh:function(e){return e&&$(e).hasClass("disabled")?!1:void tree.fileTree.reAsyncChildNodes(wide.curNode,"refresh",!0)},gitClone:function(e){return e&&$(e).hasClass("disabled")?!1:void $("#dialogGitClonePrompt").dialog("open")},"import":function(){var e=newWideRequest();e.path=wide.curNode.path,$("#importFileupload").fileupload({url:"/file/upload?path="+e.path,dataType:"json",formData:e,done:function(e,t){tree.fileTree.reAsyncChildNodes(wide.curNode,"refresh")},fail:function(){console.log(arguments)}})},init:function(){$("#file").click(function(){$(this).focus()});var e=newWideRequest();$.ajax({type:"POST",url:config.context+"/files",data:JSON.stringify(e),dataType:"json",success:function(e){if(e.succ){var t=$("#dirRMenu"),i=$("#fileRMenu"),o={data:{key:{title:"path"}},view:{showTitle:!0,selectedMulti:!1},async:{enable:!0,url:config.context+"/file/refresh",autoParam:["path"]},callback:{onDblClick:function(e,t,i){i&&tree.openFile(i)},onRightClick:function(e,o,r){if(r&&!r.isGOAPI){if(menu.undisabled(["import","export","git-clone"]),wide.curNode=r,tree.fileTree.selectNode(r),tree.isDir()){wide.curNode.removable?t.find(".remove").removeClass("disabled"):t.find(".remove").addClass("disabled"),wide.curNode.creatable?t.find(".create").removeClass("disabled"):t.find(".create").addClass("disabled");var n=e.clientY-10;t.height()+n>$(".content").height()&&(n=n-t.height()-25),t.css({top:n+"px",left:e.clientX+"px",display:"block"}).show(),i.hide()}else{wide.curNode.removable?i.find(".remove").removeClass("disabled"):i.find(".remove").addClass("disabled"),-1===wide.curNode.path.indexOf("zip",wide.curNode.path.length-"zip".length)?i.find(".decompress").hide():i.find(".decompress").show(),-1===wide.curNode.path.indexOf("go",wide.curNode.path.length-"go".length)?i.find(".linux64").hide():i.find(".linux64").show();var n=e.clientY-10;i.height()+n>$(".content").height()&&(n=n-i.height()-25),i.css({top:n+"px",left:e.clientX+"px",display:"block"}).show(),t.hide(),menu.disabled(["import","git-clone"])}$("#files").focus()}},onClick:function(e,t,i,o){i&&(wide.curNode=i,tree.fileTree.selectNode(i),menu.undisabled(["import","export","git-clone"]),tree.isDir()||menu.disabled(["import","git-clone"]),$("#files").focus())}}};tree.fileTree=$.fn.zTree.init($("#files"),o,e.data.children),session.restore()}}}),this._initSearch(),this._initRename()},openFile:function(e,t){wide.curNode=e;for(var i=t,o=0,r=editors.data.length;r>o;o++)if(editors.data[o].id===e.path){editors.tabs.setCurrent(e.path),wide.curEditor=editors.data[o].editor,i||(i=wide.curEditor.getCursor()),$(".footer .cursor").text("| "+(i.line+1)+":"+(i.ch+1)+" |"),wide.curEditor.setCursor(i);var n=Math.floor(wide.curEditor.getScrollInfo().clientHeight/wide.curEditor.defaultTextHeight()/2),a=wide.curEditor.cursorCoords({line:i.line-n,ch:0},"local");return wide.curEditor.scrollTo(0,a.top),wide.curEditor.focus(),wide.refreshOutline(),!1}if(!tree.isDir()){var d=newWideRequest();d.path=e.path,$.ajax({async:!1,type:"POST",url:config.context+"/file",data:JSON.stringify(d),dataType:"json",success:function(t){if(!t.succ)return $("#dialogAlert").dialog("open",t.msg),!1;var o=t.data;if(!o.mode){var r=CodeMirror.findModeByFileName(e.path);r?o.mode=r.mime:o.mode="text/plain"}if(o.mode||console.error("Can't find mode by file name ["+e.path+"]"),"img"===o.mode){window.open(config.context+o.path);return!1}i||(i=CodeMirror.Pos(0,0)),editors.newEditor(o,i),wide.refreshOutline()}})}},_initSearch:function(){$("#dialogSearchForm > input:eq(0)").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)}),$("#dialogSearchForm > input:eq(1)").keyup(function(e){var t=$(this).closest(".dialog-main").find(".dialog-footer > button:eq(0)");13!==e.which||t.prop("disabled")||t.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 e=newWideRequest();wide.curNode?e.dir=wide.curNode.path:e.dir="",e.text=$("#dialogSearchForm > input:eq(0)").val(),e.extension=$("#dialogSearchForm > input:eq(1)").val(),$.ajax({type:"POST",url:config.context+"/file/search/text",data:JSON.stringify(e),dataType:"json",success:function(t){t.succ&&($("#dialogSearchForm").dialog("close"),editors.appendSearch(t.data,"founds",e.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(),t=newWideRequest();t.oldPath=wide.curNode.path,t.newPath=wide.curNode.path.substring(0,wide.curNode.path.lastIndexOf("/")+1)+e,$.ajax({type:"POST",url:config.context+"/file/rename",data:JSON.stringify(t),dataType:"json",success:function(e){return e.succ?void $("#dialogRenamePrompt").dialog("close"):($("#dialogRenamePrompt").dialog("close"),bottomGroup.tabs.setCurrent("notification"),windows.flowBottom(),$(".bottom-window-group .notification").focus(),!1)}})}})}};
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:config.context+"/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,n=i.length;n>a;a++)for(var l=i[a],r=0,c=t[l].length;c>r;r++){var s=t[l][r];o+='<li data-ch="'+s.Ch+'" data-line="'+s.Line+'"><span class="ico ico-'+l.replace("Decls","")+'"></span> '+s.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:config.context+"/file/remove",data:JSON.stringify(e),dataType:"json",success:function(e){return e.succ?void $("#dialogRemoveConfirm").dialog("close"):($("#dialogRemoveConfirm").dialog("close"),bottomGroup.tabs.setCurrent("notification"),windows.flowBottom(),$(".bottom-window-group .notification").focus(),!1)}})}}),$("#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 e=newWideRequest(),t=$("#dialogNewFilePrompt > input").val();e.path=wide.curNode.path+"/"+t,e.fileType="f",$.ajax({type:"POST",url:config.context+"/file/new",data:JSON.stringify(e),dataType:"json",success:function(t){return t.succ?($("#dialogNewFilePrompt").dialog("close"),void setTimeout(function(){var t=tree.getTIdByPath(e.path);tree.openFile(tree.fileTree.getNodeByTId(t)),tree.fileTree.selectNode(wide.curNode)},100)):($("#dialogNewFilePrompt").dialog("close"),bottomGroup.tabs.setCurrent("notification"),windows.flowBottom(),$(".bottom-window-group .notification").focus(),!1)}})}}),$("#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:config.context+"/file/new",data:JSON.stringify(t),dataType:"json",success:function(e){return e.succ?void $("#dialogNewDirPrompt").dialog("close"):($("#dialogNewDirPrompt").dialog("close"),bottomGroup.tabs.setCurrent("notification"),windows.flowBottom(),$(".bottom-window-group .notification").focus(),!1)}})}}),$("#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:config.context+"/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;a>i;i++){var n=t[i].path,l=n.substr(n.lastIndexOf("/")+1),r=wide.getClassBySuffix(l.split(".")[1]);o+=0===i?'<li data-index="'+i+'" class="selected" title="'+n+'"><span class="'+r+'ico"></span>'+l+'&nbsp;&nbsp;&nbsp;&nbsp;<span class="ft-small">'+n+"</span></li>":'<li data-index="'+i+'" title="'+n+'"><span class="'+r+'ico"></span>'+l+'&nbsp;&nbsp;&nbsp;&nbsp;<span class="ft-small">'+n+"</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()}}),$("#dialogGitClonePrompt").dialog({modal:!0,height:52,width:360,title:config.label.git_clone,okText:config.label.confirm,cancelText:config.label.cancel,afterOpen:function(){$("#dialogGitClonePrompt > input").val("").focus(),$("#dialogGitClonePrompt").closest(".dialog-main").find(".dialog-footer > button:eq(0)").prop("disabled",!0)},ok:function(){$("#dialogGitClonePrompt").dialog("close");var e=newWideRequest();e.path=wide.curNode.path,e.repository=$("#dialogGitClonePrompt > input").val(),$.ajax({type:"POST",url:config.context+"/git/clone",data:JSON.stringify(e),dataType:"json",success:function(e){}})}})},_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);if(goLintFound&&(goLintFound=[]),"run"===t.nextCmd){var o=newWideRequest();o.executable=t.executable,$.ajax({type:"POST",url:config.context+"/run",data:JSON.stringify(o),dataType:"json"})}switch(t.cmd){case"run":var i=$(".bottom-window-group .output > div").html();wide.curProcessId&&""!==i?bottomGroup.fillOutput(i.replace(/<\/pre>$/g,t.output+"</pre>")):bottomGroup.fillOutput(i+"<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":case"start-get":case"start-git_clone":bottomGroup.fillOutput(t.output);break;case"go test":case"go vet":case"go install":case"go get":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 a={},n=0;n<t.lints.length;n++){var l=t.lints[n];goLintFound.push({from:CodeMirror.Pos(l.lineNo,0),to:CodeMirror.Pos(l.lineNo,0),message:l.msg,severity:l.severity}),a[l.file]=l.file}$("#buildRun").removeClass("ico-stop").addClass("ico-buildrun").attr("title",config.label.build_n_run);for(var r in a){var c=editors.getEditorByPath(r);CodeMirror.signal(c,"change",c)}}else if("cross-build"===t.cmd){var o=newWideRequest(),r=null;o.path=t.executable,o.name=t.name,$.ajax({async:!1,type:"POST",url:config.context+"/file/zip/new",data:JSON.stringify(o),dataType:"json",success:function(e){return e.succ?void(r=e.data):($("#dialogAlert").dialog("open",e.msg),!1)}}),r&&window.open(config.context+"/file/zip?path="+r+".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){return 3===e.which?!1:($(".frame").hide(),void(1!==$(e.target).closest(".frame").length&&"frame"!==e.target.className&&($(".menu > ul > li").unbind().removeClass("selected"),menu.subMenu())))}),window.onbeforeunload=function(){return editors.data.length>0?config.label.confirm_save:void 0},document.oncontextmenu=function(){return!1},this._initDialog()},_save:function(e,t){if(!e)return!1;var o=newWideRequest();o.file=e,o.code=t.getValue(),$.ajax({type:"POST",url:config.context+"/file/save",data:JSON.stringify(o),dataType:"json",success:function(o){t.doc.markClean(),$(".edit-panel .tabs > div").each(function(){var t=$(this).find("span:eq(0)");t.attr("title")===e&&t.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:config.context+"/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:config.context+"/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(e,t){var o=t.getCursor(),i=t.getScrollInfo(),a=newWideRequest();a.file=e,a.code=t.getValue(),a.cursorLine=o.line,a.cursorCh=o.ch,$.ajax({async:!1,type:"POST",url:config.context+"/go/fmt",data:JSON.stringify(a),dataType:"json",success:function(a){a.succ&&(t.setValue(a.data.code),t.setCursor(o),t.scrollTo(null,i.top),wide._save(e,t))}})},fmt:function(e,t){var o=t.getOption("mode"),i=t.getCursor(),a=t.getScrollInfo(),n=newWideRequest();n.file=e,n.code=t.getValue(),n.cursorLine=i.line,n.cursorCh=i.ch;var l=null;switch(o){case"text/x-go":$.ajax({async:!1,type:"POST",url:config.context+"/go/fmt",data:JSON.stringify(n),dataType:"json",success:function(e){e.succ&&(l=e.data.code)}});break;case"text/html":l=html_beautify(t.getValue());break;case"text/javascript":case"application/json":l=js_beautify(t.getValue());break;case"text/css":l=css_beautify(t.getValue())}l&&(t.setValue(l),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 e=function(e){var t="normal";return e.isClosed?t="min":e.size>=$("body").width()&&(t="max"),t};setInterval(function(){var t=newWideRequest(),s=[],o=[],n=editors.getCurrentId(),r=n?editors.getCurrentPath():"";editors.tabs.obj._$tabs.find("div").each(function(){var e=$(this);e.find("span:eq(0)").attr("title")!==config.label.start_page&&s.push(e.find("span:eq(0)").attr("title"))}),o=tree.getOpenPaths(),t.currentFile=r,t.fileTree=o,t.files=s,t.layout={side:{size:windows.outerLayout.west.state.size,state:e(windows.outerLayout.west.state)},sideRight:{size:windows.innerLayout.east.state.size,state:e(windows.innerLayout.east.state)},bottom:{size:windows.innerLayout.south.state.size,state:e(windows.innerLayout.south.state)}},$.ajax({type:"POST",url:config.context+"/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,s=config.latestSessionContent.currentFile,o="",n=[],r=tree.fileTree.transformToArray(tree.fileTree.getNodes()),i=0,a=r.length;a>i;i++){for(var d=0,l=e.length;l>d;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;p>g;g++)c[g].open===!1&&(f=!1);f?tree.fileTree.expandNode(r[i],!0,!1,!0):r[i].open=!0;break}for(var h=0,u=t.length;u>h;h++)if(r[i].path===t[h]){n.push(r[i]);break}r[i].path===s&&(o=r[i].path,tree.fileTree.selectNode(r[i]),wide.curNode=r[i])}for(var y=0,v=t.length;v>y;y++)for(var w=0,m=n.length;m>w;w++)if(n[w].path===t[y]){tree.openFile(n[w]);break}editors.tabs.setCurrent(o);for(var b=0,p=editors.data.length;p>b;b++)if(o===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=function(e,t){var s=new Date(e),o={"M+":s.getMonth()+1,"d+":s.getDate(),"h+":s.getHours(),"m+":s.getMinutes(),"s+":s.getSeconds(),"q+":Math.floor((s.getMonth()+3)/3),S:s.getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(s.getFullYear()+"").substr(4-RegExp.$1.length)));for(var n in o)new RegExp("("+n+")").test(t)&&(t=t.replace(RegExp.$1,1===RegExp.$1.length?o[n]:("00"+o[n]).substr((""+o[n]).length)));return t},t={type:"Network",severity:"INFO",message:"Connected to server [sid="+config.wideSessionId+"], "+e((new Date).getTime(),"yyyy-MM-dd hh:mm:ss")},s=$(".bottom-window-group .notification > table"),o="";o+='<tr><td class="severity">'+t.severity+'</td><td class="message">'+t.message+'</td><td class="type">'+t.type+"</td></tr>",s.append(o)},e.onmessage=function(e){var t=JSON.parse(e.data);switch(t.cmd){case"create-file":var s=tree.fileTree.getNodeByTId(tree.getTIdByPath(t.dir)),o=t.path.replace(t.dir+"/",""),n=CodeMirror.findModeByFileName(o),r=wide.getClassBySuffix(o.split(".")[1]);t.type&&"f"===t.type?tree.fileTree.addNodes(s,[{id:t.path,name:o,iconSkin:r,path:t.path,mode:n,removable:!0,creatable:!0}]):tree.fileTree.addNodes(s,[{id:t.path,name:o,iconSkin:"ico-ztree-dir ",path:t.path,removable:!0,creatable:!0,isParent:!0}]);break;case"remove-file":case"rename-file":var s=tree.fileTree.getNodeByTId(tree.getTIdByPath(t.path));tree.fileTree.removeNode(s);for(var i=tree.fileTree.transformToArray(s),a=0,d=i.length;d>a;a++)editors.tabs.del(i[a].path)}},e.onclose=function(e){console.log("[session onclose] disconnected ("+e.code+")");var t={type:"Network",severity:"ERROR",message:"Disconnected from server, trying to reconnect it [sid="+config.wideSessionId+"]"},s=$(".bottom-window-group .notification > table"),o="";o+='<tr><td class="severity">'+t.severity+'</td><td class="message">'+t.message+'</td><td class="type">'+t.type+"</td></tr>",s.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",n={};n.email="mailto:?subject="+$("title").text()+"&body="+$("meta[name=description]").attr("content")+" "+t;var i=encodeURIComponent($("meta[name=description]").attr("content")+" "+t+" #golang");n.twitter="https://twitter.com/intent/tweet?status="+i,n.facebook="https://www.facebook.com/sharer/sharer.php?u="+t,n.googleplus="https://plus.google.com/share?url="+t;var o=encodeURIComponent($("title").text()+". \n"+$("meta[name=description]").attr("content")+" #golang#");n.weibo="http://v.t.sina.com.cn/share/share.php?title="+o+"&url="+t+"&pic="+a,n.tencent="http://share.v.t.qq.com/index.php?c=share&a=index&title="+o+"&url="+t+"&pic="+a,window.open(n[e],"_blank","top=100,left=200,width=648,height=618")})},_initAbout:function(){$("#dialogAbout").load(config.context+"/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;a>t;t++)$(".menu li."+e[t]).addClass("disabled")},undisabled:function(e){for(var t=0,a=e.length;a>t;t++)$(".menu li."+e[t]).removeClass("disabled")},subMenu:function(){$(".menu > ul > li").click(function(e){if(1!==$(e.target).closest(".frame").length){var t=$(this);t.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;t>e;e++){var a=editors.data[e].id,n=editors.data[e].editor;"text/x-go"===n.getOption("mode")?wide.fmt(a,n):wide._save(a,n)}},closeAllFiles:function(){if($(".menu li.close-all").hasClass("disabled"))return!1;var e=[];$(".edit-panel .tabs > div").each(function(t){0!==t&&e.push($(this).data("index"))}),$("#dialogCloseEditor").data("removeData",e),$(".edit-panel .tabs .ico-close:eq(0)").click()},exit:function(){var e=newWideRequest();$.ajax({type:"POST",url:config.context+"/logout",data:JSON.stringify(e),dataType:"json",success:function(e){e.succ&&(window.location.href="/login")}})},openAbout:function(){$("#dialogAbout").dialog("open")},goget:function(){menu.saveAllFiles();var e=editors.getCurrentPath();if(!e)return!1;if($(".menu li.go-get").hasClass("disabled"))return!1;var t=newWideRequest();t.file=e,$.ajax({type:"POST",url:config.context+"/go/get",data:JSON.stringify(t),dataType:"json",beforeSend:function(){bottomGroup.resetOutput()},success:function(e){}})},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:config.context+"/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:config.context+"/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:config.context+"/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:config.context+"/build",data:JSON.stringify(t),dataType:"json",beforeSend:function(){bottomGroup.resetOutput()},success:function(e){$("#buildRun").addClass("ico-stop").removeClass("ico-buildrun").attr("title",config.label.stop)}})},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:config.context+"/build",data:JSON.stringify(t),dataType:"json",beforeSend:function(){bottomGroup.resetOutput()},success:function(e){}})},_initPreference:function(){$("#dialogPreference").load(config.context+"/preference",function(){$("#dialogPreference input").keyup(function(){var e=!1,t=[],a="";$("#dialogPreference input").each(function(){var a=$(this);a.val()!=a.data("value")&&(e=!0),""===$.trim(a.val())&&t.push(a)});var n=$("#dialogPreference").closest(".dialog-main").find(".dialog-footer > button:eq(0)");if(e?n.prop("disabled",!1):n.prop("disabled",!0),0===t.length)$("#dialogPreference").find(".tip").html(""),n.prop("disabled",!1);else{for(var i=0,o=t.length;o>i;i++){var l=t[i].closest("div").data("index"),r=$.trim(t[i].parent().text());a+="["+$('#dialogPreference .tabs > div[data-index="'+l+'"]').text()+"] -> ["+r.substr(0,r.length-1)+"]: "+config.label.no_empty+"<br/>"}$("#dialogPreference").find(".tip").html(a),n.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(){var e=$("#dialogPreference").closest(".dialog-main").find(".dialog-footer > button:eq(0)");e.prop("disabled",!0)},ok:function(){var e=newWideRequest(),t=$("#dialogPreference"),a=t.find("input[name=fontFamily]"),n=t.find("input[name=fontSize]"),i=t.find("select[name=goFmt]"),o=t.find("input[name=workspace]"),l=t.find("input[name=password]"),r=t.find("input[name=email]"),s=t.find("select[name=locale]"),d=t.find("select[name=theme]"),u=t.find("input[name=editorFontFamily]"),c=t.find("input[name=editorFontSize]"),f=t.find("input[name=editorLineHeight]"),g=t.find("select[name=editorTheme]"),p=t.find("input[name=editorTabSize]"),v=t.find("select[name=keymap]");$.extend(e,{fontFamily:a.val(),fontSize:n.val(),goFmt:i.val(),workspace:o.val(),password:l.val(),email:r.val(),locale:s.val(),theme:d.val(),editorFontFamily:u.val(),editorFontSize:c.val(),editorLineHeight:f.val(),editorTheme:g.val(),editorTabSize:p.val(),keymap:v.val()}),config.keymap!==v.val()&&window.location.reload(),$.ajax({type:"POST",url:config.context+"/preference",data:JSON.stringify(e),success:function(e,t,m){if(!e.succ)return!1;a.data("value",a.val()),n.data("value",n.val()),i.data("value",i.val()),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()),g.data("value",g.val()),p.data("value",p.val()),v.data("value",v.val()),config.keymap=v.val();var h=$("#dialogPreference").closest(".dialog-main").find(".dialog-footer > button:eq(0)");h.prop("disabled",!0),$("#themesLink").attr("href",config.staticServer+"/static/css/themes/"+d.val()+".css"),config.editorTheme=g.val();for(var b=0,w=editors.data.length;w>b;b++)editors.data[b].editor.setOption("theme",g.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(){var o=$(".toolbars .font-ico");o.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;s>n;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,t,i){t.data("index",0),e.keydown(function(e){var r=t.data("index"),o=t.find("li").length;if(0===o)return!0;38===e.which&&(r--,0>r&&(r=o-1)),40===e.which&&(r++,r>o-1&&(r=0));var d=t.find("li:eq("+r+")");return 13===e.which&&i(d),t.find("li").removeClass("selected"),t.data("index",r),d.addClass("selected"),0===r?t.scrollTop(0):d[0].offsetTop+t.scrollTop()>t.height()?40===e.which?t.scrollTop(t.scrollTop()+d.height()):t.scrollTop(d[0].offsetTop):t.scrollTop(0),38===e.which||40===e.which||13===e.which?!1:void 0})},_bindOutput:function(){$(".bottom-window-group .output").keydown(function(e){var t=hotkeys.defaultKeyMap;return e.altKey===t.clearWindow.altKey&&e.which===t.clearWindow.which?(bottomGroup.clear("output"),void e.preventDefault()):void 0})},_bindFileTree:function(){$("#files").keydown(function(e){e.preventDefault();var t=hotkeys.defaultKeyMap;if(e.ctrlKey===t.search.ctrlKey&&e.which===t.search.which)return void $("#dialogSearchForm").dialog("open");if(e.ctrlKey===t.rename.ctrlKey&&e.which===t.rename.which)return void(wide.curNode.removable&&$("#dialogRenamePrompt").dialog("open"));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:var 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)}})},_bindDocument:function(){var e=this.defaultKeyMap;$(document).keydown(function(t){if(t.ctrlKey===e.goEditor.ctrlKey&&t.which===e.goEditor.which)return e.goEditor.fun(),void t.preventDefault();if(t.ctrlKey===e.goFileTree.ctrlKey&&t.which===e.goFileTree.which)return e.goFileTree.fun(),void t.preventDefault();if(t.ctrlKey===e.goOutline.ctrlKey&&t.which===e.goOutline.which)return e.goOutline.fun(),void t.preventDefault();if(t.ctrlKey===e.goOutput.ctrlKey&&t.which===e.goOutput.which)return e.goOutput.fun(),void t.preventDefault();if(t.ctrlKey===e.goSearch.ctrlKey&&t.which===e.goSearch.which)return e.goSearch.fun(),void t.preventDefault();if(t.ctrlKey===e.goNotification.ctrlKey&&t.which===e.goNotification.which)return e.goNotification.fun(),void t.preventDefault();if(t.ctrlKey===e.closeCurEditor.ctrlKey&&t.which===e.closeCurEditor.which)return $(".edit-panel .tabs > div.current").find(".ico-close").click(),void t.preventDefault();if(t.ctrlKey===e.changeEditor.ctrlKey&&t.which===e.changeEditor.which){if("notification"===document.activeElement.className||"output"===document.activeElement.className||"search"===document.activeElement.className){for(var i=["output","search","notification"],r="",o=0,d=i.length;d>o;o++)if(bottomGroup.tabs.getCurrentId()===i[o]){r=d-1>o?i[o+1]:i[0];break}return bottomGroup.tabs.setCurrent(r),$(".bottom-window-group ."+r).focus(),t.preventDefault(),!1}if(editors.data.length>1){for(var r="",o=0,d=editors.data.length;d>o;o++){var c=editors.getCurrentId();if(c&&c===editors.data[o].id){d-1>o?(r=editors.data[o+1].id,wide.curEditor=editors.data[o+1].editor):(r=editors.data[0].id,wide.curEditor=editors.data[0].editor);break}}editors.tabs.setCurrent(r);var u=tree.getTIdByPath(r);wide.curNode=tree.fileTree.getNodeByTId(u),tree.fileTree.selectNode(wide.curNode),wide.refreshOutline();var n=wide.curEditor.getCursor();$(".footer .cursor").text("| "+(n.line+1)+":"+(n.ch+1)+" |"),wide.curEditor.focus()}return t.preventDefault(),!1}return t.which===e.build.which?(menu.build(),void t.preventDefault()):t.which===e.buildRun.which?(menu.run(),void t.preventDefault()):void(t.ctrlKey===e.goFile.ctrlKey&&t.altKey===e.goFile.altKey&&t.shiftKey===e.goFile.shiftKey&&t.which===e.goFile.which&&$("#dialogGoFilePrompt").dialog("open"))})},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)return void $(".bottom-window-group .frame").hide();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"})})},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");t=t.replace(/\n/g,"<br/>"),-1!==t.indexOf("<br/>")&&(t=Autolinker.link(t)),o.find("div").html(t),o.parent().scrollTop(o[0].scrollHeight)}};
//# sourceMappingURL=wide.min.js.map