2015-12-15 18:12:54 +03:00
|
|
|
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)
|
2017-04-23 19:10:16 +03:00
|
|
|
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.getMillis
|
2015-12-15 18:12:54 +03:00
|
|
|
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(
|
|
|
|
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")
|
|
|
|
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]")}}};
|
2017-03-27 16:31:35 +03:00
|
|
|
var menu={init:function(){this.subMenu(),this._initPreference(),this._initAbout(),this._initShare(),$(".menu .frame li").click(function(){$(".menu > ul > li").unbind().removeClass("selected"),menu.subMenu()})},_initShare:function(){$(".menu .ico-share").hover(function(){$(".menu .share-panel").show()}),$(".share-panel .font-ico").click(function(){var e=$(this).attr("class").split("-")[2],t="https://wide.b3log.org",a="https://wide.b3log.org/static/images/wide-logo.png",i={};i.email="mailto:?subject="+$("title").text()+"&body="+$("meta[name=description]").attr("content")+" "+t;var n=encodeURIComponent($("meta[name=description]").attr("content")+" "+t+" #golang");i.twitter="https://twitter.com/intent/tweet?status="+n,i.facebook="https://www.facebook.com/sharer/sharer.php?u="+t,i.googleplus="https://plus.google.com/share?url="+t;var o=encodeURIComponent($("title").text()+". \n"+$("meta[name=description]").attr("content")+" #golang#");i.weibo="http://v.t.sina.com.cn/share/share.php?title="+o+"&url="+t+"&pic="+a,i.tencent="http://share.v.t.qq.com/index.php?c=share&a=index&title="+o+"&url="+t+"&pic="+a,window.open(i[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,i=editors.data[e].editor;"text/x-go"===i.getOption("mode")?wide.fmt(a,i):wide._save(a,i)}},closeAllFiles:function(){if($(".menu li.close-all").hasClass("disabled"))return!1;var 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=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
|
2016-02-20 09:44:46 +03:00
|
|
|
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
|
2015-12-15 18:12:54 +03:00
|
|
|
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)retu
|
2017-03-15 18:37:52 +03:00
|
|
|
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(/\r/g,""),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)}};
|
2015-12-15 18:12:54 +03:00
|
|
|
//# sourceMappingURL=wide.min.js.map
|