-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.html
26 lines (26 loc) · 11.8 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<!--
Lazy's Live
Copyright 2022 Lazy All rights reserved.
https://github.com/LazyCreeper/LazyLive
-->
<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0" /><meta name="keywords" content="Lazy,lazy,Lazy's Live,lazylive,lazyslive,live,Lazy的直播间"><meta name="description" content="Lazy的个人直播间"><meta name="author" content="Lazy"><meta http-equiv="X-UA-Compatible" content="IE=11" /><title>Lazy's Live</title><link rel="icon" href="https://tva1.sinaimg.cn/large/008qLT8ggy1h6q69154tij30ku0lbtl1.jpg" /><link
href="https://font.sec.miui.com/font/css?family=MiSans:400,500,600,700:Chinese_Simplify,Latin,Chinese_Traditional&display=swap"
rel="stylesheet" /><link rel="stylesheet" href="./resources/shit.css?version=20220802" /><link rel="stylesheet" href="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/mdui/1.0.2/css/mdui.min.css" /><link href="https://cdn.bootcdn.net/ajax/libs/dplayer/1.9.1/DPlayer.min.css" rel="stylesheet" /></head><body class="mdui-theme-layout-auto"><div id="bg"></div><img class="NekohaShizuku" src="https://s1.imlazy.ink:233/img/2021/06/30/99535bc41007020210630.png" /><div class="mdui-container"><div class="mdui-row"><div class="mdui-col-sm-12"><div class="mdui-appbar logo"><div class="mdui-toolbar mdui-color-light-blue-a700"><a href="javascript:;" class="mdui-typo-headline">Lazy's Live</a><a href="javascript:;" class="mdui-typo-title phone-visit">个人直播,测试用。欢迎收看~</a><div class="mdui-toolbar-spacer"></div>
<a href="https://www.lazy.ink"
class="mdui-shadow-3 mdui-btn mdui-btn-ripple mdui-color-pink-400 pc-visit phone-visit">
<i class="mdui-icon material-icons"></i> 主页
</a>
<a href="https://blog.imlazy.ink:233"
class="mdui-shadow-3 mdui-btn mdui-btn-ripple mdui-color-deep-purple-500 phone-visit">
<i class="mdui-icon material-icons"></i> 博客
</a>
<a href="https://api.imlazy.ink"
class="mdui-shadow-3 mdui-btn mdui-btn-ripple mdui-color-teal-500 phone-visit">
<i class="mdui-icon material-icons"></i> API
</a>
<a href="javascript:void(0);" class="mdui-shadow-3 mdui-btn mdui-btn-ripple">
<i class="mdui-icon material-icons"></i>
<span class="login-top" mdui-dialog="{target: '#loginDialog'}">未登录</span></a></div></div></div></div><div class="mdui-row mb10"><div class="mdui-col-sm-9 mb10"><div class="mdui-card mdui-color-black"><div class="" style="padding: 6px 14px"><span class="livEstatus"></span><span id="status">Loading...</span>:<span id="description"></span></div><div id="dplayer" style="display: block"></div></div></div><div class="mdui-col-sm-3 commentlab"><div class="comments mdui-card"><div class="CardTitle">实时聊天<span style="float: right; font-size: 14px"> 当前在线:<span id="online">-</span>人</span></div><div class="CardBody commentdata"><div class="msgcontent" id="content"></div></div><button class="mdui-btn mdui-btn-block loginned mdui-color-pink-400 mdui-ripple" mdui-dialog="{target: '#loginDialog'}">登陆即可发送弹幕</button></div></div></div><div class="mdui-row mb10"><div class="mdui-col-lg-6 mdui-col-md-12 mb10"><div class="mdui-card"><div class="mdui-card-content mdui-typo"><footer>直播间公告</footer><p>B站直播间地址:<a href="https://live.bilibili.com/22816605" target="_blank">https://live.bilibili.com/22816605</a><button class="mdui-btn"><del>懒得排版</del></button></p></div></div></div><div class="mdui-col-lg-6 mdui-col-md-12"><div class="mdui-card"><div class="mdui-card-content mdui-typo"><footer>功能按钮</footer><button class="mdui-btn mdui-ripple mdui-btn-raised mdui-color-light-blue-a700" onclick="clearChat()">清空聊天框</button> <button class="mdui-btn mdui-ripple mdui-btn-raised mdui-color-pink" onclick="location.reload()">刷新页面</button></div></div></div></div><div class="mdui-row mb10"><div class="mdui-col-sm-12"><div class="mdui-card"><div class="mdui-card-content mdui-text-center mdui-typo"><strong>
Copyright © 2022
<a href="https://www.lazy.ink/" target="_blank">Lazy</a> Rights
Reserved.</strong></div></div></div></div></div><div class="mdui-dialog"id="loginDialog"><div class="mdui-dialog-title">登陆</div><div class="mdui-dialog-content"><span>使用你的FxCraft账号进行登录</span><div class="mdui-textfield mdui-textfield-floating-label"><i class="mdui-icon material-icons">person_outline</i><label class="mdui-textfield-label">邮箱或玩家名</label><input class="mdui-textfield-input"id="username"type="text"required/><div class="mdui-textfield-error">邮箱或玩家名不能为空</div></div><div class="mdui-textfield mdui-textfield-floating-label"><i class="mdui-icon material-icons">vpn_key</i><label class="mdui-textfield-label">密码</label><input class="mdui-textfield-input"id="password"type="password"required/><div class="mdui-textfield-error">请输入密码</div></div><div class="mdui-float-left"><a href="https://skin.fxcraft.cn/auth/register"target="_blank"><button class="mdui-btn mdui-ripple mdui-text-color-teal">我没账号</button></a><a href="https://skin.fxcraft.cn/auth/forgot"target="_blank"><button class="mdui-btn mdui-ripple mdui-text-color-light-blue"onclick="window.open('')">忘了密码</button></a></div><div class="mdui-float-right"><p>注意:登陆后你的登录信息将会自动保存!</p></div></div><div class="mdui-dialog-actions"><button class="mdui-btn mdui-ripple"mdui-dialog-cancel>取消</button><button class="mdui-btn mdui-ripple"mdui-dialog-confirm onclick="login()">登录</button></div></div><script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/hls.js/8.0.0-beta.3/hls.min.js"></script><script src="https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/flv.js/1.6.2/flv.min.js"type="application/javascript"></script><script src="https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/dplayer/1.26.0/DPlayer.min.js"></script><script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/3.2.1/jquery.min.js"type="application/javascript"></script><script src="https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/mdui/1.0.2/js/mdui.min.js"></script><script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/limonte-sweetalert2/11.4.4/sweetalert2.all.min.js"></script><script type="text/javascript">let videoUrl;$.ajax({type:"GET",url:"https://s1.imlazy.ink:233/info.json",async:false,success:function(response){$("#livEstatus").css("background",response.status_color);$("#status").replaceWith(response.status);$("#description").replaceWith(response.description);if(response.status!="离线"){document.title="正在直播:"+response.description+" - Lazy's Live";videoUrl="https://s1.imlazy.ink:233/live/livestream.flv"}else{videoUrl="hd.mp4"}return videoUrl},});const dp=new DPlayer({container:document.getElementById("dplayer"),live:true,autoplay:false,video:{url:videoUrl,type:"auto",},danmaku:true,});if(localStorage.getItem("accessToken")!=""){$.ajax({type:"POST",url:"https://skin.fxcraft.cn/api/yggdrasil/authserver/validate",contentType:"application/json",dataType:"json",data:JSON.stringify({accessToken:localStorage.getItem("accessToken"),clientToken:localStorage.getItem("clientToken"),}),success:function(data){mdui.snackbar({message:"自动登录成功",position:"right-top",});connectWs();$(".login-top").replaceWith("<span id=loginnedname onclick=logOut()>"+localStorage.getItem("username")+"</span>");mdui.mutation();$(".loginned").replaceWith('<input type="text" id="comment" class="inputcontent" max="128" placeholder="输入后回车发送" onkeydown="keyup_submit(event);">')},error:function(errMsg){console.log(errMsg);mdui.alert("令牌已过期或不存在,请重新登录","登录失败")},})}function login(){$.ajax({type:"POST",url:"https://skin.fxcraft.cn/api/yggdrasil/authserver/authenticate/",contentType:"application/json",dataType:"json",data:JSON.stringify({username:$("#username").val(),password:$("#password").val(),}),success:function(sucMsg){console.log(sucMsg);localStorage.setItem("username",sucMsg.selectedProfile.name);localStorage.setItem("accessToken",sucMsg.accessToken);localStorage.setItem("clientToken",sucMsg.clientToken);mdui.snackbar({message:"登录成功",position:"right-top",});connectWs();$(".login-top").replaceWith("<span id=loginnedname onclick=logOut()>"+sucMsg.selectedProfile.name+"</span>");$(".loginned").replaceWith('<input type="text" id="comment" class="inputcontent" max="128" placeholder="输入后回车发送" onkeydown="keyup_submit(event);">')},error:function(errMsg){console.log(errMsg);mdui.alert("请检查你的用户名和密码!","登录失败")},})}function connectWs(){var aT=localStorage.getItem("accessToken");var cT=localStorage.getItem("clientToken");ws=new WebSocket("ws://localhost:8848/?accessToken="+aT+"&clientToken="+cT);ws.onerror=()=>{mdui.alert("Websocket 连接失败!","错误")};ws.onopen=()=>{let data={"type":"setName","nickname":localStorage.getItem("username"),};ws.send(JSON.stringify(data))};ws.onmessage=(e)=>{var ele=document.getElementById("content");ele.scrollTop=ele.scrollHeight;let data=JSON.parse(e.data);if(data.type==="chatterList"){let list=data.list;let length=list.length;document.getElementById("online").innerText=`${length}`}else{let message=data.message;let oldContent=document.getElementById("content");const JoinRoom={text:message,color:"#fff",type:"right",};dp.danmaku.draw(JoinRoom);$("#content").prepend(createChatDiv(data))}};ws.onclose=()=>{mdui.alert("Websocket连接异常,聊天、弹幕功能将不可用!请刷新网页!","错误")}}</script><script type="text/javascript"language="JavaScript">let ws=null;Date.prototype.Format=function(fmt){var o={"M+":this.getMonth()+1,"d+":this.getDate(),"h+":this.getHours(),"m+":this.getMinutes(),"s+":this.getSeconds(),"q+":Math.floor((this.getMonth()+3)/3),S:this.getMilliseconds(),};if(/(y+)/.test(fmt))fmt=fmt.replace(RegExp.$1,(this.getFullYear()+"").substr(4-RegExp.$1.length));for(var k in o)if(new RegExp("("+k+")").test(fmt))fmt=fmt.replace(RegExp.$1,RegExp.$1.length==1?o[k]:("00"+o[k]).substr((""+o[k]).length));return fmt};const createChatDiv=(data)=>{let div=document.createElement("div");let p_time=document.createElement("b");let p_content=document.createElement("span");switch(data.type){case"serverInformation":p_time.innerHTML=new Date().Format("hh:mm:ss")+" ";p_content.innerHTML=data.message;break;case"chat":p_time.innerHTML="<img src=https://skin.fxcraft.cn/avatar/player/"+data.name+"?size=16> "+data.name+":";p_content.innerHTML=data.message;break;default:break}div.setAttribute("class","msg");div.appendChild(p_time);div.appendChild(p_content);return div};function keyup_submit(e){var evt=window.event||e;if(evt.keyCode==13){let message=document.getElementById("comment");if(!message.value){return}var clear_msg=$("#comment").val().replace(/</g,"<").replace(/>/g,">");let data={"type":"chat","message":clear_msg,};ws.send(JSON.stringify(data));message.value=""}}function clearChat(){$("#content").html('<div class="msg"><b>已清空聊天框</b></div>')}function logOut(){mdui.alert("你真的要退出登录嘛","警告",function(){$.ajax({type:"POST",url:"https://skin.fxcraft.cn/api/yggdrasil/authserver/invalidate",contentType:"application/json",dataType:"json",data:JSON.stringify({accessToken:localStorage.getItem("accessToken"),clientToken:localStorage.getItem("clientToken"),}),success:function(data){console.log("吊销令牌成功");mdui.snackbar({message:"登出成功,正在重新加载页面...",position:"top",});localStorage.setItem("accessToken","");localStorage.setItem("clientToken","");localStorage.setItem("username","");location.reload()},})})};</script></body></html>