Files
vippk-yy-template/build/html-template/chat.js
T
2018-12-03 17:31:53 +08:00

251 lines
7.0 KiB
JavaScript

var Event = {};
var showJsChatPub = false;
window.jsChatPubComplete = false;
Event.addEvents = function (target, eventType, handle) {
if (document.addEventListener) {
Event.addEvents = function (target, eventType, handle) {
target.addEventListener(eventType, handle, false);
};
} else {
Event.addEvents = function (target, eventType, handle) {
target.attachEvent('on' + eventType, function () {
handle.call(target, arguments);
});
};
};
Event.addEvents(target, eventType, handle);
};
var isExpandChatTopMain = true;
Event.addEvents(document.getElementById("expand-bar-btn"), "click", function () {
if (isExpandChatTopMain) {
document.getElementById("pkRankTop").style.position = "absolute";
document.getElementById("pkRankTop").style.right = "900px";
document.getElementById("expand-bar-btn").className = "expand-bar";
}
else {
document.getElementById("pkRankTop").style.position = "relative";
document.getElementById("pkRankTop").style.right = "0px";
document.getElementById("expand-bar-btn").className = "expand-bar expand-bar-up";
}
isExpandChatTopMain = !isExpandChatTopMain;
resizeRightUI();
});
function resizeRightUI() {
if (!window.jsChatPubComplete)
return;
try{
var mainWrap = document.getElementById("mainWrap");
var pkChat = document.getElementById("pkChat");
var pkChatWrap = document.getElementById("pkChatWrap");
var pkRightWrap = document.getElementById("pkRightWrap");
var pkMainWrap = document.getElementById("pkMainWrap");
var chatTopMainHeight = document.getElementById("pkRankTop").offsetHeight + document.getElementById("pkVideosTop").offsetHeight + 5;
if (document.getElementById("pkRankTop").style.position == "absolute")
chatTopMainHeight = document.getElementById("pkVideosTop").offsetHeight + 5;
pkChatWrap.style.height = pkRightWrap.offsetHeight - chatTopMainHeight + "px";
pkMainWrap.style.marginRight = "260px";
pkRightWrap.style.width = "260px";
pkRightWrap.style.marginRight = "0px";
if (document.body.clientWidth < (850 + 260)) {
mainWrap.style.width = 850 + 260 + "px";
}
else {
mainWrap.style.width = document.body.clientWidth + "px";
}
}
catch(e){
}
}
function setSwfSize(swfId, heightValue) {
if (!window.jsChatPubComplete)
return;
document.getElementById(swfId).style.height = heightValue + "px";
resizeRightUI();
}
function getIsOpenJsChatPub() {
return showJsChatPub;
}
function hideYYShowDiv() {
if (!window.jsChatPubComplete)
return;
document.getElementById("pkYYShowTop").style.display = "none";
}
function showYYShowDiv() {
if (!window.jsChatPubComplete)
return;
document.getElementById("pkYYShowTop").style.display = "block";
}
var MainDiamondRank;
var ChatVer;
var MainVideoLists;
var YYShowBrocast;
var RightConfig;
function changeJsChatPub(ChatVer, MainDiamondRank, MainVideoLists, YYShowBrocast,RightConfig) {
showJsChatPub = true;
this.ChatVer = ChatVer;
this.MainDiamondRank = MainDiamondRank;
this.MainVideoLists = MainVideoLists;
this.YYShowBrocast = YYShowBrocast;
this.RightConfig = RightConfig;
if (showJsChatPub) {
var pkChat = document.getElementById("pkChat");
var pkChatWrap = document.getElementById("pkChatWrap");
var pkRightWrap = document.getElementById("pkRightWrap");
var pkMainWrap = document.getElementById("pkMainWrap");
if (pkChat.attachEvent) {
pkChat.attachEvent("onload", function () {
window.jsChatPubComplete = true;
validateChat();
});
}
else {
pkChat.onload = function () {
window.jsChatPubComplete = true;
validateChat();
}
}
pkChat.src = "http://show.vip.yy.com/clientpkchatpub/index.html?t=" + ChatVer;
}
}
function validateChat(){
if(this.jsIsRealyLoadedFlag && window.jsChatPubComplete && this.showJsChatPub)
{
this.onCompletePkChat(this.ChatVer, this.MainDiamondRank, this.MainVideoLists, this.YYShowBrocast,this.RightConfig);
document.getElementById(yy.flashId).jsChatComplete();
}
}
function onCompletePkChat(ver, MainDiamondRank, MainVideoLists, YYShowBrocast,Config) {
if(!jsIsRealyLoadedFlag)
return;
var pkChat = document.getElementById("pkChat");
var pkChatWrap = document.getElementById("pkChatWrap");
var pkRightWrap = document.getElementById("pkRightWrap");
var pkMainWrap = document.getElementById("pkMainWrap");
setTimeout(function () {
if(!jsIsRealyLoadedFlag)
return;
var flashvars = "";
var params = { wmode: "direct" };
params.allowScriptAccess = "always";
var MainDiamondRankHeigt = "165px";
if(Config.MainDiamondRankHeigt > 0)
MainDiamondRankHeigt = Config.MainDiamondRankHeigt + "px";
swfobject.embedSWF(MainDiamondRank + "?t=" + ver, "pkRankTopMain", "100%", MainDiamondRankHeigt, "10.0.0", "", flashvars, params);
}, 1000);
/*
setTimeout(function () {
if(!jsIsRealyLoadedFlag)
return;
var flashvars = "";
var params = { wmode: "direct" };
params.allowScriptAccess = "always";
swfobject.embedSWF(MainVideoLists + "?t=" + ver, "pkVideosTopMain", "100%", "170px", "10.0.0", "", flashvars, params);
}, 3000);
*/
setTimeout(function () {
if(!jsIsRealyLoadedFlag)
return;
var flashvars = "";
var params = { wmode: "direct" };
params.allowScriptAccess = "always";
swfobject.embedSWF(YYShowBrocast + "?t=" + ver, "pkYYShowTopMain", "100%", "100%", "10.0.0", "", flashvars, params);
}, 5000);
resizeRightUI();
callExternal("IChannelWindow_setRightAreaVisible", false);
}
var jsIsRealyLoadedFlag;
function jsIsRealyLoaded(){
if(jsIsRealyLoadedFlag)
return;
jsIsRealyLoadedFlag = true;
validateChat();
}
function jsIsError(){
changeDefaultChat();
}
function resizeDefaultStyle(){
if(!window.jsChatPubComplete)
{
var mainWrap = document.getElementById("mainWrap");
var pkRightWrap = document.getElementById("pkRightWrap");
mainWrap.style.width = document.body.clientWidth + "px";
pkMainWrap.style.marginRight = "0px";
}
}
function openClientChat(){
callExternal("IChannelWindow_setRightAreaVisible", true);
}
function closeClientChat(){
callExternal("IChannelWindow_setRightAreaVisible", false);
}
function changeDefaultChat(){
this.jsIsRealyLoadedFlag = false;
window.jsChatPubComplete = false;
this.showJsChatPub = false;
var pkRightWrap = document.getElementById("pkRightWrap");
if(pkRightWrap)
{
pkRightWrap.style.display = "none";
}
resizeDefaultStyle();
callExternal("IChannelWindow_setRightAreaVisible", true);
}
function changeSelfChat(){
this.jsIsRealyLoadedFlag = true;
window.jsChatPubComplete = true;
this.showJsChatPub = true;
if(pkRightWrap)
{
pkRightWrap.style.display = "block";
}
resizeRightUI();
callExternal("IChannelWindow_setRightAreaVisible", false);
}
window.onresize = function () {
if(!window.jsChatPubComplete)
{
resizeDefaultStyle();
}
else
{
resizeRightUI();
}
}
function checkJsChatPubComplete(){
return window.jsChatPubComplete;
}