var MagicEditor = { init : function(){ this.config = {}; var skin = this.getValue('skin'); if(skin){ $('body').addClass('skin-' + skin); } this.addedGroups = {}; this.apiId = null; this.apiList = []; this.debugSessionId = null; this.defaultRequestValue = '{\r\n\t"request" : {\r\n\t\t"message" : "Hello MagicAPI!"\r\n\t},\r\n\t"path" : {\r\n\t\t"id" : "123456"\r\n\t},\r\n\t"body" : {\r\n\t\t"id" : "123456"\r\n\t},\r\n\t"header" : {\r\n\t\t"token" : "tokenValue"\r\n\t},\r\n\t"cookie" : {\r\n\t\t"cookieName" : "cookieValue"\r\n\t},\r\n\t"session" : {\r\n\t\t"userId" : "123"\r\n\t}\r\n}'; this.initMTA(); this.loadAPI(); this.initShortKey(); this.initSkin(); this.initLeftToobarContainer(); this.initBottomContainer(); this.initSelect(); this.initContextMenu(); this.initScriptEditor(); this.resetEditor(); this.checkUpdate(); var _this = this; $.getJSON('config.json',function(data){ _this.config = data; }) }, initSkin : function(){ var skinSelector = $('.skin-selector'); $('.button-skin').on('click',function(){ skinSelector.toggle(); return false; }); var $body = $('body'); $body.on('click',function(){ skinSelector.hide(); }) var _this = this; skinSelector.on('click','li',function(){ skinSelector.hide(); $(this).siblings().each(function(){ $body.removeClass('skin-' + $(this).text()) }) _this.setSkin($(this).text()); }) }, resetEditor : function(){ $('input[name=group]').val('未分组'); $('input[name=method]').val('GET'); $('input[name=name]').val(''); $('input[name=path]').val(''); $('input[name=prefix]').val(''); this.outputJson = null; this.apiId = null; this.scriptEditor&&this.scriptEditor.setValue('return message;'); this.requestEditor && this.requestEditor.setValue(this.defaultRequestValue); this.resultEditor&&this.resultEditor.setValue(''); this.optionsEditor && this.optionsEditor.setValue('{\r\n}'); }, addBreakPoint : function(line){ var model = this.scriptEditor.getModel(); model.deltaDecorations([],[{ range : new monaco.Range(line, 1, line, 1), options: { isWholeLine: true, linesDecorationsClassName: 'breakpoints', className : 'breakpoint-line', } }]) }, removeBreakPoint : function(line){ var model = this.scriptEditor.getModel(); var decorations = []; if (line !== undefined) { decorations = model.getLineDecorations(line); } else { decorations = model.getAllDecorations(); } var ids = []; for (var i=0,len =decorations.length;i 0){ var $groupUL = $('input[name=group]').next(); for(var i=0,len = apiList.length;i').append(info.groupName)) } } if(info.show!==false){ groups[info.groupName].children.push({ id : info.id, groupName : info.groupName, groupPrefix : info.groupPrefix, name : info.name, title : '" + info.path, path : info.path }); } } } for(var key in this.addedGroups){ if(!groups[key]){ groups[key] = this.addedGroups[key]; } } var $dom = $('.api-list-container').html(''); for(var key in groups){ var group = groups[key]; var $item = $('
').addClass('group-item') .addClass('opened') .append($('
').addClass('group-header') .append('') .append($('