diff --git a/UPDATELOG.md b/UPDATELOG.md index ec8e29b..bb049ca 100644 --- a/UPDATELOG.md +++ b/UPDATELOG.md @@ -1,4 +1,9 @@ ### rap v1.0 ### +* [UE] 搜索优化-限制每类条目数最多6条,支持快捷键上、下、回车检索。 2014-03-10 +* [BUG] 解决MockJS标签导致pageTester无法正确检验接口结构的问题 2014-03-10 +* [功能] 参数现在可以按照identifier(标识符)顺序排序了,如果没有identifier或为空,则按照系统自动生成的参数ID(与创建时间顺序一致)排序 2014-03-10 +* [功能] pageTester控制台现在支持mockjs了,跟路径包含mockjs时会自动对返回的JSON串用mockjs处理 2014-03-10 +* [BUG] 修复rap插件 id="rap" 节点放在script 标签前导致加载失败的问题 2014-03-10 * [功能] 完成了工作区搜索。妈妈再也不用担心我找不到接口了。 2014-03-04 * [UE] 文档编辑区升级到bootstrap3,提升UI,调整按钮、提示文案。下线老版hint,改用原生title。 2014-03-03 * [BUG] 修复工作区数据projectData中包含特殊字符导致提交失败、系统异常的问题。2014-02-19 diff --git a/WebContent/stat/js/core/rap.js b/WebContent/stat/js/core/rap.js index 175f455..eeae8b0 100644 --- a/WebContent/stat/js/core/rap.js +++ b/WebContent/stat/js/core/rap.js @@ -1,5 +1,14 @@ var rap = rap || {}; +// console compability +if (!window.console) { + window.console = { + log : function() {}, + warn : function() {}, + error : function() {} + }; +} + /******************************************************** * * * ##util module begin * @@ -1040,6 +1049,7 @@ var rap = rap || {}; * serach project by key */ p.search = function(key) { + var RESULT_LENGTH_LIMIT = 6; var r = { 'byActionName' : [], 'byActionUrl' : [], @@ -1048,7 +1058,8 @@ var rap = rap || {}; var AN = 'byActionName', AU = 'byActionUrl', - PN = 'byPageName'; + PN = 'byPageName', + KEYS = [AN, AU, PN]; var mList = _data.moduleList, mListNum = mList.length, @@ -1084,8 +1095,15 @@ var rap = rap || {}; } } - return r; + for (i = 0; i < KEYS.length; i++) { + n = r[KEYS[i]].length; + r[KEYS[i] + '_length'] = n; + if (n > RESULT_LENGTH_LIMIT) { + r[KEYS[i]].length = RESULT_LENGTH_LIMIT; + } + } + return r; }; })(); @@ -1309,7 +1327,7 @@ var rap = rap || {}; // workspace UI events register var inputSearch = $('#inputSearch'); inputSearch.keyup(function() { - workspaceSearch(inputSearch.val()); + workspaceSearch(inputSearch.val(), arguments); }); }; @@ -3141,14 +3159,54 @@ var rap = rap || {}; } + var _curSearchIndex = -1; + /** * workspace search */ - function workspaceSearch(key) { + function workspaceSearch(key, ev) { var AN = 'byActionName', AU = 'byActionUrl', PN = 'byPageName'; + var liList = $('#dropdown-workspace-search .item'); + var selectedItem; + var orders; + + + if (ev) { + ev = ev[0]; + } + + // up/down arrow + if (ev.keyCode === 38 || ev.keyCode === 40) { + console.log('keyCode:' , ev.keyCode, ", index:", _curSearchIndex, ", length:", liList.length); + liList.css('background', 'none'); + $(liList[_curSearchIndex]).removeClass('selected'); + if (ev.keyCode === 40) { + _curSearchIndex++; + } else { + _curSearchIndex--; + } + + if (_curSearchIndex < 0) { + _curSearchIndex = liList.length - 1; + } else if (_curSearchIndex >= liList.length) { + _curSearchIndex = 0; + } + $(liList[_curSearchIndex]).css('background', '#DFDFDF'); + $(liList[_curSearchIndex]).addClass('selected'); + + return; + + // enter response + } else if (ev.keyCode === 13) { + selectedItem = $('#dropdown-workspace-search .selected'); + orders = selectedItem.find('a').attr('onclick'); + eval(orders); + return; + } + if ($.trim(key) === '') { $('#dropdown-workspace-search').hide(); } else { @@ -3156,8 +3214,10 @@ var rap = rap || {}; if (r[AN].length || r[AU].length || r[PN].length) { $('#dropdown-workspace-search').html(getSearchResultHTML(r)); $('#dropdown-workspace-search').show(); + _curSearchIndex = -1; } else { $('#dropdown-workspace-search').hide(); + $('#dropdown-workspace-search .item').removeClass('selected'); } } } @@ -3177,7 +3237,7 @@ var rap = rap || {}; var AN = 'byActionName', AU = 'byActionUrl', PN = 'byPageName', - n, o, + n, o, num, html = '', header, footer, body, htmlList = []; @@ -3197,43 +3257,54 @@ var rap = rap || {}; // action name results html = ''; n = r[AN].length; + num = n; if (n) { - html += ''; + html += ''; while (n--) { o = r[AN][n]; - html += '
  • ' + o.name + '  ' + o.requestUrl + '
  • '; } + if (r[AN + "_length"] > num) { + html += '
  • ... ...
  • '; + } htmlList.push(html); } // action url results html = ''; n = r[AU].length; + num = n; if (n) { - html += ''; + html += ''; while (n--) { o = r[AU][n]; - html += '
  • ' + o.name + '  ' + o.requestUrl + '
  • '; } + if (r[AU + "_length"] > num) { + html += '
  • ... ...
  • '; + } htmlList.push(html); } // page name results html = ''; n = r[PN].length; + num = n; if (n) { - html += ''; + html += ''; while (n--) { o = r[PN][n]; - html += '
  • ' + o.name + '
  • '; } + if (r[PN + "_length"] > num) { + html += '
  • ... ...
  • '; + } htmlList.push(html); } - body = htmlList.join(''); footer = ''; diff --git a/WebContent/tester/pageTester.vm b/WebContent/tester/pageTester.vm index 54de27e..22849a0 100644 --- a/WebContent/tester/pageTester.vm +++ b/WebContent/tester/pageTester.vm @@ -225,6 +225,9 @@ n = paramIdList.length; for (i = 0; i < n; i++) { key = paramIdList[i]; + if (key && key.indexOf('|') !== -1) { + key = key.substring(0, key.indexOf('|')); + } if (!~jsonString.indexOf(key)) { log('parameter [' + color(key, RED) + '] lost!', ERROR); }