diff --git a/js/custom.js b/js/custom.js index ef4b5cf..042b1b0 100644 --- a/js/custom.js +++ b/js/custom.js @@ -153,7 +153,7 @@ function exitEv(id){ $(`${id}`).remove(); } // 进入广场 -function peopleObj(name,uid,say,action,active_time){ +function peopleObj(name,uid,say,action,active_time, is_admin){ let yspHtml = ''; let yspData = [ { @@ -166,15 +166,17 @@ function peopleObj(name,uid,say,action,active_time){ peopleImg:`people-img0${Math.floor(Math.random()*6+1)}`,//人物图片 ying_guang:`stick-0${Math.floor(Math.random()*5+1)}`,//荧光棒 dancin:action, - active_time: active_time + active_time: active_time, + is_admin: is_admin } ] $.each(yspData, function (commentIndex, comment) { + let bigStick = comment.is_admin == 1 ? 'stick-swing-big-tow' : '' yspHtml += `
${comment.say}
-
+
${comment.name}
` @@ -233,7 +235,7 @@ $(function(){ setInterval(function () { delExpireDiv() }, 60000) - + //烟花 // setInterval(()=>{ // setTimeout(function() { diff --git a/js/handle.js b/js/handle.js index 043bd7e..2163d6e 100644 --- a/js/handle.js +++ b/js/handle.js @@ -147,10 +147,15 @@ function receiveMessage(event) let dataList = JSON.parse(event.data) let data = dataList.dm + // 舰长 + let adminList = dataList.admin + // 高能榜top3 + let highList = dataList.high + // 目前硬编码大航海列表 - // let adminList = dataList.admin - adminList = ['流域_墨绿绿']; - // adminList = ['内有猛犬小心']; + // + // let highList = ['流域_墨绿绿']; + // highList = ['内有猛犬小心']; if (data.length <= 0) { return false @@ -161,29 +166,29 @@ function receiveMessage(event) return false } - // 大航海列表 - if (adminList.length > 0) { + // 高能榜列表 + if (highList.length > 0) { // 获取当前领舞人 let currentLeader = getLeader() let now = (new Date).getTime()/1000 if (currentLeader['name'] === '') { - setLeader(adminList[0], leaderTime) + setLeader(highList[0], leaderTime) } else { //领舞人存在 检查过期时间 if (currentLeader['time'] === 0 || currentLeader['time'] < now) { // 切换领舞 // 当前领舞人 - let leaderIndex = adminList.indexOf(currentLeader['name']) + let leaderIndex = highList.indexOf(currentLeader['name']) let newLeader if (leaderIndex == -1) { - newLeader = adminList[0] + newLeader = highList[0] } else { let newIndex = leaderIndex + 1 - if (newIndex >= adminList.length) { + if (newIndex >= highList.length) { newIndex = 0 } - newLeader = adminList[newIndex] + newLeader = highList[newIndex] } setLeader(newLeader, leaderTime) @@ -212,9 +217,10 @@ function receiveMessage(event) let eventName = getEvent(data.danmaku) let isLeader = data.uname == leaderInfo ? 1 : 0 + let isAdmin = adminList.indexOf(data.uname) == -1 ? 0 : 1 let dm = {text: data.danmaku, uid: data.uid, uname: data.uname, event: eventName, - is_new: isNew, is_admin: 0, is_leader: isLeader,active_time: data.ts} + is_new: isNew, is_admin: isAdmin, is_leader: isLeader,active_time: data.ts} let leader = { uid: 0, uname: leaderInfo, text: '', event: '' } @@ -230,7 +236,7 @@ function receiveMessage(event) // 新用户 if(dm.is_new==1){ // if(dm.uname!=leader.uname){//如果弹幕的人的名字不等于领舞者的名字,就创建一个人物 - peopleObj(dm.uname,dm.uid,dm.text,dm.event,dm.active_time); + peopleObj(dm.uname,dm.uid,dm.text,dm.event,dm.active_time,dm.is_admin); // } } else { // 老用户 @@ -238,6 +244,10 @@ function receiveMessage(event) //更新最近时间 $(`#${dm.uid}`).attr('data-time', dm.active_time); $(`#${dm.uid} .speak`).removeClass("dn"); + if (dm.is_admin == 1) { + // 舰长添加大宝剑 + $(`#${dm.uid} .stick`).addClass("stick-swing-big-tow"); + } setTimeout(()=>{ $(`#${dm.uid} .speak`).addClass("dn"); },3000)