|
-
- var token;
- if(isEmpty(token)){
- var meta = $("meta[name=_uid]");
- if(!isEmpty(meta)){
- token = meta.attr("content");
- }
- }
-
- var swiperNewMessage = new Swiper(".newslist", {
- direction: "vertical",
- slidesPerView: 6,
- loop: true,
- spaceBetween: 8,
- autoplay: {
- delay: 2500,
- disableOnInteraction: false,
- },
- });
-
- var swiperRepo = new Swiper(".homepro-list", {
- slidesPerView: 1,
- // slidesPerColumn: 2,
- // slidesPerColumnFill:'row',
- spaceBetween: 20,
- pagination: {
- el: ".swiper-pagination",
- clickable: true,
- },
- autoplay: {
- delay: 2500,
- disableOnInteraction: false,
- },
- breakpoints: {
- 768: {
- slidesPerView: 2,
- },
- 1024: {
- slidesPerView: 2,
- },
- 1200: {
- slidesPerView: 3,
- },
- 1440: {
- slidesPerView: 3,
- },
- 1840: {
- slidesPerView: 3,
- },
- 1920: {
- slidesPerView: 3,
- },
- },
- });
-
- var swiperOrg = new Swiper(".homeorg-list", {
- slidesPerView: 1,
- slidesPerColumn: 2,
- slidesPerColumnFill:'row',
- spaceBetween: 25,
- pagination: {
- el: ".swiper-pagination",
- clickable: true,
- },
- autoplay: {
- delay: 4500,
- disableOnInteraction: false,
- },
- breakpoints: {
- 768: {
- slidesPerView: 3,
- slidesPerColumn: 2,
- },
- 1024: {
- slidesPerView: 3,
- slidesPerColumn: 2,
- },
- 1200: {
- slidesPerView: 4,
- slidesPerColumn: 2,
- },
- 1440: {
- slidesPerView: 4,
- slidesPerColumn: 2,
- },
- 1840: {
- slidesPerView: 4,
- slidesPerColumn: 2,
- },
- 1920: {
- slidesPerView: 4,
- slidesPerColumn: 2,
- },
- },
- });
-
- var swiperUserExp = new Swiper(".home-user-exp-list", {
- slidesPerView: 1,
- spaceBetween: 0,
- navigation: {
- nextEl: '.homeuserexp .swiper-prev',
- prevEl: '.homeuserexp .swiper-next',
- },
- autoplay: {
- delay: 2500,
- disableOnInteraction: false,
- },
- breakpoints: {
- 768: {
- slidesPerView: 2,
- },
- 1200: {
- slidesPerView: 3,
- },
- 1440: {
- slidesPerView: 4,
- },
- 1840: {
- slidesPerView: 4,
- },
- 1920: {
- slidesPerView: 5,
- },
- },
- });
-
- var swiperDataset = new Swiper(".home-dataset-list", {
- slidesPerView: 2,
- slidesPerColumn: 1,
- slidesPerColumnFill:'row',
- spaceBetween: 30,
- pagination: {
- el: ".swiper-pagination",
- clickable: true,
- },
- autoplay: {
- delay: 2500,
- disableOnInteraction: false,
- },
- breakpoints: {
- 676: {
- slidesPerView: 3,
- },
- 768: {
- slidesPerView: 4,
- },
- 1320: {
- slidesPerView: 5,
- },
- 1520: {
- slidesPerView: 6,
- },
- 1720: {
- slidesPerView: 7,
- },
- 1920: {
- slidesPerView: 7,
- },
- },
- });
-
- var maxSize = 20;
- var html =document.documentElement;
- var lang = html.attributes["lang"]
- var isZh = true;
- if(lang != null && lang.nodeValue =="en-US" ){
- isZh=false;
- }
- document.onreadystatechange = function () {
- if(document.readyState != "complete"){
- return;
- }
- console.log("Start to open WebSocket." + document.readyState);
- queryRecommendData();
-
- var output = document.getElementById("newmessage");
- var url = "ws://" + document.location.host + "/action/notification";
- if(document.location.host == "git.openi.org.cn" || document.URL.startsWith("https")){
- url = "wss://" + document.location.host + "/action/notification"
- }
- var socket = new WebSocket(url);
-
- socket.onopen = function () {
- messageQueue = [];
- console.log("message has connected.");
- };
-
- socket.onmessage = function (e) {
- if (!output) return;
- var data =JSON.parse(e.data)
- var html = "";
- if (data != null){
- if(messageQueue.length > maxSize){
- messageQueue.splice(0,1);
- }
- messageQueue.push(data);
- var currentTime = new Date().getTime();
- for(var i = 0; i < messageQueue.length; i++){
- var record = messageQueue[i];
- var actionName = getAction(record.OpType,isZh);
- if(record.ActUser == null){
- console.log("receive action type=" + record.OpType + " name=" + actionName + " but user is null.");
- continue;
- }
- if(record.OpType == "24"){
- if(record.Content.indexOf("true") != -1){
- continue;
- }
- }
- var recordPrefix = getMsg(record);
- if(record.OpType == "6" || record.OpType == "10" || record.OpType == "12" || record.OpType == "13"){
- html += recordPrefix + actionName;
- html += " <a href=\"" + getIssueLink(record) + "\" rel=\"nofollow\">" + getIssueText(record) + "</a>"
- }
- else if(record.OpType == "7" || record.OpType == "11" || record.OpType == "14" || record.OpType == "15" || record.OpType == "22"
- || record.OpType == "23"){
- html += recordPrefix + actionName;
- html += " <a href=\"" + getPRLink(record) + "\" rel=\"nofollow\">" + getPRText(record) + "</a>"
- }
- else if(record.OpType == "1"){
- html += recordPrefix + actionName;
- html += " <a href=\"" + getRepoLink(record) + "\" rel=\"nofollow\">" +getRepotext(record) + "</a>"
- }
- else if(record.OpType == "5"){
- branch = "<a href=\"" + getRepoLink(record) + "/src/branch/" + encodeURI(record.RefName) + "\" rel=\"nofollow\">" + record.RefName + "</a>"
- actionName = actionName.replace("{branch}",branch);
- html += recordPrefix + actionName;
- html += " <a href=\"" + getRepoLink(record) + "\" rel=\"nofollow\">" + getRepotext(record) + "</a>"
- }else if(record.OpType == "9"){
- branch = "<a href=\"" + getRepoLink(record) + "/src/tag/" + encodeURI(record.RefName) + "\" rel=\"nofollow\">" + record.RefName + "</a>"
- actionName = actionName.replace("{branch}",branch);
- html += recordPrefix + actionName;
- html += " <a href=\"" + getRepoLink(record) + "\" rel=\"nofollow\">" + getRepotext(record) + "</a>"
- }
- else if(record.OpType == "17"){
- actionName = actionName.replace("{deleteBranchName}",record.RefName);
- var repoLink = "<a href=\"" + getRepoLink(record) + "\" rel=\"nofollow\">" + getRepotext(record) + "</a>"
- actionName = actionName.replace("{repoName}",repoLink);
- html += recordPrefix + actionName;
- }
- else if(record.OpType == "2"){
- actionName = actionName.replace("{oldRepoName}",record.Content);
- html += recordPrefix + actionName;
- html += " <a href=\"" + getRepoLink(record) + "\" rel=\"nofollow\">" + getRepotext(record) + "</a>"
- }
- else if(record.OpType == "24" || record.OpType == "26" || record.OpType == "27" || record.OpType == "28" || record.OpType == "50" || record.OpType == "51"
- || record.OpType == "30" || record.OpType == "31" || record.OpType == "32" || record.OpType == "33" || record.OpType == "42" || record.OpType == "44"){
- html += recordPrefix + actionName;
- const taskLink = getTaskLink(record);
- if (taskLink) {
- html += " <a href=\"" + taskLink + "\" rel=\"nofollow\">" + record.RefName + "</a>"
- } else {
- html += " <span style=\"color: rgba(0,0,0,0.3)\">" + record.RefName + "</span>"
- }
- }
- else if(record.OpType == "25" || record.OpType == "29" || record.OpType == "39" || record.OpType == "40" || record.OpType == "41"
- || record.OpType == "43"|| record.OpType == "44"|| record.OpType == "45"|| record.OpType == "46"|| record.OpType == "47"
- || record.OpType == "48"|| record.OpType == "49"
- ){
- html += recordPrefix + actionName;
- const taskLink = getTaskLink(record);
- if (taskLink) {
- html += " <a href=\"" + taskLink + "\" rel=\"nofollow\">" + record.RefName + "</a>"
- } else {
- html += " <span style=\"color: rgba(0,0,0,0.3)\">" + record.RefName + "</span>"
- }
- }
- else if(record.OpType == "35"){
- var datasetLink = "<a href=\"" + getRepoLink(record) + "/datasets" + "\" rel=\"nofollow\">" + record.Content.split('|')[1] + "</a>";
- actionName = actionName.replace('{dataset}', datasetLink);
- html += recordPrefix + actionName;
- }
- else{
- continue;
- }
- if(record.Repo != null){
- var time = getTime(record.CreatedUnix,currentTime);
- html += " " + time;
- }
- html += "</div></div>";
- html += "</div>";
- }
- }
- output.innerHTML = html;
- $('#homenews p').show();
- swiperNewMessage.updateSlides();
- swiperNewMessage.updateProgress();
- };
- }
-
- function getTaskLink(record){
- var re = getRepoLink(record);
- if(record.OpType == 24){
- re = re + "/datasets";
- }else if(record.OpType == 25){
- if (record.Cloudbrain) {
- re = re + "/cloudbrain/" + record.Cloudbrain.ID;
- } else {
- re = '';
- }
- }else if(record.OpType == 26){
- if (record.Cloudbrain) {
- re = re + "/modelarts/notebook/" + record.Content;
- } else {
- re = '';
- }
- }else if(record.OpType == 27){
- if (record.Cloudbrain) {
- re = re + "/modelarts/train-job/" + record.Cloudbrain.ID;
- } else {
- re = '';
- }
- }else if(record.OpType == 28){
- if (record.Cloudbrain) {
- re = re + "/modelarts/inference-job/" + record.Cloudbrain.ID;
- } else {
- re = '';
- }
- }else if(record.OpType == 50 || record.OpType == 51){
- if (record.Cloudbrain) {
- re = re + "/grampus/inference-job/" + record.Cloudbrain.ID;
- } else {
- re = '';
- }
- }else if(record.OpType == 29){
- re = re + "/cloudbrain/benchmark/" + record.Content;
- }else if(record.OpType == 30){
- re = re + "/modelmanage/model_readme_tmpl?name=" + record.RefName;
- }else if(record.OpType == 31){
- if (record.Cloudbrain) {
- re = re + "/cloudbrain/train-job/" + record.Cloudbrain.ID;
- } else {
- re = '';
- }
- }else if(record.OpType == 32 || record.OpType == 33 || record.OpType == 42 || record.OpType == 44){
- if (record.Cloudbrain) {
- re = re + "/grampus/train-job/" + record.Cloudbrain.ID;
- } else {
- re = '';
- }
- }else if(record.OpType == 39 || record.OpType == 40 || record.OpType == 41 || record.OpType == 43|| record.OpType == 46|| record.OpType == 48|| record.OpType == 49){
- if (record.Cloudbrain) {
- re = re + "/grampus/notebook/" + record.Cloudbrain.ID;
- } else {
- re = '';
- }
- } else if(record.OpType == 47){
- re = re + "/supercompute/job/" + record.Cloudbrain.ID;
- } else if(record.OpType == 45){
- re = re + "/grampus/onlineinfer/" + record.Content;
- }
- re = encodeURI(re);
- return re;
- }
-
- function getMsg(record){
- var html ="";
- html += "<div class=\"swiper-slide item\">";
- var name = "";
- if(record.ActUser != null){
- name = record.ActUser.Name;
- }else{
- console.log("act user is null.");
- }
- html += "<div class=\"content-c\"><img class=\"ui avatar image\" src=\"/user/avatar/" + name + "/-1\" alt=\"\">"
- html += " <div class=\"middle aligned content nowrap\">"
- html += " <a href=\"/" + encodeURI(name) + "\" title=\"\">" + name + "</a>"
- return html;
- }
-
- function getRepotext(record){
- if(record.Repo.Alias){
- return record.Repo.OwnerName + "/" + record.Repo.Alias;
- }else{
- return record.Repo.OwnerName + "/" + record.Repo.Name;
- }
- }
-
- function getRepoLink(record){
- return encodeURI(record.Repo.OwnerName + "/" + record.Repo.Name);
-
- }
-
- function getTime(UpdatedUnix,currentTime){
- UpdatedUnix = UpdatedUnix;
- currentTime = currentTime / 1000;
- var timeEscSecond = currentTime - UpdatedUnix;
- if( timeEscSecond < 0){
- timeEscSecond = 1;
- }
-
- var hours= Math.floor(timeEscSecond / 3600);
- //计算相差分钟数
- var leave2 = Math.floor(timeEscSecond % (3600)); //计算小时数后剩余的秒数
- var minutes= Math.floor(leave2 / 60);//计算相差分钟数
-
- var leave3=Math.floor(leave2 % 60); //计算分钟数后剩余的秒数
- var seconds= leave3;
-
- if(hours == 0 && minutes == 0){
- return seconds + getRepoOrOrg(6,isZh,seconds);
- }else{
- if(hours > 0){
- return hours + getRepoOrOrg(4,isZh,hours);
- }else{
- return minutes + getRepoOrOrg(5,isZh,minutes);
- }
- }
- }
-
- function getPRLink(record){
- return encodeURI("/" + record.Repo.OwnerName + "/" + record.Repo.Name + "/pulls/" + getIssueId(record));
- }
- function getPRText(record){
- if(record.Repo.Alias){
- return record.Repo.OwnerName + "/" + record.Repo.Alias + "#" + getIssueId(record);
- }else{
- return record.Repo.OwnerName + "/" + record.Repo.Name + "#" + getIssueId(record);
- }
-
- }
-
- function getIssueLink(record){
-
- return encodeURI("/" + record.Repo.OwnerName + "/" + record.Repo.Name + "/issues/" + getIssueId(record));
- }
-
- function getIssueId(record){
- var Id = "1";
- if(!isEmpty(record.Comment) && !isEmpty(record.Comment.Issue)){
- Id = record.Comment.Issue.Index;
- }else{
- if(!isEmpty(record.Content)){
- var content = record.Content;
- var index = content.indexOf("|");
- if(index != -1){
- Id = content.substring(0,index);
- }
- }
- }
- return Id;
- }
-
- function getIssueText(record){
- if(record.Repo.Alias){
- return record.Repo.OwnerName + "/" + record.Repo.Alias + "#" + getIssueId(record);
- }else{
- return record.Repo.OwnerName + "/" + record.Repo.Name + "#" + getIssueId(record);
- }
-
- }
-
- /*
- ActionCreateRepo ActionType = iota + 1 // 1
- ActionRenameRepo // 2
- ActionStarRepo // 3
- ActionWatchRepo // 4
- ActionCommitRepo // 5
- ActionCreateIssue // 6
- ActionCreatePullRequest // 7
- ActionTransferRepo // 8
- ActionPushTag // 9
- ActionCommentIssue // 10
- ActionMergePullRequest // 11
- ActionCloseIssue // 12
- ActionReopenIssue // 13
- ActionClosePullRequest // 14
- ActionReopenPullRequest // 15
- ActionDeleteTag // 16
- ActionDeleteBranch // 17
- ActionMirrorSyncPush // 18
- ActionMirrorSyncCreate // 19
- ActionMirrorSyncDelete // 20
- ActionApprovePullRequest // 21
- ActionRejectPullRequest // 22
- ActionCommentPull // 23
- */
-
- var actionNameZH={
- "1":"创建了项目",
- "2":"重命名项目 {oldRepoName} 为",
- "5":"推送了 {branch} 分支的代码到",
- "6":"创建了任务",
- "7":"创建了合并请求",
- "9":"推送了标签 {branch} 到",
- "10":"评论了任务",
- "11":"合并了合并请求",
- "12":"关闭了任务",
- "13":"重新开启了任务",
- "14":"关闭了合并请求",
- "15":"重新开启了合并请求",
- "17":"从 {repoName} 删除分支 {deleteBranchName}",
- "22":"建议变更",
- "23":"评论了合并请求",
- "24":"上传了数据集文件",
- "25":"创建了CPU/GPU类型调试任务",
- "26":"创建了NPU类型调试任务",
- "27":"创建了NPU类型训练任务",
- "28":"创建了推理任务",
- "50":"创建了GPU类型推理任务",
- "51":"创建了ILUVATAR-GPGPU类型推理任务",
- "29":"创建了评测任务",
- "30":"导入了新模型",
- "31":"创建了CPU/GPU类型训练任务",
- "32":"创建了NPU类型训练任务",
- "33":"创建了CPU/GPU类型训练任务",
- "35":"创建的数据集 {dataset} 被设置为推荐数据集",
- "36":"提交了镜像 {image}",
- "37":"提交的镜像 {image} 被设置为推荐镜像",
- "39":"创建了NPU类型调试任务",
- "40":"创建了CPU/GPU类型调试任务",
- "41":"创建了GCU类型调试任务",
- "42":"创建了GCU类型训练任务",
- "43":"创建了MLU类型调试任务",
- "44":"创建了MLU类型训练任务",
- "45":"创建了GPU类型在线推理任务",
- "46":"创建了DCU类型调试任务",
- "47":"创建了CPU类型超算任务",
- "48":"创建了ILUVATAR-GPGPU类型调试任务",
- "49":"创建了METAX-GPGPU类型调试任务",
- };
-
- var actionNameEN={
- "1":" created repository",
- "2":" renamed repository from {oldRepoName} to ",
- "5":" pushed to {branch} at",
- "6":" opened issue",
- "7":" created pull request",
- "9":" pushed tag {branch} to ",
- "10":" commented on issue",
- "11":" merged pull request",
- "12":" closed issue",
- "13":" reopened issue",
- "14":" closed pull request",
- "15":" reopened pull request",
- "17":" deleted branch {deleteBranchName} from {repoName}",
- "22":" proposed changes",
- "23":" commented on pull request",
- "24":" upload dataset ",
- "25":" created CPU/GPU type debugging task ",
- "26":" created NPU type debugging task ",
- "27":" created NPU type training task",
- "28":" created inference task",
- "50":" created GPU type inference task",
- "51":" created ILUVATAR-GPGPU type inference task",
- "29":" created profiling task",
- "30":" created new model",
- "31":" created CPU/GPU type training task",
- "32":" created NPU type training task",
- "33":" created CPU/GPU type training task",
- "35":" created dataset {dataset} was set as recommended dataset",
- "36":"committed image {image}",
- "37":"committed image {image} was set as recommended image",
- "39":" created NPU type debugging task ",
- "40":" created CPU/GPU type debugging task ",
- "41":" created GCU type debugging task ",
- "42":" created GCU type training task ",
- "43":" created MLU type debugging task ",
- "44":" created MLU type training task ",
- "45":" created GPU type online inference task ",
- "46":" created DCU type debugging task ",
- "47":" created CPU type super compute task ",
- "48":" created ILUVATAR-GPGPU type debugging task ",
- "49":" created METAX-GPGPU type debugging task ",
- };
-
- var repoAndOrgZH={
- "1":"项目",
- "2":"成员",
- "3":"团队",
- "11":"项目",
- "21":"成员",
- "31":"团队",
- "4":"小时前",
- "5":"分钟前",
- "6":"秒前",
- "41":"小时前",
- "51":"分钟前",
- "61":"秒前"
- };
-
- var repoAndOrgEN={
- "1":"Repository",
- "2":"Member ",
- "3":"Team",
- "11":"Repositories",
- "21":"Members ",
- "31":"Teams",
- "4":" hour ago",
- "5":" minute ago",
- "6":" second ago",
- "41":" hours ago",
- "51":" minutes ago",
- "61":" seconds ago"
- };
-
-
- function getAction(opType,isZh){
- if(isZh){
- return actionNameZH[opType]
- }else{
- return actionNameEN[opType]
- }
- }
-
- function queryRecommendData(){
- $.ajax({
- type:"GET",
- url:"/recommend/home",
- headers: {
- authorization:token,
- },
- dataType:"json",
- async:false,
- success:function(json){
- displayOrg(json.org);
- displayRepo(json.repo);
- displayActivity(json.activity);
- displayDataset(json.dataset);
- displayUserExp(json.user_experience);
- LetterAvatar && LetterAvatar.transform();
- },
- error:function(response) {
- }
- });
- }
-
-
- function displayActivity(json){
- var activityDiv = document.getElementById("recommendactivity");
- if (!activityDiv) return;
- var html = "";
- if (json != null && json.length > 0){
- for(var i = 0; i < json.length;i++){
- var record = json[i];
- var name = isZh ? (record["name"] || '') : (record["name_en"] || record["name"]);
- html += "<div class=\"swiper-slide\" style=\"text-align:center;\">";
- html += "<a href=\"" + record["image_link"] + "\">";
- html += " <div class=\"image ui card\"><img src=\"" + record["url"] + "\">";
- html += ' <div class="image-name" title="' + name + '">' + name + "</div>";
- html += "</div>";
- html += "</a>";
- html += "</div>";
- }
- var swiperEvent = new Swiper(".event-list", {
- slidesPerView: 1,
- spaceBetween: 30,
- // pagination: {
- // el: ".swiper-pagination",
- // clickable: true,
- // },
- autoplay: {
- delay: 2500,
- disableOnInteraction: false,
- },
- breakpoints: {
- 768: {
- slidesPerView: Math.min(2, json.length),
- },
- 1024: {
- slidesPerView: Math.min(3, json.length),
- },
- 1200: {
- slidesPerView: Math.min(3, json.length),
- },
- 1440: {
- slidesPerView: Math.min(4, json.length),
- },
- 1840: {
- slidesPerView: Math.min(4, json.length),
- },
- 1920: {
- slidesPerView: Math.min(4, json.length),
- },
- },
- });
- activityDiv.innerHTML = html;
- swiperEvent.updateSlides();
- swiperEvent.updateProgress();
- }
- }
-
- function displayRepo(json){
- var orgRepo = document.getElementById("recommendrepo");
- var html = "";
- if (json != null && json.length > 0){
- var repoMap = {};
- for (var i = 0, iLen = json.length; i < iLen; i++) {
- var repo = json[i];
- var label = isZh ? repo.Label : repo.Label_en;
- if (repoMap[label]) {
- repoMap[label].push(repo);
- } else {
- repoMap[label] = [repo];
- }
- }
-
- for (var label in repoMap) {
- var repos = repoMap[label];
- var labelSearch = repos[0].Label;
- html += `<div class="swiper-slide"><div><a style="color:rgb(50, 145, 248);font-size:16px;font-weight:550;" href="/explore/repos?q=&topic=${labelSearch}&sort=hot"># ${label}</a></div>`;
- for (var i = 0, iLen = repos.length; i < iLen; i++) {
- if (i >= 4) break;
- var repo = repos[i];
- html += `<div class="ui fluid card" style="border-radius:6px;">
- <div class="content" style="position:relative;">
- ${repo["Avatar"] ? `<img style="border-radius:100%;" class="left floated mini ui image" src="${repo["Avatar"]}">` : `<img style="border-radius:100%;" class="left floated mini ui image" avatar="${repo["OwnerName"]}">`}
- <a class="header nowrap" style="color:rgb(50, 145, 248);font-size:14px;" href="/${repo["OwnerName"]}/${repo["Name"]}" title="${repo["Alias"]}">${repo["Alias"]}</a>
- <div class="description nowrap-2" style="rgba(136,136,136,1);;font-size:12px;" title="${repo["Description"]}">${repo["Description"]}</div>
- <a href="/${repo["OwnerName"]}/${repo["Name"]}" style="height:100%;width:100%;position:absolute;left:0;top:0"></a>`;
- html += `
- </div>
- </div>`;
- }
- html += '</div>'
- }
- }
- orgRepo.innerHTML = html;
- swiperRepo.updateSlides();
- swiperRepo.updateProgress();
- }
-
- function getRepoOrOrg(key,isZhLang,numbers=1){
- if(numbers > 1){
- key+="1";
- }
- if(isZhLang){
- return repoAndOrgZH[key];
- }else{
- return repoAndOrgEN[key];
- }
- }
- function displayOrg(json){
- var orgDiv = document.getElementById("recommendorg");
- var html = "";
- if (json != null && json.length > 0){
- for(var i = 0; i < json.length;i++){
- var record = json[i]
- html += "<div class=\"swiper-slide\">";
- html += " <a href=\"/" + record["Name"] + "\" class=\"ui fluid card\">";
- html += " <div class=\"content\">";
- html += " <div class=\"ui small header\">";
- html += " <img class=\"ui image\" src=\"" + record["Avatar"] + "\">";
- html += " <div class=\"content nowrap\">";
- html += " <span class=\"ui blue\">" + record["Name"] + "</span> " + record["FullName"];
- html += " <div class=\"sub header\" style=\"margin-top:4px;\"><span style=\"color:rgb(54, 56, 64)\">" + record["NumRepos"] +"</span> " + getRepoOrOrg(1,isZh,record["NumRepos"]) + " ・ <span style=\"color:rgb(54, 56, 64)\">" + record["NumMembers"] +"</span> " + getRepoOrOrg(2,isZh,record["NumMembers"]) + " ・ <span style=\"color:rgb(54, 56, 64)\">" + record["NumTeams"] + "</span> " + getRepoOrOrg(3,isZh,record["NumTeams"]) + "</div>";
- html += " </div>";
- html += " </div>";
- html += " </div>";
- html += " </a>";
- html += "</div>";
- }
- }
- orgDiv.innerHTML = html;
- swiperOrg.updateSlides();
- }
-
- function displayDataset(data) {
- var homeDatasetEl = document.getElementById("home_dataset");
- if (!homeDatasetEl) return;
- var html = '';
- var svgStrMap = {
- '0': '<svg xmlns="http://www.w3.org/2000/svg" class="svg svg-icon-path-icon fill" viewBox="0 0 32 32" width="32" height="32"><defs data-reactroot=""><linearGradient id="ila93em9ydx6bi61,1,rs,1,f000f000,f0rsf000,f000,00e6msqtrs,dw4hjuqlrs,ri00exmcrs" x1="0" x2="100%" y1="0" y2="0" gradientUnits="userSpaceOnUse"><stop stop-color="#82d1f6" stop-opacity="1" offset="0"></stop><stop stop-color="#29b6f4" stop-opacity="1" offset="0.5"></stop><stop stop-color="#0089cd" stop-opacity="1" offset="0.99"></stop></linearGradient></defs><g><path d="M16 4c7.189 0 13.171 5.173 14.425 12-1.253 6.827-7.236 12-14.425 12s-13.171-5.173-14.425-12c1.253-6.827 7.236-12 14.425-12zM16 25.333c5.682-0.001 10.442-3.949 11.687-9.252l0.016-0.081c-1.265-5.379-6.024-9.322-11.703-9.322s-10.437 3.943-11.686 9.241l-0.016 0.081c1.261 5.384 6.021 9.332 11.703 9.333h0zM16 22c-3.314 0-6-2.686-6-6s2.686-6 6-6v0c3.314 0 6 2.686 6 6s-2.686 6-6 6v0zM16 19.333c1.841 0 3.333-1.492 3.333-3.333s-1.492-3.333-3.333-3.333v0c-1.841 0-3.333 1.492-3.333 3.333s1.492 3.333 3.333 3.333v0z"></path></g></svg>',
- '1': '<svg xmlns="http://www.w3.org/2000/svg" class="svg svg-icon-path-icon fill" viewBox="0 0 32 32" width="32" height="32"><defs data-reactroot=""><linearGradient id="ila93gapd7aoa4d1,1,rs,1,f000f000,f0rsf000,f000,00e6msqtrs,dw4hjuqlrs,ri00exmcrs" x1="0" x2="100%" y1="0" y2="0" gradientUnits="userSpaceOnUse"><stop stop-color="#82d1f6" stop-opacity="1" offset="0"></stop><stop stop-color="#29b6f4" stop-opacity="1" offset="0.5"></stop><stop stop-color="#0089cd" stop-opacity="1" offset="0.99"></stop></linearGradient></defs><g><path d="M2.667 16c0-7.364 5.969-13.333 13.333-13.333s13.333 5.969 13.333 13.333-5.969 13.333-13.333 13.333h-13.333l3.905-3.905c-2.413-2.407-3.905-5.735-3.905-9.411 0-0.006 0-0.012 0-0.018v0.001zM9.104 26.667h6.896c5.891 0 10.667-4.776 10.667-10.667s-4.776-10.667-10.667-10.667c-5.891 0-10.667 4.776-10.667 10.667v0c0 2.869 1.135 5.553 3.124 7.543l1.885 1.885-1.239 1.239zM14.667 8h2.667v16h-2.667v-16zM9.333 12h2.667v8h-2.667v-8zM20 12h2.667v8h-2.667v-8z"></path></g></svg>',
- '2': '<svg xmlns="http://www.w3.org/2000/svg" class="styles__StyledSVGIconPathComponent-sc-16fsqc8-0 lhfskE svg-icon-path-icon fill" viewBox="0 0 48 48" width="32" height="32"><defs data-reactroot=""><linearGradient id="ila93j5tkotzm421,1,rs,1,f000f000,f0rsf000,f000,00e6msqtrs,dw4hjuqlrs,ri00exmcrs" x1="0" x2="100%" y1="0" y2="0" gradientUnits="userSpaceOnUse"><stop stop-color="#82d1f6" stop-opacity="1" offset="0"></stop><stop stop-color="#29b6f4" stop-opacity="1" offset="0.5"></stop><stop stop-color="#0089cd" stop-opacity="1" offset="0.99"></stop></linearGradient></defs><g><rect width="48" height="48" fill-opacity="0.01" fill="url(#ila93j5tkotzm421,1,rs,1,f000f000,f0rsf000,f000,00e6msqtrs,dw4hjuqlrs,ri00exmcrs)" storke="none"></rect><path stroke="url(#ila93j5tkotzm421,1,rs,1,f000f000,f0rsf000,f000,00e6msqtrs,dw4hjuqlrs,ri00exmcrs)" fill="none" d="M4 24C4 24 10 15 14 15C18 15 22 17 24 17C26 17 30 15 34 15C38 15 44 24 44 24C44 24 34 34 24 34C14 34 4 24 4 24Z" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"></path><path stroke="url(#ila93j5tkotzm421,1,rs,1,f000f000,f0rsf000,f000,00e6msqtrs,dw4hjuqlrs,ri00exmcrs)" fill="none" d="M4 24H44" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"></path></g></svg>',
- '3': '<svg xmlns="http://www.w3.org/2000/svg" class="styles__StyledSVGIconPathComponent-sc-16fsqc8-0 beWLko svg-icon-path-icon fill" viewBox="0 0 48 48" width="32" height="32"><defs data-reactroot=""><linearGradient id="ila93k86om2ayqg1,1,rs,1,f000f000,f0rsf000,f000,00e6msqtrs,dw4hjuqlrs,ri00exmcrs" x1="0" x2="100%" y1="0" y2="0" gradientUnits="userSpaceOnUse"><stop stop-color="#82d1f6" stop-opacity="1" offset="0"></stop><stop stop-color="#29b6f4" stop-opacity="1" offset="0.5"></stop><stop stop-color="#0089cd" stop-opacity="1" offset="0.99"></stop></linearGradient></defs><g><path d="M6 25C6 15.0589 14.0589 7 24 7C30.8669 7 36.8357 10.8453 39.8706 16.5" stroke="url(#ila93k86om2ayqg1,1,rs,1,f000f000,f0rsf000,f000,00e6msqtrs,dw4hjuqlrs,ri00exmcrs)" fill="none" stroke-width="4"></path><path d="M41 25H43L42 24L41 25Z" stroke="url(#ila93k86om2ayqg1,1,rs,1,f000f000,f0rsf000,f000,00e6msqtrs,dw4hjuqlrs,ri00exmcrs)" fill="none" stroke-width="4"></path><path d="M31 34L28.375 27L25 18H23L19.625 27L17 34" stroke="url(#ila93k86om2ayqg1,1,rs,1,f000f000,f0rsf000,f000,00e6msqtrs,dw4hjuqlrs,ri00exmcrs)" fill="none" stroke-width="4"></path><path d="M28.375 27H19.625" stroke="url(#ila93k86om2ayqg1,1,rs,1,f000f000,f0rsf000,f000,00e6msqtrs,dw4hjuqlrs,ri00exmcrs)" fill="none" stroke-width="4"></path><path d="M7 25H5L6 26L7 25Z" stroke="url(#ila93k86om2ayqg1,1,rs,1,f000f000,f0rsf000,f000,00e6msqtrs,dw4hjuqlrs,ri00exmcrs)" fill="none" stroke-width="4"></path><path d="M42 25C42 34.9411 33.9411 43 24 43C17.1331 43 11.1643 39.1547 8.12939 33.5" stroke="url(#ila93k86om2ayqg1,1,rs,1,f000f000,f0rsf000,f000,00e6msqtrs,dw4hjuqlrs,ri00exmcrs)" fill="none" stroke-width="4"></path></g></svg>',
- '4': '<svg xmlns="http://www.w3.org/2000/svg" class="styles__StyledSVGIconPathComponent-sc-16fsqc8-0 kqqJug svg-icon-path-icon fill" viewBox="0 0 48 48" width="32" height="32"><defs data-reactroot=""><linearGradient id="ila93lcoqm7710i1,1,rs,1,f000f000,f0rsf000,f000,00e6msqtrs,dw4hjuqlrs,ri00exmcrs" x1="0" x2="100%" y1="0" y2="0" gradientUnits="userSpaceOnUse"><stop stop-color="#82d1f6" stop-opacity="1" offset="0"></stop><stop stop-color="#29b6f4" stop-opacity="1" offset="0.5"></stop><stop stop-color="#0089cd" stop-opacity="1" offset="0.99"></stop></linearGradient></defs><g><path d="M33 4.99976H41C42.1046 4.99976 43 5.89519 43 6.99976V14.9998M43 32.9998V40.9998C43 42.1043 42.1046 42.9998 41 42.9998H33M15 42.9998H7C5.89543 42.9998 5 42.1043 5 40.9998V32.9998M5 14.9998V6.99976C5 5.89519 5.89543 4.99976 7 4.99976H15" stroke="url(#ila93lcoqm7710i1,1,rs,1,f000f000,f0rsf000,f000,00e6msqtrs,dw4hjuqlrs,ri00exmcrs)" fill="none" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"></path><path d="M24 38C30.6274 38 36 31.732 36 24C36 16.268 30.6274 10 24 10C17.3726 10 12 16.268 12 24C12 31.732 17.3726 38 24 38Z" stroke="url(#ila93lcoqm7710i1,1,rs,1,f000f000,f0rsf000,f000,00e6msqtrs,dw4hjuqlrs,ri00exmcrs)" fill="none" stroke-width="4"></path><path d="M6 24H42" stroke="url(#ila93lcoqm7710i1,1,rs,1,f000f000,f0rsf000,f000,00e6msqtrs,dw4hjuqlrs,ri00exmcrs)" fill="none" stroke-width="4" stroke-linecap="round"></path><path d="M20.0693 30.1057C21.3372 31.0429 22.6473 31.5115 23.9996 31.5115C25.3519 31.5115 26.698 31.0429 28.0378 30.1057" stroke="url(#ila93lcoqm7710i1,1,rs,1,f000f000,f0rsf000,f000,00e6msqtrs,dw4hjuqlrs,ri00exmcrs)" fill="none" stroke-width="4" stroke-linecap="round"></path></g></svg>',
- '5': '<svg xmlns="http://www.w3.org/2000/svg" class="svg svg-icon-path-icon fill" viewBox="0 0 32 32" width="32" height="32"><defs data-reactroot=""><linearGradient id="ila93mrrwzocn0r1,1,rs,1,f000f000,f0rsf000,f000,00e6msqtrs,dw4hjuqlrs,ri00exmcrs" x1="0" x2="100%" y1="0" y2="0" gradientUnits="userSpaceOnUse"><stop stop-color="#82d1f6" stop-opacity="1" offset="0"></stop><stop stop-color="#29b6f4" stop-opacity="1" offset="0.5"></stop><stop stop-color="#0089cd" stop-opacity="1" offset="0.99"></stop></linearGradient></defs><g><path d="M16 26.667c5.891 0 10.667-4.776 10.667-10.667s-4.776-10.667-10.667-10.667v0c-5.891 0-10.667 4.776-10.667 10.667s4.776 10.667 10.667 10.667v0zM16 29.333c-7.364 0-13.333-5.969-13.333-13.333s5.969-13.333 13.333-13.333 13.333 5.969 13.333 13.333-5.969 13.333-13.333 13.333zM16 21.333c2.946 0 5.333-2.388 5.333-5.333s-2.388-5.333-5.333-5.333v0c-2.946 0-5.333 2.388-5.333 5.333s2.388 5.333 5.333 5.333v0zM16 24c-4.418 0-8-3.582-8-8s3.582-8 8-8v0c4.418 0 8 3.582 8 8s-3.582 8-8 8v0zM16 18.667c-1.473 0-2.667-1.194-2.667-2.667s1.194-2.667 2.667-2.667v0c1.473 0 2.667 1.194 2.667 2.667s-1.194 2.667-2.667 2.667v0z"></path></g></svg>',
- '6': '<svg xmlns="http://www.w3.org/2000/svg" class="styles__StyledSVGIconPathComponent-sc-16fsqc8-0 cAmoNA svg-icon-path-icon fill" viewBox="0 0 48 48" width="32" height="32"><defs data-reactroot=""><linearGradient id="ila93oiqy4t1x861,1,rs,1,f000f000,f0rsf000,f000,00e6msqtrs,dw4hjuqlrs,ri00exmcrs" x1="0" x2="100%" y1="0" y2="0" gradientUnits="userSpaceOnUse"><stop stop-color="#82d1f6" stop-opacity="1" offset="0"></stop><stop stop-color="#29b6f4" stop-opacity="1" offset="0.5"></stop><stop stop-color="#0089cd" stop-opacity="1" offset="0.99"></stop></linearGradient></defs><g><rect width="48" height="48" fill="white" fill-opacity="0.01"></rect><path d="M14.5397 20.0186C12.8522 17.9434 11.2675 17.4979 9.78564 18.6821C7.5629 20.4583 6.92453 26.6496 8.71324 32.1086C10.502 37.5676 13.9801 45.0017 21.0016 45.0017C28.0231 45.0017 29.684 37.5222 32.5485 33.0001C35.413 28.478 36.9285 24.1152 34.1208 18.6821" stroke="url(#ila93oiqy4t1x861,1,rs,1,f000f000,f0rsf000,f000,00e6msqtrs,dw4hjuqlrs,ri00exmcrs)" fill="none" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"></path><path d="M11 18.0368C9.29707 15.4428 7.96374 13.4306 6.99996 12.0002C5.5543 9.85464 9.25107 7.08164 11 8.96807C12.1659 10.2257 13.7148 12.078 15.6466 14.5249" stroke="url(#ila93oiqy4t1x861,1,rs,1,f000f000,f0rsf000,f000,00e6msqtrs,dw4hjuqlrs,ri00exmcrs)" fill="none" stroke-width="4" stroke-linecap="round"></path><path d="M15.0236 25.6396C14.5391 19.5759 14.9333 15.6276 16.2062 13.7947C18.1155 11.0455 21.6631 10.0031 25.0035 10.0031C26.9924 10.0031 28.8087 10.8502 30.4525 12.5444" stroke="url(#ila93oiqy4t1x861,1,rs,1,f000f000,f0rsf000,f000,00e6msqtrs,dw4hjuqlrs,ri00exmcrs)" fill="none" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M41.0003 12.6128C41.5858 14.6492 40.6294 16.5097 37.6844 16.931C34.7393 17.3523 32.5313 18.8332 30.9388 20.079C29.3463 21.3248 26.4983 25.1046 25.9361 27.0023C25.3738 28.9 22.1602 27.1547 21.2971 26.3971C20.434 25.6394 19.5855 23.9806 21.2971 22.2457C23.0086 20.5108 22.6383 20.1646 22.6383 18.4052C22.6383 16.6459 32.0003 10.8263 37.2729 10.2941C38.4449 10.2257 40.4147 10.5763 41.0003 12.6128Z" stroke="url(#ila93oiqy4t1x861,1,rs,1,f000f000,f0rsf000,f000,00e6msqtrs,dw4hjuqlrs,ri00exmcrs)" fill="none" stroke-width="4"></path><path d="M23.0078 4.00014V9.26283" stroke="url(#ila93oiqy4t1x861,1,rs,1,f000f000,f0rsf000,f000,00e6msqtrs,dw4hjuqlrs,ri00exmcrs)" fill="none" stroke-width="4" stroke-linecap="round"></path><path d="M20.3066 10.7178C17.2888 6.92534 14.8555 4.80868 13.0068 4.36781" stroke="url(#ila93oiqy4t1x861,1,rs,1,f000f000,f0rsf000,f000,00e6msqtrs,dw4hjuqlrs,ri00exmcrs)" fill="none" stroke-width="4" stroke-linecap="round"></path><path d="M17.0039 7.02894L17.9944 2.96156" stroke="url(#ila93oiqy4t1x861,1,rs,1,f000f000,f0rsf000,f000,00e6msqtrs,dw4hjuqlrs,ri00exmcrs)" fill="none" stroke-width="4" stroke-linecap="round"></path><path d="M35.6128 10.7174C35.2905 11.8219 35.2905 12.8575 35.6128 13.8241C35.935 14.7908 36.6255 15.8264 37.6842 16.9308" stroke="url(#ila93oiqy4t1x861,1,rs,1,f000f000,f0rsf000,f000,00e6msqtrs,dw4hjuqlrs,ri00exmcrs)" fill="none" stroke-width="4" stroke-linecap="round"></path></g></svg>',
- }
- for (var i = 0, iLen = data.length; i < iLen; i++) {
- var dataI = data[i];
- html += `<div class="swiper-slide">
- <a href="/explore/datasets?sort=default&q=&tab=&category=&task=${dataI.task}&license=">
- <div class="ui fluid dataset-card">
- <div><div class="content icon-c">
- ${svgStrMap[i % 7]}
- </div></div>
- <div><div class="content label" title="${i18n[dataI.task] || dataI.task}">${i18n[dataI.task] || dataI.task}</div></div>
- <div><div class="content count" style="">${i18n['about']} ${dataI.total} ${i18n['count']}</div></div>
- </div>
- </a>
- </div>`
- }
- homeDatasetEl.innerHTML = html;
- swiperDataset.updateSlides();
- swiperDataset.updateProgress();
- }
-
- function displayUserExp(data) {
- var homeUserExpEl = document.getElementById("home_user-exp");
- if (!homeUserExpEl) return;
- var html = '';
- for (var i = 0, iLen = data.length; i < iLen; i++) {
- var dataI = data[i];
- html += `<div class="swiper-slide">
- <div class="ui fluid user-card">
- <div><div class="content img-c">
- <a href="/${dataI.name}">
- <div class="img" style="width:60px;height:60px;background-image:url('${dataI.avatar}')"></div>
- </a>
- </div></div>
- <div><div class="content label" title="${dataI.fullname || dataI.name}">${dataI.fullname || dataI.name}</div></div>
- <div><div class="content descr" title="${dataI.desc}">${dataI.desc}</div></div>
- </div>
- </div>`
- }
- homeUserExpEl.innerHTML = html;
- swiperUserExp.updateSlides();
- swiperUserExp.updateProgress();
- }
-
- function getNotice() {
- $.ajax({
- type:"GET",
- url:"/dashboard/invitation",
- headers: { authorization:token, },
- dataType:"json",
- data: {
- filename: 'notice/notice.json',
- },
- success:function(json){
- if (json) {
- try {
- var noticeList = JSON.parse(json).Notices || [];
- var noticeEls = $('._hm-recommend-info-area-1 a._hm-notice');
- for (var i = 0, iLen = noticeEls.length; i < iLen; i++) {
- var noticeEl = noticeEls.eq(i);
- var noticeObj = noticeList[i];
- if (noticeObj) {
- var title = isZh ? noticeObj.Title : (noticeObj.Title_en || noticeObj.Title);
- noticeEl.attr('href', noticeObj.Link);
- noticeEl.find('span').text(title).attr('title', title);
- noticeEl.show();
- } else {
- noticeEl.hide();
- }
- }
- } catch (e) {
- console.info(e);
- }
- }
- },
- error:function(response) {
- }
- });
- }
-
- function getRecommendModule() {
- $.ajax({
- type:"GET",
- url:"/dashboard/invitation",
- headers: { authorization:token, },
- dataType:"json",
- data: {
- filename: 'home/newfunction',
- },
- success:function(json){
- if (json) {
- try {
- var recommendModuleList = JSON.parse(json) || [];
- var recommendModuleEls = $('._hm-recommend-info-area a._hm-link');
- for (var i = 0, iLen = recommendModuleEls.length; i < iLen; i++) {
- var recommendModuleEl = recommendModuleEls.eq(i);
- var recommendModuleObj = recommendModuleList[i];
- if (recommendModuleObj) {
- recommendModuleEl.attr('href', recommendModuleObj.image_link);
- recommendModuleEl.text(isZh ? recommendModuleObj.name : (recommendModuleObj.name_en || recommendModuleObj.name));
- } else {
- }
- }
- } catch (e) {
- console.info(e);
- }
- }
- },
- error:function(response) {
- }
- });
- }
-
- function initHomeTopBanner() {
- var homeSlideTimer = null;
- var homeSlideDuration = 8000;
-
- function getBannerData() {
- $.ajax({
- type: "GET",
- url: "/dashboard/invitation",
- headers: { authorization: token, },
- dataType: "json",
- data: { filename: 'home/banner', },
- success: function (data) {
- try {
- var banners = JSON.parse(data);
- var count = 0, bannerList = [];
- for (var i = 0; i < banners.length; i++) {
- (function (banner, index) {
- $.ajax({
- type: "GET",
- url: "/dashboard/invitation",
- headers: { authorization: token, },
- data: { filename: 'home/banners/' + banner },
- success: function (data) {
- count++;
- bannerList[index] = {
- banner: banner,
- data: data,
- };
- if (count == banners.length) {
- renderBanners(bannerList);
- }
- },
- error: function (err) {
- count++;
- if (count == data.length) {
- startSlide();
- }
- console.log(err);
- }
- });
- })(banners[i], i);
- }
- if (!banners.length) {
- startSlide();
- }
- } catch (err) {
- console.log(err);
- startSlide();
- }
- },
- error: function (err) {
- console.log(err);
- startSlide();
- }
- });
- }
-
- function renderBanners(bannerList) {
- var hmPageC = $('._hm-bg-container ._hm-pg-c');
- var hmPageSlidePaginationC = $('._hm-slide-pagination-c');
- for (var i = 0, iLen = bannerList.length; i < iLen; i++) {
- var banner = bannerList[i];
- if (banner.data) {
- hmPageC.append($(banner.data));
- hmPageSlidePaginationC.append('<div class="_hm-slide-pagination-item"></div>');
- }
- }
- startSlide();
- }
-
- function homeSlide(direction, index) {
- var slidePages = $('._hm-pg-c ._hm-pg');
- var currentPage = slidePages.filter('._hm-pg-show');
- var slidePagination = $('._hm-slide-pagination-c ._hm-slide-pagination-item');
- var currentIndex = currentPage.index();
- var next = 0;
- if (direction) {
- next = direction == 'left' ? currentIndex - 1 : currentIndex + 1;
- } else {
- next = index || 0;
- }
- if (next < 0) next = slidePages.length - 1;
- if (next == slidePages.length) next = 0;
- slidePages.removeClass('_hm-pg-show');
- slidePages.eq(next).addClass('_hm-pg-show');
- slidePagination.removeClass('_hm-slide-pagination-item-active');
- slidePagination.eq(next).addClass('_hm-slide-pagination-item-active');
- }
-
- function startSlide() {
- $('._hm-slide-pagination-c').show();
- homeSlideTimer && clearTimeout(homeSlideTimer);
- homeSlideTimer = setTimeout(function () {
- homeSlide('right');
- startSlide();
- }, homeSlideDuration);
- }
-
- function stopSlide() {
- homeSlideTimer && clearTimeout(homeSlideTimer);
- }
-
- function eventInit() {
- $('._hm-slide-btn').on('click', function () {
- if ($(this).hasClass('_hm-slide-btn-left')) {
- homeSlide('left');
- } else {
- homeSlide('right');
- }
- startSlide();
- });
- $('._hm-pg #homenews').on('mouseenter', function () {
- stopSlide();
- }).on('mouseleave', function () {
- startSlide();
- });
- $('._hm-slide-pagination-c').on('click', '._hm-slide-pagination-item', function () {
- var self = $(this);
- if (self.hasClass('_hm-slide-pagination-item-active')) return;
- homeSlide('', self.index());
- startSlide();
- });
- }
-
- getBannerData();
- eventInit();
- }
-
- initHomeTopBanner();
- getNotice();
- getRecommendModule();
|