@@ -27,6 +27,7 @@ var itemType = {
4: "org",
5: "dataset",
6: "pr",
7: "model",
};
var sortBy = {
@@ -51,6 +52,10 @@ var sortBy = {
51: "download_times",
60: "default",
61: "updated_unix.keyword",
70: "default",
71: "reference_count",
72: "download_count",
73: "created_unix.keyword",
};
var sortAscending = {
@@ -75,6 +80,10 @@ var sortAscending = {
51: "false",
60: "false",
61: "false",
70: "false",
71: "false",
72: "false",
73: "false",
};
var currentPage = 1;
@@ -149,6 +158,7 @@ function emptySearch() {
$("#pr_total").text("");
$("#issue_total").text("");
$("#dataset_total").text("");
$("#model_total").text("");
$("#user_total").text("");
$("#org_total").text("");
setActivate(null);
@@ -159,6 +169,7 @@ function initDiv(isSearchLabel = false) {
document.getElementById("search_div").style.display = "none";
document.getElementById("search_label_div").style.display = "block";
document.getElementById("dataset_item").style.display = "none";
document.getElementById("model_item").style.display = "none";
document.getElementById("issue_item").style.display = "none";
document.getElementById("pr_item").style.display = "none";
document.getElementById("user_item").style.display = "none";
@@ -168,6 +179,7 @@ function initDiv(isSearchLabel = false) {
document.getElementById("search_div").style.display = "block";
document.getElementById("search_label_div").style.display = "none";
document.getElementById("dataset_item").style.display = "block";
document.getElementById("model_item").style.display = "block";
document.getElementById("issue_item").style.display = "block";
document.getElementById("pr_item").style.display = "block";
document.getElementById("user_item").style.display = "block";
@@ -210,6 +222,9 @@ function doSpcifySearch(tableName, keyword, sortBy = "", ascending = "false") {
if (currentSearchTableName != "dataset") {
doSearch("dataset", currentSearchKeyword, 1, pageSize, true, "", false);
}
if (currentSearchTableName != "model") {
doSearch("model", currentSearchKeyword, 1, pageSize, true, "", false);
}
if (currentSearchTableName != "pr") {
doSearch("pr", currentSearchKeyword, 1, pageSize, true, "", false);
}
@@ -278,7 +293,7 @@ function doSearch(
success: function (json) {
displayResult(tableName, page, json, onlyReturnNum, keyword);
},
error: function (response) {},
error: function (response) { },
});
}
@@ -293,6 +308,8 @@ function displayResult(tableName, page, jsonResult, onlyReturnNum, keyword) {
displayOrgResult(page, jsonResult, onlyReturnNum, keyword);
} else if (tableName == "dataset") {
displayDataSetResult(page, jsonResult, onlyReturnNum, keyword);
} else if (tableName == "model") {
displayModelResult(page, jsonResult, onlyReturnNum, keyword);
} else if (tableName == "pr") {
displayPrResult(page, jsonResult, onlyReturnNum, keyword);
}
@@ -535,6 +552,104 @@ function displayDataSetResult(page, jsonResult, onlyReturnNum, keyword) {
}
}
function displayModelResult(page, jsonResult, onlyReturnNum, keyword) {
var data = jsonResult.Result;
var total = jsonResult.Total;
$("#model_total").text(total);
if (!onlyReturnNum) {
setActivate("model_item");
//$('#keyword_desc').text(keyword);
//$('#obj_desc').text(getLabel(isZh,"search_model"));
//$('#child_total').text(total);
$("#find_title").html(
getLabel(isZh, "find_title")
.replace("{keyword}", keyword)
.replace("{tablename}", getLabel(isZh, "search_model"))
.replace("{total}", total)
);
var sortHtml = "";
sortHtml +=
'<a class="' +
getActiveItem(70) +
'item" href="javascript:searchItem(7,70);" tabindex="-1" role="menuitem" id="menuitem_1">' +
getLabel(isZh, "search_matched") +
"</a>";
sortHtml +=
'<a class="' +
getActiveItem(71) +
'item" href="javascript:searchItem(7,71);" tabindex="-1" role="menuitem" id="menuitem_1">' +
getLabel(isZh, "search_matched_reference") +
"</a>";
sortHtml +=
'<a class="' +
getActiveItem(72) +
'item" href="javascript:searchItem(7,72);" tabindex="-1" role="menuitem" id="menuitem_1">' +
getLabel(isZh, "search_matched_download") +
"</a>";
sortHtml +=
'<a class="' +
getActiveItem(73) +
'item" href="javascript:searchItem(7,73);" tabindex="-1" role="menuitem" id="menuitem_1">' +
getLabel(isZh, "search_lasted_create") +
"</a>";
document.getElementById("sort_type").innerHTML = sortHtml;
var html = "";
var currentTime = new Date().getTime();
const engineMap = {
'0': 'PyTorch',
'1': 'TensorFlow',
'2': 'MindSpore',
'4': 'PaddlePaddle',
'5': 'OneFlow',
'6': 'MXNet',
'3': 'Other',
};
for (var i = 0; i < data.length; i++) {
var recordMap = data[i];
var createDate = new Date(recordMap['created_unix'] * 1000);
var createYear = createDate.getFullYear().toString();
var createMonth = (createDate.getMonth() + 1).toString();
var createDay = createDate.getDate().toString();
html += `<div class="item">
<div class="content">
<div class="ui right metas" style="color:#767676">${engineMap[recordMap['engine']] || 'Other'}</div>
<div class="ui header">
<a class="name" href="/${recordMap["repoUrl"]}/modelmanage/model_readme_tmpl?name=${recordMap["real_name"]}" target="_blank">
${recordMap["name"]}
</a>
</div>
<div class="description">
<p class="labels has-emoji">${recordMap['label'] ? recordMap['label'].replace(/font\scolor=/g, 'font_color=').trim().split(/\s+/).map(item => {
return '<span style="color:rgba(16, 16, 16, 0.8);border-radius:4px;font-size:12px;background:rgba(232, 232, 232, 0.6);padding:2px 6px;margin-right:8px">'
+ item.replace(/font_color=/g, 'font color=') + '</span>';
}).join('') : ''}</p>
<p class="descr has-emoji">${recordMap['description']}</p>
<p class="filename has-emoji">${recordMap['file_name'] || ''}</p>
<p class="time" style="display:flex;align-items:center">
<a style="margin-right:8px;display:inline-block;height:22px;" href="/${recordMap['owerName']}"><img src="/user/avatar/${recordMap['owerName']}/-1"
style="display:inline-block;width:22px;height:22px;border-radius:100%;"></a>
<span style="margin-right:8px" title="${getLabel(isZh, "create_time")}">
${createYear}-${createMonth.length < 2 ? '0' + createMonth : createMonth}-${createDay.length < 2 ? '0' + createDay : createDay}
</span>
<span title="${getLabel(isZh, "search_matched_reference")}" style="display:flex;align-items:center">
<i class="ri-link" style="margin-right:4px"></i><span style="margin-right:4px">${recordMap['reference_count']}</span>
</span>
<span title="${getLabel(isZh, "search_matched_download")}" style="display:flex;align-items:center">
<i class="ri-download-line" style="margin-right:4px"></i><span style="margin-right:8px">${recordMap['download_count']}</span>
</span>
${getLabel(isZh, "search_lasted_update")} ${recordMap["updated_html"]}
</p>
</div>
</div>
</div>
`;
}
document.getElementById("child_search_item").innerHTML = html;
}
}
function displayOrgResult(page, jsonResult, onlyReturnNum, keyword) {
var data = jsonResult.Result;
var total = jsonResult.Total;
@@ -872,6 +987,7 @@ function setActivate(name) {
$("#user_item").removeClass("active");
$("#issue_item").removeClass("active");
$("#dataset_item").removeClass("active");
$("#model_item").removeClass("active");
$("#org_item").removeClass("active");
$("#pr_item").removeClass("active");
if (name == null) {
@@ -885,27 +1001,27 @@ function LetterAvatar(name, size, color) {
name = name || "";
size = size || 60;
var colours = [
"#1abc9c",
"#2ecc71",
"#3498db",
"#9b59b6",
"#34495e",
"#16a085",
"#27ae60",
"#2980b9",
"#8e44ad",
"#2c3e50",
"#f1c40f",
"#e67e22",
"#e74c3c",
"#00bcd4",
"#95a5a6",
"#f39c12",
"#d35400",
"#c0392b",
"#bdc3c7",
"#7f8c8d",
],
"#1abc9c",
"#2ecc71",
"#3498db",
"#9b59b6",
"#34495e",
"#16a085",
"#27ae60",
"#2980b9",
"#8e44ad",
"#2c3e50",
"#f1c40f",
"#e67e22",
"#e74c3c",
"#00bcd4",
"#95a5a6",
"#f39c12",
"#d35400",
"#c0392b",
"#bdc3c7",
"#7f8c8d",
],
nameSplit = String(name).split(" "),
initials,
charIndex,
@@ -1624,6 +1740,7 @@ var zhCN = {
search: "搜索",
search_repo: "项目",
search_dataset: "数据集",
search_model: "模型",
search_issue: "任务",
search_pr: "合并请求",
search_user: "用户",
@@ -1631,10 +1748,11 @@ var zhCN = {
search_finded: "找到",
search_matched: "最佳匹配",
search_matched_download: "下载次数",
search_matched_reference: "引用次数",
search_lasted_update: "最后更新于",
search_letter_asc: "字母顺序排序",
search_letter_desc: "字母逆序排序",
search_lasted_create: "最近 创建",
search_lasted_create: "最新 创建",
search_early_create: "最早创建",
search_add_by: "加入于",
search_lasted: "最近更新",
@@ -1654,12 +1772,14 @@ var zhCN = {
find_title:
'“<strong class="highlight" id="keyword_desc">{keyword}</strong>”相关{tablename}约为{total}个',
search_empty: "<strong>请输入任意关键字开始搜索。</strong>",
create_time: "创建时间"
};
var esUN = {
search: "Search",
search_repo: "Repository",
search_dataset: "DataSet",
search_model: "Model",
search_issue: "Issue",
search_pr: "Pull Request",
search_user: "User",
@@ -1667,6 +1787,7 @@ var esUN = {
search_finded: "Find",
search_matched: "Best Match",
search_matched_download: "Most downloads",
search_matched_reference: "Most reference",
search_lasted_update: "Updated ",
search_letter_asc: "Alphabetically",
search_letter_desc: "Reverse alphabetically",
@@ -1691,6 +1812,7 @@ var esUN = {
' {total} "<strong class="highlight" id="keyword_desc">{keyword}</strong>" related {tablename}',
search_empty:
"<strong>Please enter any keyword to start the search.</strong>",
create_time: "Create Time"
};
initDiv(false);
document.onreadystatechange = function () {