Skip to content

Commit 5373586

Browse files
committed
add js string arg
1 parent 0cd6220 commit 5373586

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

resources/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,11 @@ var handleSearch = function (data) {
411411
clearInterval(costTiming);
412412
if (document.getElementById('type').value != 'cograph') {
413413
let nums = document.getElementById("tbody").rows.length;
414-
let msg = tr('Find ') + nums + tr(' results.');
414+
// let msg = tr('Find ') + nums + tr(' results.');
415+
let msg = tr('Find %1 results. ').arg(nums);
415416
if (costMsec >= 100) {
416-
msg += tr('(Cost time: ') + costMsec / 1000 + tr('s)');
417+
msg += tr('(Cost time: %1 s)').arg(costMsec / 1000);
418+
// msg += tr('(Cost time: ') + costMsec / 1000 + tr('s)');
417419
}
418420
alertMsg('success', msg);
419421
}

resources/strings_zh.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ var strings = {
4242
"Save successfully, please go to the index file directory to view.": "保存成功,请前往索引文件目录查看。",
4343
"Save failed!": "保存失败!",
4444
"The number of k-cliques": "k阶完全子图的个数",
45-
"Find ": "找到",
46-
" results.": "条结果。",
47-
"(Cost time: ": "(用时:",
48-
"s)": "秒)",
4945
"keyWord(s)": "关键词",
46+
"Find %1 results. ": "找到 %1 条结果。",
47+
"(Cost time: %1 s)": "(用时:%1 秒)"
5048
};

resources/util.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
String.prototype.arg = function () {
2+
let args = [].slice.call(arguments, 0);
3+
if (args.length == 1 && typeof args[0] == "object") {
4+
return this.replace(/\{(\w+)\}/g, function (match, cap) {
5+
return args[0][cap] || match;
6+
});
7+
}
8+
return this.replace(/\%(\d+)/g, function (match, cap) {
9+
return String(args[cap - 1]) || match;
10+
});
11+
}
12+
113
function $(s) {
214
if (s[0] == '#') {
315
return document.getElementById(s.substr(1));

0 commit comments

Comments
 (0)