/* * Copyright (c) 2014-2019, b3log.org & hacpai.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ 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('
'+t.title+'
'),e.append('
'+t.content+"
"),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
"+o.title+"
";o.hideFooter||(o.hiddenOk||(r=""),r+="");var h="
"+c+"
"+r+"
",g="";o.modal&&0===p("."+l.background).length&&(g="
");p("#"+i).wrap("
");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 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 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+" "+e+". "+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 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 '+config.label.start_page+"",content:'
',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(e,t){var o=e.articles;if(0!==o.length){var i=o.length;9边看边练",a=0;a"+n.articleTitle+"  "+s(n.articleCreateTime,"yyyy-MM-dd")}$("#startPage .news").html(r+"")}}})}})},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 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:config.context+"/autocomplete",data:JSON.stringify(n),dataType:"json",success:function(e){var t=e[1];if(t)for(var o=0;o'+t[o].name+" "+t[o].type+"";break;case"const":i=''+t[o].name+" "+t[o].type+"";break;case"var":i=''+t[o].name+" "+t[o].type+"";break;case"package":i=''+t[o].name+" "+t[o].type+"";break;case"func":i=''+t[o].name+""+t[o].type.substring(4)+"",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:config.context+"/exprinfo",data:JSON.stringify(o),dataType:"json",success:function(e){if(e.succ){var t=wide.curEditor.cursorCoords();$("body").append('
'+e.data+"
")}}})},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: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='
    ',r=(o=o.toLowerCase(),0),a=e.length;r"+p+""),n+=e[r].contents[0].substring(d-s[c].length,d)+p}i+='
  • '+n+"    "+e[r].path+' ('+e[r].line+":"+e[r].ch+")
  • "}0===e.length&&(i+="
  • "+config.label.search_no_match+"
  • "),i+="
";var f=$(".bottom-window-group .search"),g=config.label.find_usages;"founds"===t&&(g=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(g)):(f.find(".tabs").show(),bottomGroup.searchTab.add({id:"search"+(new Date).getTime(),title:g,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:''+wide.curNode.name+"",content:''}),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();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 table"),i="";n.cmd&&"init-notification"===n.cmd?console.log("[notification onmessage]"+o.data):(i+=''+n.severity+''+n.message+''+n.type+"",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 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&&(e.getParentNode()?!!e.getParentNode().isLastNode&&tree.isBottomNode(e.getParentNode()):!!e.isLastNode)},getTIdByPath:function(e){for(var t=tree.fileTree.transformToArray(tree.fileTree.getNodes()),i=0,o=t.length;i$(".content").height()&&(o=o-r.height()-25),r.css({top:o+"px",left:e.clientX+"px",display:"block"}).show(),n.hide()}else{wide.curNode.removable?n.find(".remove").removeClass("disabled"):n.find(".remove").addClass("disabled"),-1===wide.curNode.path.indexOf("zip",wide.curNode.path.length-"zip".length)?n.find(".decompress").hide():n.find(".decompress").show(),-1===wide.curNode.path.indexOf("go",wide.curNode.path.length-"go".length)?n.find(".linux64").hide():n.find(".linux64").show();var o=e.clientY-10;n.height()+o>$(".content").height()&&(o=o-n.height()-25),n.css({top:o+"px",left:e.clientX+"px",display:"block"}).show(),r.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"),t,e.data.children),session.restore()}}}),this._initSearch(),this._initRename()},openFile:function(o,e){wide.curNode=o;for(var r=e,t=0,i=editors.data.length;t 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 t=newWideRequest();wide.curNode?t.dir=wide.curNode.path:t.dir="",t.text=$("#dialogSearchForm > input:eq(0)").val(),t.extension=$("#dialogSearchForm > input:eq(1)").val(),$.ajax({type:"POST",url:config.context+"/file/search/text",data:JSON.stringify(t),dataType:"json",success:function(e){e.succ&&($("#dialogSearchForm").dialog("close"),editors.appendSearch(e.data,"founds",t.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){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:config.context+"/outline",data:JSON.stringify(e),dataType:"json",success:function(e){if(e.succ){for(var t=e.data,o='
    ',i=["constDecls","varDecls","funcDecls","structDecls","interfaceDecls","typeDecls"],a=0,n=i.length;a '+s.Name+""}$("#outline").html(o+"
"),$("#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){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:config.context+"/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:config.context+"/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: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;i'+l+'    '+n+"":'
  • '+l+'    '+n+"
  • "}$("#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);(goLintFound&&(goLintFound=[]),"run"===t.nextCmd)&&((c=newWideRequest()).executable=t.executable,$.ajax({type:"POST",url:config.context+"/run",data:JSON.stringify(c),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+"")):bottomGroup.fillOutput(o+"
    "+t.output+"
    "),wide.curProcessId=t.pid;break;case"run-done":bottomGroup.fillOutput($(".bottom-window-group .output > div").html().replace(/<\/pre>$/g,t.output+"")),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 i={},a=0;a ul > li").unbind().removeClass("selected"),menu.subMenu())}),window.onbeforeunload=function(){if(0 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: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(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:config.context+"/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(),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 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: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,o=config.latestSessionContent.currentFile,n="",s=[],i=tree.fileTree.transformToArray(tree.fileTree.getNodes()),r=0,a=i.length;r'+("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"))+''+e+"",$(".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),i=wide.getClassBySuffix(n.split(".")[1]);t.type&&"f"===t.type?tree.fileTree.addNodes(o,[{id:t.path,name:n,iconSkin:i,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 r=tree.fileTree.transformToArray(o),a=0,d=r.length;a'+("Disconnected from server, trying to reconnect it [sid="+config.wideSessionId+"]")+''+t+"",$(".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",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.qqz="https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url="+t+"&sharesource=qzone&title="+o+"&pics="+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+""+e.wideVersion+"")}})}})})},disabled:function(e){for(var t=0,a=e.length;t 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 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:config.context+"/logout",data:JSON.stringify(e),dataType:"json",success:function(e){e.succ&&(window.location.href=config.context+"/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(),$("#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: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 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 n=$("#dialogPreference").closest(".dialog-main").find(".dialog-footer > button:eq(0)");if(t?n.prop("disabled",!1):n.prop("disabled",!0),0===a.length)$("#dialogPreference").find(".tip").html(""),n.prop("disabled",!1);else{for(var i=0,o=a.length;i div[data-index="'+l+'"]').text()+"] -> ["+r.substr(0,r.length-1)+"]: "+config.label.no_empty+"
    "}$("#dialogPreference").find(".tip").html(e),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(){$("#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]"),g=t.find("input[name=email]"),p=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]"),x=t.find("input[name=editorTabSize]"),y=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(),email:g.val(),locale:p.val(),theme:v.val(),editorFontFamily:m.val(),editorFontSize:h.val(),editorLineHeight:b.val(),editorTheme:w.val(),editorTabSize:x.val(),keymap:y.val()}),config.keymap!==y.val()&&window.location.reload(),$.ajax({type:"POST",url:config.context+"/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()),g.data("value",g.val()),p.data("value",p.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()),x.data("value",x.val()),y.data("value",y.val()),config.keymap=y.val(),$("#dialogPreference").closest(".dialog-main").find(".dialog-footer > button:eq(0)").prop("disabled",!0),$("#themesLink").attr("href",config.staticServer+"/static/css/themes/"+v.val()+".css"),config.editorTheme=w.val();for(var n=0,i=editors.data.length;no.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 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,"
    ")).indexOf("
    ")&&(t=Autolinker.link(t)),o.find("div").html(t),o.parent().scrollTop(o[0].scrollHeight)}}; //# sourceMappingURL=wide.min.js.map