Browse Source

提交代码。

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.22.1.1^2
zouap 3 years ago
parent
commit
6dd256ec7b
1 changed files with 43 additions and 5 deletions
  1. +43
    -5
      public/home/home.js

+ 43
- 5
public/home/home.js View File

@@ -26,7 +26,7 @@ console.log("the language is " + lang);

socket.onmessage = function (e) {
var data =JSON.parse(e.data)
console.log("recevie data=" + data.ID)
console.log("recevie data=" + data)
var html = "";
if (data != null){
console.log("queue length=" + messageQueue.length);
@@ -35,6 +35,7 @@ socket.onmessage = function (e) {
}else{
messageQueue.push(data);
}
var currentTime = new Date().getTime();
for(var i = 0; i < messageQueue.length;i++){
var record = messageQueue[i];
@@ -44,16 +45,25 @@ socket.onmessage = function (e) {
html += " <div class=\"middle aligned content\">"
html += " <a href=\"/" + record.ActUser.Name + "\" title=\"\">" + record.ActUser.Name + "</a>"
var actionName = getAction(record.OpType,isZh);
html += actionName;
if(record.OpType == "6" || record.OpType == "10" || record.OpType == "12" || record.OpType == "13"){
html += actionName;
html += " <a href=\"" + getIssueLink(record) + "\" rel=\"nofollow\">" + getIssueText(record) + "</a>"
}
if(record.OpType == "7" || record.OpType == "11" || record.OpType == "14" || record.OpType == "15"){
html += actionName;
html += " <a href=\"" + getPRLink(record) + "\" rel=\"nofollow\">" + getPRText(record) + "</a>"
}
if(record.OpType == "1"){
html += actionName;
html += " <a href=\"" + getRepoLink(record) + "\" rel=\"nofollow\">" + getRepoLink(record) + "</a>"
}
if(record.OpType == "9"){

}

if(record.Repo != null){
var time = getTime(record.Repo.UpdatedUnix);
var time = getTime(record.Repo.UpdatedUnix,currentTime);
html += time;
}
html += "</div>";
@@ -73,8 +83,36 @@ socket.onmessage = function (e) {
output.innerHTML = html;
};

function getTime(UpdatedUnix){
return "10分钟前";
function getRepoLink(record){
return "/" + record.Repo.OwnerName + "/" + record.Repo.Name;
}
function getRepoLink(record){
return record.Repo.OwnerName + "/" + record.Repo.Name;
}

function getTime(UpdatedUnix,currentTime){
currentTime = currentTime/1000;
var timeEsc = currentTime - UpdatedUnix;
console.log("currentTime=" + currentTime + " updateUnix=" + UpdatedUnix);
var dayDiff = Math.floor(timeEsc / (24 * 3600 * 1000));//计算出相差天数
var leave1= timeEsc%(24*3600*1000) //计算天数后剩余的毫秒数

var hours=Math.floor(leave1/(3600*1000))//计算出小时数
//计算相差分钟数
var leave2=leave1%(3600*1000) //计算小时数后剩余的毫秒数
var minutes=Math.floor(leave2/(60*1000))//计算相差分钟数
var re = "";
if(hours > 0){
re += hours + "小时";
}
if(minutes > 1){
re += hours + "分钟前";
}else{
if(hours == 0){
re = "刚刚"
}
}
return re;
}

function getPRLink(record){


Loading…
Cancel
Save