Skip to content

Commit

Permalink
continously user experience update! See update_log.md for more details.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bosn committed Mar 10, 2014
1 parent 18f08f2 commit cad90e5
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 12 deletions.
5 changes: 5 additions & 0 deletions UPDATELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
95 changes: 83 additions & 12 deletions WebContent/stat/js/core/rap.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
var rap = rap || {};

// console compability
if (!window.console) {
window.console = {
log : function() {},
warn : function() {},
error : function() {}
};
}

/********************************************************
* *
* ##util module begin *
Expand Down Expand Up @@ -1040,6 +1049,7 @@ var rap = rap || {};
* serach project by key
*/
p.search = function(key) {
var RESULT_LENGTH_LIMIT = 6;
var r = {
'byActionName' : [],
'byActionUrl' : [],
Expand All @@ -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,
Expand Down Expand Up @@ -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;
};

})();
Expand Down Expand Up @@ -1309,7 +1327,7 @@ var rap = rap || {};
// workspace UI events register
var inputSearch = $('#inputSearch');
inputSearch.keyup(function() {
workspaceSearch(inputSearch.val());
workspaceSearch(inputSearch.val(), arguments);
});
};

Expand Down Expand Up @@ -3141,23 +3159,65 @@ 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 {
var r = p.search(key);
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');
}
}
}
Expand All @@ -3177,7 +3237,7 @@ var rap = rap || {};
var AN = 'byActionName',
AU = 'byActionUrl',
PN = 'byPageName',
n, o,
n, o, num,
html = '',
header, footer, body,
htmlList = [];
Expand All @@ -3197,43 +3257,54 @@ var rap = rap || {};
// action name results
html = '';
n = r[AN].length;
num = n;
if (n) {
html += '<li role="presentation" class="dropdown-header">Action Name (' + n + ')</li>';
html += '<li role="presentation" class="dropdown-header">Action Name (' + r[AN + "_length"] + ')</li>';
while (n--) {
o = r[AN][n];
html += '<li role="presentation"><a role="menuitem" tabindex="-1" href="#" onclick="ws.workspaceSearchResultHandler(\'a\', ' +
html += '<li role="presentation" class="item"><a role="menuitem" tabindex="-1" href="#" onclick="ws.workspaceSearchResultHandler(\'a\', ' +
o.id + ');">' + o.name + '&nbsp;&nbsp;' + o.requestUrl + '</a></li>';
}
if (r[AN + "_length"] > num) {
html += '<li role="presentation"><a role="menuitem" tabindex="-1" href="#" onclick="return false;">... ...</a></li>';
}
htmlList.push(html);
}

// action url results
html = '';
n = r[AU].length;
num = n;
if (n) {
html += '<li role="presentation" class="dropdown-header">Request Url (' + n + ')</li>';
html += '<li role="presentation" class="dropdown-header">Request Url (' + r[AU + "_length"] + ')</li>';
while (n--) {
o = r[AU][n];
html += '<li role="presentation"><a role="menuitem" tabindex="-1" href="#" onclick="ws.workspaceSearchResultHandler(\'a\', ' +
html += '<li role="presentation" class="item"><a role="menuitem" tabindex="-1" href="#" onclick="ws.workspaceSearchResultHandler(\'a\', ' +
o.id + ');">' + o.name + '&nbsp;&nbsp;' + o.requestUrl + '</a></li>';
}
if (r[AU + "_length"] > num) {
html += '<li role="presentation"><a role="menuitem" tabindex="-1" href="#" onclick="return false;">... ...</a></li>';
}
htmlList.push(html);
}

// page name results
html = '';
n = r[PN].length;
num = n;
if (n) {
html += '<li role="presentation" class="dropdown-header">Page Name (' + n + ')</li>';
html += '<li role="presentation" class="dropdown-header">Page Name (' + r[PN + "_length"] + ')</li>';
while (n--) {
o = r[PN][n];
html += '<li role="presentation"><a role="menuitem" tabindex="-1" href="#" onclick="ws.workspaceSearchResultHandler(\'p\', ' +
html += '<li role="presentation" class="item"><a role="menuitem" tabindex="-1" href="#" onclick="ws.workspaceSearchResultHandler(\'p\', ' +
o.id + ');">' + o.name + '</a></li>';
}
if (r[PN + "_length"] > num) {
html += '<li role="presentation"><a role="menuitem" tabindex="-1" href="#" onclick="return false;">... ...</a></li>';
}
htmlList.push(html);
}


body = htmlList.join('<li role="presentation" class="divider"></li>');

footer = '</ul>';
Expand Down
3 changes: 3 additions & 0 deletions WebContent/tester/pageTester.vm
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit cad90e5

Please sign in to comment.