第一次提交

This commit is contained in:
dengtongyu committed 2018-12-03 17:31:53 +08:00
commit 8121362a03
4412 files changed
+1091845

No files matched your search

@@ -0,0 +1,40 @@
define(function(require, exports, module) {
var yyapi = require("../../lib/pkroom/yyapi");
var queue = [];
var face = {
saveHistory : function(item,type){
while(queue.length>=5){
queue.shift();
}
item.type = type;
var sid = yyapi.getChannelInfo().longId;
item.channelId = sid;
queue.push(item);
var cookietime = new Date();
cookietime.setTime(cookietime.getTime() + 1 * 60 * 1000);
$.cookie("chatPub_history",JSON.stringify(queue),{expires :cookietime});
},
readHistory : function(type){
var sid = yyapi.getChannelInfo().longId;
var str = $.cookie("chatPub_history");
var arr = [];
if(str == undefined)
return arr;
var jsonData = JSON.parse(str);
for(var i = 0; i < jsonData.length; i++)
{
var item = jsonData[i];
if((type == undefined || item.type == type) && item.channelId == sid)
{
item.isHistory = true;
arr.push(item);
}
}
return arr;
}
};
module.exports = face;
})
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,37 @@
define(function(require, exports, module) {
function setCookie(name,value,sec)
{
var exp = new Date();
exp.setTime(exp.getTime() + sec * 1000);
document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}
//读取cookies
function getCookie(name)
{
var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
if(arr=document.cookie.match(reg))
return unescape(arr[2]);
else
return null;
}
//删除cookies
function delCookie(name)
{
var exp = new Date();
exp.setTime(exp.getTime() - 1);
var cval=getCookie(name);
if(cval!=null)
document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}
var face = {
setCookie : setCookie,
getCookie : getCookie,
delCookie : delCookie
}
module.exports = face;
})
@@ -0,0 +1,83 @@
define(function(require, exports, module) {
var logger = require("./logger");
var indexId = 0;
var getNextId = function(){
return indexId ++;
}
var eventClass = function(){
var eventArray = [];
this.addEvent = function(name,fn){
// logger.debug(['event util addEvent',name,fn]);
var evt = {
name:name,
fn:fn
};
eventArray.push(evt);
}
this.removeEvent = function(name,fn){
// logger.debug(['event util removeEvent',name,fn]);
var newArr = [];
for(var i in eventArray){
var e = eventArray[i];
if(e.name == name && e.fn == fn){
// logger.debug("event util removeEvent found:"+name);
}else{
newArr.push(e);
}
}
eventArray = newArr;
}
this.trigerEvent = function(name,data){
// logger.debug(['event util trigerEvent',name,data]);
for(var i in eventArray){
var e = eventArray[i];
if(e && e.name == name){
// logger.debug(["event util trigerEvent found:",name,data]);
e.fn.apply(window,[data]);
}
}
}
this.getEvents = function(){
return eventArray;
}
};
var eventInstances = {};
/**
* 创建一个时间处理器实例,传一个名字,如果name为空则实例一个,如果不为空则返回已有的实例或者新建一个
* @prama 处理器名字,
* @return 事件处理实例
*/
var careteEventInstance = function(name){
if(!name){
return new eventClass();
}
if(name in eventInstances){
return eventInstances[name];
}
var instance = new eventClass();
eventInstances[name] = instance;
return instance;
}
module.exports = {
getInstance:careteEventInstance
};
window.eventUtil = module.exports;
});
@@ -0,0 +1,72 @@
define(function(require, exports, module) {
var logger = function(lv,args){};
logger.prototype={
log:function(){},
debug:function(){},
info:function(){},
warn:function(){},
error:function(){}
};
var enable = false;
window.enableLog=function(stat){
enable = !!stat;
}
if(location.href.indexOf("debug")!=-1 || (document.referrer||"").indexOf("debug")!=-1 ){
enable = true;
}
var loggerName = ["log", "info", "debug", "warn","error"];
var exp ;
var console = window.console;
if(console && enable){
exp = console;
}else{
exp = new logger();
}
for (var i in loggerName) {
var n = loggerName[i];
if(!exp[n]){
exp[n]=logger.prototype[n];
}
}
/**
* 格式化数字,显示未两位数,小于10前面加0
*/
var fillLen = function(n){
if(n<10){
n = "0"+n;
}
return String(n);
}
var fillLen3 = function(n){
if(n <10){
n = "00"+n;
}else if(n < 100){
n = "0"+n;
}
return String(n);
}
exp.time = function(){
var d = new Date();
var r = d.getFullYear()+"-"+ fillLen(1+d.getMonth())+"-"+fillLen(d.getDate());
r+=" "+fillLen(d.getHours())+":"+fillLen(d.getMinutes())+":"+fillLen(d.getSeconds())+"."+fillLen3(d.getMilliseconds());
return r;
}
module.exports = exp;
});
@@ -0,0 +1,221 @@
define(function(require, exports, module) {
jQuery = $;
/**
* jQuery MD5 hash algorithm function
*
* <code>
* Calculate the md5 hash of a String
* String $.md5 ( String str )
* </code>
*
* Calculates the MD5 hash of str using the 禄 RSA Data Security, Inc. MD5 Message-Digest Algorithm, and returns that hash.
* MD5 (Message-Digest algorithm 5) is a widely-used cryptographic hash function with a 128-bit hash value. MD5 has been employed in a wide variety of security applications, and is also commonly used to check the integrity of data. The generated hash is also non-reversable. Data cannot be retrieved from the message digest, the digest uniquely identifies the data.
* MD5 was developed by Professor Ronald L. Rivest in 1994. Its 128 bit (16 byte) message digest makes it a faster implementation than SHA-1.
* This script is used to process a variable length message into a fixed-length output of 128 bits using the MD5 algorithm. It is fully compatible with UTF-8 encoding. It is very useful when u want to transfer encrypted passwords over the internet. If you plan using UTF-8 encoding in your project don't forget to set the page encoding to UTF-8 (Content-Type meta tag).
* This function orginally get from the WebToolkit and rewrite for using as the jQuery plugin.
*
* Example
* Code
* <code>
* $.md5("I'm Persian.");
* </code>
* Result
* <code>
* "b8c901d0f02223f9761016cfff9d68df"
* </code>
*
* @alias Muhammad Hussein Fattahizadeh < muhammad [AT] semnanweb [DOT] com >
* @link http://www.semnanweb.com/jquery-plugin/md5.html
* @see http://www.webtoolkit.info/
* @license http://www.gnu.org/licenses/gpl.html [GNU General Public License]
* @param {jQuery} {md5:function(string))
* @return string
*/
(function($){
var rotateLeft = function(lValue, iShiftBits) {
return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits));
}
var addUnsigned = function(lX, lY) {
var lX4, lY4, lX8, lY8, lResult;
lX8 = (lX & 0x80000000);
lY8 = (lY & 0x80000000);
lX4 = (lX & 0x40000000);
lY4 = (lY & 0x40000000);
lResult = (lX & 0x3FFFFFFF) + (lY & 0x3FFFFFFF);
if (lX4 & lY4) return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
if (lX4 | lY4) {
if (lResult & 0x40000000) return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
else return (lResult ^ 0x40000000 ^ lX8 ^ lY8);
} else {
return (lResult ^ lX8 ^ lY8);
}
}
var F = function(x, y, z) {
return (x & y) | ((~ x) & z);
}
var G = function(x, y, z) {
return (x & z) | (y & (~ z));
}
var H = function(x, y, z) {
return (x ^ y ^ z);
}
var I = function(x, y, z) {
return (y ^ (x | (~ z)));
}
var FF = function(a, b, c, d, x, s, ac) {
a = addUnsigned(a, addUnsigned(addUnsigned(F(b, c, d), x), ac));
return addUnsigned(rotateLeft(a, s), b);
};
var GG = function(a, b, c, d, x, s, ac) {
a = addUnsigned(a, addUnsigned(addUnsigned(G(b, c, d), x), ac));
return addUnsigned(rotateLeft(a, s), b);
};
var HH = function(a, b, c, d, x, s, ac) {
a = addUnsigned(a, addUnsigned(addUnsigned(H(b, c, d), x), ac));
return addUnsigned(rotateLeft(a, s), b);
};
var II = function(a, b, c, d, x, s, ac) {
a = addUnsigned(a, addUnsigned(addUnsigned(I(b, c, d), x), ac));
return addUnsigned(rotateLeft(a, s), b);
};
var convertToWordArray = function(string) {
var lWordCount;
var lMessageLength = string.length;
var lNumberOfWordsTempOne = lMessageLength + 8;
var lNumberOfWordsTempTwo = (lNumberOfWordsTempOne - (lNumberOfWordsTempOne % 64)) / 64;
var lNumberOfWords = (lNumberOfWordsTempTwo + 1) * 16;
var lWordArray = Array(lNumberOfWords - 1);
var lBytePosition = 0;
var lByteCount = 0;
while (lByteCount < lMessageLength) {
lWordCount = (lByteCount - (lByteCount % 4)) / 4;
lBytePosition = (lByteCount % 4) * 8;
lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount) << lBytePosition));
lByteCount++;
}
lWordCount = (lByteCount - (lByteCount % 4)) / 4;
lBytePosition = (lByteCount % 4) * 8;
lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80 << lBytePosition);
lWordArray[lNumberOfWords - 2] = lMessageLength << 3;
lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29;
return lWordArray;
};
var wordToHex = function(lValue) {
var WordToHexValue = "", WordToHexValueTemp = "", lByte, lCount;
for (lCount = 0; lCount <= 3; lCount++) {
lByte = (lValue >>> (lCount * 8)) & 255;
WordToHexValueTemp = "0" + lByte.toString(16);
WordToHexValue = WordToHexValue + WordToHexValueTemp.substr(WordToHexValueTemp.length - 2, 2);
}
return WordToHexValue;
};
var uTF8Encode = function(string) {
string = string.replace(/\x0d\x0a/g, "\x0a");
var output = "";
for (var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
output += String.fromCharCode(c);
} else if ((c > 127) && (c < 2048)) {
output += String.fromCharCode((c >> 6) | 192);
output += String.fromCharCode((c & 63) | 128);
} else {
output += String.fromCharCode((c >> 12) | 224);
output += String.fromCharCode(((c >> 6) & 63) | 128);
output += String.fromCharCode((c & 63) | 128);
}
}
return output;
};
$.extend({
md5: function(string) {
var x = Array();
var k, AA, BB, CC, DD, a, b, c, d;
var S11=7, S12=12, S13=17, S14=22;
var S21=5, S22=9 , S23=14, S24=20;
var S31=4, S32=11, S33=16, S34=23;
var S41=6, S42=10, S43=15, S44=21;
string = uTF8Encode(string);
x = convertToWordArray(string);
a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476;
for (k = 0; k < x.length; k += 16) {
AA = a; BB = b; CC = c; DD = d;
a = FF(a, b, c, d, x[k+0], S11, 0xD76AA478);
d = FF(d, a, b, c, x[k+1], S12, 0xE8C7B756);
c = FF(c, d, a, b, x[k+2], S13, 0x242070DB);
b = FF(b, c, d, a, x[k+3], S14, 0xC1BDCEEE);
a = FF(a, b, c, d, x[k+4], S11, 0xF57C0FAF);
d = FF(d, a, b, c, x[k+5], S12, 0x4787C62A);
c = FF(c, d, a, b, x[k+6], S13, 0xA8304613);
b = FF(b, c, d, a, x[k+7], S14, 0xFD469501);
a = FF(a, b, c, d, x[k+8], S11, 0x698098D8);
d = FF(d, a, b, c, x[k+9], S12, 0x8B44F7AF);
c = FF(c, d, a, b, x[k+10], S13, 0xFFFF5BB1);
b = FF(b, c, d, a, x[k+11], S14, 0x895CD7BE);
a = FF(a, b, c, d, x[k+12], S11, 0x6B901122);
d = FF(d, a, b, c, x[k+13], S12, 0xFD987193);
c = FF(c, d, a, b, x[k+14], S13, 0xA679438E);
b = FF(b, c, d, a, x[k+15], S14, 0x49B40821);
a = GG(a, b, c, d, x[k+1], S21, 0xF61E2562);
d = GG(d, a, b, c, x[k+6], S22, 0xC040B340);
c = GG(c, d, a, b, x[k+11], S23, 0x265E5A51);
b = GG(b, c, d, a, x[k+0], S24, 0xE9B6C7AA);
a = GG(a, b, c, d, x[k+5], S21, 0xD62F105D);
d = GG(d, a, b, c, x[k+10], S22, 0x2441453);
c = GG(c, d, a, b, x[k+15], S23, 0xD8A1E681);
b = GG(b, c, d, a, x[k+4], S24, 0xE7D3FBC8);
a = GG(a, b, c, d, x[k+9], S21, 0x21E1CDE6);
d = GG(d, a, b, c, x[k+14], S22, 0xC33707D6);
c = GG(c, d, a, b, x[k+3], S23, 0xF4D50D87);
b = GG(b, c, d, a, x[k+8], S24, 0x455A14ED);
a = GG(a, b, c, d, x[k+13], S21, 0xA9E3E905);
d = GG(d, a, b, c, x[k+2], S22, 0xFCEFA3F8);
c = GG(c, d, a, b, x[k+7], S23, 0x676F02D9);
b = GG(b, c, d, a, x[k+12], S24, 0x8D2A4C8A);
a = HH(a, b, c, d, x[k+5], S31, 0xFFFA3942);
d = HH(d, a, b, c, x[k+8], S32, 0x8771F681);
c = HH(c, d, a, b, x[k+11], S33, 0x6D9D6122);
b = HH(b, c, d, a, x[k+14], S34, 0xFDE5380C);
a = HH(a, b, c, d, x[k+1], S31, 0xA4BEEA44);
d = HH(d, a, b, c, x[k+4], S32, 0x4BDECFA9);
c = HH(c, d, a, b, x[k+7], S33, 0xF6BB4B60);
b = HH(b, c, d, a, x[k+10], S34, 0xBEBFBC70);
a = HH(a, b, c, d, x[k+13], S31, 0x289B7EC6);
d = HH(d, a, b, c, x[k+0], S32, 0xEAA127FA);
c = HH(c, d, a, b, x[k+3], S33, 0xD4EF3085);
b = HH(b, c, d, a, x[k+6], S34, 0x4881D05);
a = HH(a, b, c, d, x[k+9], S31, 0xD9D4D039);
d = HH(d, a, b, c, x[k+12], S32, 0xE6DB99E5);
c = HH(c, d, a, b, x[k+15], S33, 0x1FA27CF8);
b = HH(b, c, d, a, x[k+2], S34, 0xC4AC5665);
a = II(a, b, c, d, x[k+0], S41, 0xF4292244);
d = II(d, a, b, c, x[k+7], S42, 0x432AFF97);
c = II(c, d, a, b, x[k+14], S43, 0xAB9423A7);
b = II(b, c, d, a, x[k+5], S44, 0xFC93A039);
a = II(a, b, c, d, x[k+12], S41, 0x655B59C3);
d = II(d, a, b, c, x[k+3], S42, 0x8F0CCC92);
c = II(c, d, a, b, x[k+10], S43, 0xFFEFF47D);
b = II(b, c, d, a, x[k+1], S44, 0x85845DD1);
a = II(a, b, c, d, x[k+8], S41, 0x6FA87E4F);
d = II(d, a, b, c, x[k+15], S42, 0xFE2CE6E0);
c = II(c, d, a, b, x[k+6], S43, 0xA3014314);
b = II(b, c, d, a, x[k+13], S44, 0x4E0811A1);
a = II(a, b, c, d, x[k+4], S41, 0xF7537E82);
d = II(d, a, b, c, x[k+11], S42, 0xBD3AF235);
c = II(c, d, a, b, x[k+2], S43, 0x2AD7D2BB);
b = II(b, c, d, a, x[k+9], S44, 0xEB86D391);
a = addUnsigned(a, AA);
b = addUnsigned(b, BB);
c = addUnsigned(c, CC);
d = addUnsigned(d, DD);
}
var tempValue = wordToHex(a) + wordToHex(b) + wordToHex(c) + wordToHex(d);
return tempValue.toLowerCase();
}
});
})(jQuery);
})
@@ -0,0 +1,118 @@
define(function(require, exports, module){
var yyapi = require("../../lib/pkroom/yyapi");
var util = require("../../lib/pkroom/util");
var expfn = {
filterAirTicket : function(msg){
//yy://pd-[sid=2710&subid=999315&type=wonder_channel]
//yy://pd-[sid=2710&amp;subid=999315&amp;type=wonder_channel]
var firstIndex = msg.indexOf("yy://pd-");
var t = this ;
if(firstIndex >= 0){
msg = msg.replace(new RegExp("yy://pd-\\[sid=(\\d+)&(amp;)?subid=(\\d+)(&(amp;)?type=wonder_channel)?\\]","gm"),
'<span class="air-ticket-pd" ><a href="javascript:#;" onclick="window.$gotoChannel(this)" data-sid="$1", data-subid="$3">$1</a></span>' );
}
return msg;
},
filterAirTicket2 : function(msg){
//yy://qun-[gaid=14113059&action=add]
var firstIndex = msg.indexOf("yy://qun-");
if(firstIndex >= 0){
msg = msg.replace(new RegExp("yy://qun-\\[gaid=(\\d+)(&(amp;)?action=add)?\\]","gm"),
'<span class="group-ticket-pd" ><a href=\"yy://qun-[gaid=$1&action=add]\" target="_blank">Y群$1</a></span>' );
//'<a href=\"yy://qun-[gaid=$1&action=add]\" target="_blank"><font color="#ff0000">[加Y群($1)]</font></a>' );
}
return msg;
},
filterCustomImage : function(msg){
//[Image]4a28fd248c0037aeb15a6dd5a37de713[/Image]
var exp = new RegExp("\\[Image\\](.+)\\[/Image\\]","gm");
var imgHolder = '<img data-key="$1" class="pub-custom-img" src="http://vipweb.bs2cdn.yy.com/vipinter_0f0e1b0411b94bf9bdfb41fae0906edb.gif"/>';
msg = msg.replace(exp,imgHolder);
return msg;
},
filterSysMsg : function(msg){
msg = msg.replace(/\[\[U\]/gm,"") ;
msg = msg.replace(/\[\/U\]\]/gm, "") ;
msg = this.filterAirTicket(msg);
msg = this.filterAirTicket2(msg);
//msg = util.html_encode(msg);
return msg;
},
fileterWeiDeng : function(msg,weidengs){
if(msg && weidengs)
{
for(var i = 0; i < weidengs.length; i++)
{
var weidengObj = weidengs[i];
if(weidengObj)
{
if(weidengObj.type == 0)
msg = msg + '<span class="pub-weideng-img vip-jinzuan '+ weidengObj.name +'"></span>';
else if(weidengObj.type == 1)
msg = msg + '<span class="pub-weideng-img pk-jinzuan '+ weidengObj.name +'"></span>';
}
}
}
return msg;
},
fileterLianghao : function(lianhao){
var msg = "";
if(lianhao && lianhao!="" && lianhao!=0)
{
msg = '<img class="lianghao-img" src="http://dl.vip.yy.com/icons/minicard_vip_prettynum_'+lianhao+'.png"/>';
}
return msg;
},
fileterIdentity : function(identitys){
var msg = "";
if(identitys )
{
for(var i = 0; i < identitys.length; i++)
{
msg += '<img class="identity-img" title="'+identitys[i].desc +'" alt="'+identitys[i].desc +'" src="'+identitys[i].url+'"/>';
}
}
return msg;
},
fileterYYLevel: function(yylevel){
var msg = "";
if(yylevel < 256)
return msg;
if(yylevel >=1 && yylevel<=3 )
{
msg += '<span class="jifen-img jifen-1"></span>';
}
else if(yylevel >=4 && yylevel<=15 )
{
msg += '<span class="jifen-img jifen-2"></span>';
}
else if(yylevel >=16 && yylevel<=63 )
{
msg += '<span class="jifen-img jifen-3"></span>';
}
else if(yylevel >=64 && yylevel<=255 )
{
msg += '<span class="jifen-img jifen-4"></span>';
}
else if(yylevel >=256 && yylevel<=1023 )
{
msg += '<span class="jifen-img jifen-5"></span>';
}
else if(yylevel >=1024 )
{
msg += '<span class="jifen-img jifen-6"></span>';
}
return msg;
}
}
window.$gotoChannel = function(e){
var sid = e.getAttribute("data-sid");
var subid = e.getAttribute("data-subid");
yyapi.gotoChannel(parseInt(sid),parseInt(subid));
}
module.exports= expfn;
})
@@ -0,0 +1,240 @@
define(function(require, exports, module) {
var login = require('../../common/login');
var util = require("./util"),
eventUtil = require("./eventUtil");
var exp={
showLoginBox:function(){
// var url = location.protocol + '//' + location.host +'/index/wakeudblogin';
// eventUtil.getInstance("user").trigerEvent("showLoginBox",{url:url});
// UDB.sdk.PCWeb.popupOpenLgn(url, 'loginCallback','');
// if(location.pathname=="/spy"){
//this.showMultiLoginBox();
// }else{
// this.showYYLoginBox();
// }
showUdbLogin();
//this.showMultiLoginBox();
},
showYYLoginBox:function(){
showUdbLogin();
},
/*
* 显示集成第三方登录按钮的登陆框
*/
showMultiLoginBox:function(){
//remove old elemets
var _this = this;
var openBox;
var cleanup = function(){
$('.multi-login-box-mask,.multi-login-box').remove();
}
var openThirdBox = function(url){
var openOpts = 'width=700, height=680, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, location=yes, resizable=no, status=no,target=_blank';
openBox = window.open(url,'qq',openOpts);
}
window.closeBox = function(refresh){
if(openBox){
openBox.close();
}
if(refresh){
location.reload();
}
}
window.showLoginPopTip = function(code){
cleanup();
if(code == "-10003"){//第三方登录新用户
createTipBox();
closeBox(false);
} else if(code =="-10004"){
createBindedBox();
closeBox(false);
}else{
closeBox(true);
}
}
var showBox = function(type){
var callback = encodeURIComponent(location.protocol + '//' + location.host +'/assets/static/login_success.html');
var uri = 'http://uaas.yy.com/open/yyauth/1j4y1211/${type}/${appid}?callback=${callback}';
var opts = {
callback:callback
};
switch(type){
case "yy":
_this.showYYLoginBox();
cleanup();
return false;
break;
case "qq":
opts['type'] = 2;
opts['appid'] = 101154992;
break;
case "sina":
opts['type'] = 1;
opts['appid'] = 2822259651;
break;
case "baidu":
opts['type'] = 4;
opts['appid'] = 'ArCbjaE1dh0V2rj7GN8P2qal';
break;
}
var fmturi = util.format(uri,opts);
openThirdBox(fmturi);
}
var createLoginBox = function(){
var mask ='<div class="multi-login-box-mask"></div>';
var box = '<div class="multi-login-box">'
+'<h2>帐号登录</h2>'
+'<div class="multi-login-cont">'
+' <a href="/" data-type="yy" class="login-yy"></a>'
+' <a href="/" data-type="qq" class="login-qq"></a>'
+' <a href="/" data-type="sina" class="login-sina"></a>'
+' <a href="/" data-type="baidu" class="login-baidu"></a>'
+' <div class="login-vline"></div>'
+'</div>'
+'<div class="multi-login-tip">注:首次使用第三方登录的用户,该功能无法使用。</div>'
+'<a href="#" class="multi-login-box-close" title="关闭">&nbsp;</a>'
+'</div>';
var domMask = $(mask);
var domBox = $(box);
domBox.on("click",".multi-login-cont a",function(){
var type = $(this).attr("data-type");
showBox(type);
return false;
})
domBox.on("click",".multi-login-box-close",function(){
cleanup();
return false;
})
$('body').append(domMask).append(domBox);
}
var createTipBox = function(){
var mask ='<div class="multi-login-box-mask"></div>';
var box = '<div class="multi-login-box">'
+'<h2>帐号登录</h2>'
+'<div class="multi-login-cont multi-login-etip-cont">'
+'<div class="multi-login-error-tip"><p>抱歉,自2015年3月20日起,</p><p>第三方登录功能已经停用,请使用YY账号登录。</p></div>'
+'</div>'
+'<div class="multi-login-foot">'
+'<div class="multi-login-cancel-btn"><a href="#">取消</a></div>'
+'<div class="multi-login-yylogin-btn"><a href="#">YY账户登录</a></div>'
+'</div>'
+'<a href="#" class="multi-login-box-close" title="关闭">&nbsp;</a>'
+'</div>';
var domMask = $(mask);
var domBox = $(box);
domBox.on("click",".multi-login-cancel-btn a",function(){
cleanup();
createLoginBox();
return false;
})
domBox.on("click",".multi-login-yylogin-btn a",function(){
cleanup();
showBox("yy");
return false;
})
domBox.on("click",".multi-login-box-close",function(){
cleanup();
return false;
})
$('body').append(domMask).append(domBox);
}
var createBindedBox = function(){
var thirdyy = $.cookie("third_yy_no");
var mask ='<div class="multi-login-box-mask"></div>';
var box = '<div class="multi-login-box">'
+'<h2>帐号登录</h2>'
+'<div class="multi-login-cont multi-login-etip-cont">'
+'<div class="multi-login-error-tip"><p>抱歉,第三方功能已经停止使用,请使用已绑定的<br/>YY账户:<span class="binded-yy">'
+ thirdyy
+'</span> <a href="#" class="copy-yynum">复制</a></p></div>'
+'</div>'
+'<div class="multi-login-foot">'
+'<div class="multi-login-cancel-btn"><a href="#">取消</a></div>'
+'<div class="multi-login-yylogin-btn"><a href="#">YY账户登录</a></div>'
+'</div>'
+'<a href="#" class="multi-login-box-close" title="关闭">&nbsp;</a>'
+'</div>';
var domMask = $(mask);
var domBox = $(box);
domBox.on("click",".multi-login-cancel-btn a",function(){
cleanup();
createLoginBox();
return false;
})
domBox.on("click",".multi-login-yylogin-btn a",function(){
cleanup();
showBox("yy");
return false;
})
domBox.on("click",".multi-login-box-close",function(){
cleanup();
return false;
})
domBox.on("click",".copy-yynum",function(){
alert("您的浏览器不支持手动复制功能,请手动复制!");
return false;
})
$('body').append(domMask).append(domBox);
}
cleanup();
createLoginBox();
},
logout:function() {
var getDelCookieURL = location.protocol + '//' + location.host +'/index/logout';
var done = function(data){
if ("1" == data.success) {
UDB.sdk.PCWeb
.deleteCrossmainCookieWithCallBack(
data.delCookieURL,
function() {
//退出成功后调用触发退出事件
eventUtil.getInstance("user").trigerEvent("logout");
location.reload()
});
} else {
alert(data.errMsg);
}
}
$.post(
getDelCookieURL,
function(data) {
done(data);
}, "json");
},
getMyUid:function(){
return $.cookie("yyuid") || 0;
}
}
module.exports = exp;
window.user= exp;
});
@@ -0,0 +1,265 @@
define(function (require, exports, module) {
//判断当前日期是否大于某个日期
// yyyy-MM-dd HH:mm:ss
var greaterThanTime = function (time) {
var now = new Date();
var end = parseDate(time);
var ret = false;
if (now.getTime() > end.getTime()) {
ret = true;
}
// logger.debug([formatTime(now),">", formatTime(end),ret]);
return ret;
}
//跟greaterThanTime恰好相反
var lessThanTime = function (t) {
return !greaterThanTime(t);
}
//yyyy-MM-dd HH:mm:ss --> Date objet
var parseDate = function (time) {
var t = String(time);
var year = parseInt(t.substring(0, 4)),
month = parseInt(t.substring(5, 7)),
day = parseInt(t.substring(8, 10)),
hour = parseInt(t.substring(11, 13)),
min = parseInt(t.substring(14, 16)),
sec = parseInt(t.substring(17, 19));
// logger.debug([year,month,day,hour,min,sec])
var end = new Date();
end.setFullYear(year);
end.setMonth(month - 1, day);
end.setHours(hour);
end.setMinutes(min);
end.setSeconds(sec);
end.setMilliseconds(0);
return end;
}
var parseXML = function (data) {
var xml, tmp;
if (window.DOMParser) { // Standard
tmp = new DOMParser();
xml = tmp.parseFromString(data, "text/xml");
} else { // IE
xml = new ActiveXObject("Microsoft.XMLDOM");
xml.async = "false";
xml.loadXML(data);
}
tmp = xml.documentElement;
if (!tmp || !tmp.nodeName || tmp.nodeName === "parsererror") {
return null;
}
return xml;
}
var xmlToJson = function (obj) {
if (this == null) return null;
var retObj = new Object;
buildObjectNode(retObj,
/*jQuery*/
obj);
return retObj;
function buildObjectNode(cycleOBJ,
/*Element*/
elNode) {
/*NamedNodeMap*/
var nodeAttr = elNode.attributes;
if (nodeAttr != null) {
if (nodeAttr.length && cycleOBJ == null) cycleOBJ = new Object;
for (var i = 0; i < nodeAttr.length; i++) {
cycleOBJ[nodeAttr[i].name] = nodeAttr[i].value;
}
}
var nodeText = "text";
if (elNode.text == null) nodeText = "textContent";
/*NodeList*/
var nodeChilds = elNode.childNodes;
if (nodeChilds != null) {
if (nodeChilds.length && cycleOBJ == null) cycleOBJ = new Object;
for (var i = 0; i < nodeChilds.length; i++) {
if (nodeChilds[i].tagName != null) {
if (nodeChilds[i].childNodes[0] != null && nodeChilds[i].childNodes.length <= 1 && (nodeChilds[i].childNodes[0].nodeType == 3 || nodeChilds[i].childNodes[0].nodeType == 4)) {
if (cycleOBJ[nodeChilds[i].tagName] == null) {
cycleOBJ[nodeChilds[i].tagName] = nodeChilds[i][nodeText];
} else {
if (typeof (cycleOBJ[nodeChilds[i].tagName]) == "object" && cycleOBJ[nodeChilds[i].tagName].length) {
cycleOBJ[nodeChilds[i].tagName][cycleOBJ[nodeChilds[i].tagName].length] = nodeChilds[i][nodeText];
} else {
cycleOBJ[nodeChilds[i].tagName] = [cycleOBJ[nodeChilds[i].tagName]];
cycleOBJ[nodeChilds[i].tagName][1] = nodeChilds[i][nodeText];
}
}
} else {
if (nodeChilds[i].childNodes.length) {
if (cycleOBJ[nodeChilds[i].tagName] == null) {
cycleOBJ[nodeChilds[i].tagName] = new Object;
buildObjectNode(cycleOBJ[nodeChilds[i].tagName], nodeChilds[i]);
} else {
if (cycleOBJ[nodeChilds[i].tagName].length) {
cycleOBJ[nodeChilds[i].tagName][cycleOBJ[nodeChilds[i].tagName].length] = new Object;
buildObjectNode(cycleOBJ[nodeChilds[i].tagName][cycleOBJ[nodeChilds[i].tagName].length - 1], nodeChilds[i]);
} else {
cycleOBJ[nodeChilds[i].tagName] = [cycleOBJ[nodeChilds[i].tagName]];
cycleOBJ[nodeChilds[i].tagName][1] = new Object;
buildObjectNode(cycleOBJ[nodeChilds[i].tagName][1], nodeChilds[i]);
}
}
} else {
cycleOBJ[nodeChilds[i].tagName] = nodeChilds[i][nodeText];
}
}
}
}
}
}
}
var o = {
xmlToJson:xmlToJson,
parseXML: parseXML,
parseDate: parseDate,
lessThanTime: lessThanTime,
greaterThanTime: greaterThanTime,
/*
* 获取 url 中指定变量的值
* @param {[String]} key name [变量名]
* @param {[String]} url [url地址]
* */
getUrlParam: function (name, url) {
var re = new RegExp("[\\?&#]" + name + "=([^&#]+)", "gi");
var ma = (url || location.href).match(re);
var strArr;
if (ma && ma.length > 0) {
strArr = (ma[ma.length - 1]).split("=");
if (strArr && strArr.length > 1) {
return strArr[1];
}
return ''
}
return '';
},
now: Date.now || function () { return new Date().getTime(); },
debounce: function (func, wait, immediate) {
var timeout, args, context, timestamp, result;
var later = function () {
var last = o.now() - timestamp;
if (last < wait) {
timeout = setTimeout(later, wait - last);
} else {
timeout = null;
if (!immediate) {
result = func.apply(context, args);
context = args = null;
}
}
};
return function () {
context = this;
args = arguments;
timestamp = o.now();
var callNow = immediate && !timeout;
if (!timeout) {
timeout = setTimeout(later, wait);
}
if (callNow) {
result = func.apply(context, args);
context = args = null;
}
return result;
};
},
imageLoad: function (element, options) {
var imgs = (element instanceof $ ? element : $(element)).find('img');
imgs.length && imgs.on('load', function () {
$.isFunction(options.done) && options.done(this)
}).one('error', function () {
$.isFunction(options.fail) && options.fail(this)
})
},
format: function (text, obj) {
var c = obj || {};
var b = text;
for (var a in c) {
if (c.hasOwnProperty(a)) {
b = b.replace(new RegExp("\\$\\{" + a + "\\}", "gm"), c[a]);
}
}
return b;
},
htmlEscape: function (input) {
if (typeof (input) !== "string")
return input;
var result = [];
var length = input.length;
for (var i = 0; i < length; i++) {
var c = input.charAt(i).toString();
if (c == '&') {
result.push("&amp;");
} else if (c == '\"') {
result.push("&quot;");
} else if (c == '<') {
result.push("&lt;");
} else if (c == '>') {
result.push("&gt;");
} else if (c == '\'') {
result.push("&#39;");
} else if (c == '\\') {
result.push("&#092;");
} else {
result.push(c);
}
}
return result.join("");
},
JSONString: (window.JSON && JSON.stringify) || function (vContent) {
if (vContent instanceof Object) {
var sOutput = "";
if (vContent.constructor === Array) {
for (var nId = 0; nId < vContent.length; sOutput += this.JSONString(vContent[nId]) + ",", nId++);
return "[" + sOutput.substr(0, sOutput.length - 1) + "]";
}
if (vContent.toString !== Object.prototype.toString) {
return "\"" + vContent.toString().replace(/"/g, "\\$&") + "\"";
}
for (var sProp in vContent) {
sOutput += "\"" + sProp.replace(/"/g, "\\$&") + "\":" + this.JSONString(vContent[sProp]) + ",";
}
return "{" + sOutput.substr(0, sOutput.length - 1) + "}";
}
return typeof vContent === "string" ? "\"" + vContent.replace(/"/g, "\\$&") + "\"" : String(vContent);
},
trim : function(str){
str = str.replace(/\s+/g,"");
return str;
},
removeHtmlTab :function(tab) {
return tab;//删除所有HTML标签
} ,
html_encode:function(str)
{
var s = "";
if (!str || str.length == 0) return "";
s = str.replace(/&/g, "&gt;");
s = s.replace(/</g, "&lt;");
s = s.replace(/>/g, "&gt;");
s = s.replace(/ /g, "&nbsp;");
s = s.replace(/\'/g, "&#39;");
s = s.replace(/\"/g, "&quot;");
s = s.replace(/\n/g, "<br>");
return s;
}
};
module.exports = o;
})
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,237 @@
define(function (require, exports, module) {
var Base64Tool = require("../../extend/BASE64");
var callExternal = window.parent.callExternal || function () { return {} };
var yy = window.parent.yy || {};
var YYUtils = {
parseChannelInfo: function (result) {
var channelInfo = {};
channelInfo.ret = 0;
channelInfo.longId = result.long_id;
channelInfo.shortId = result.short_id;
channelInfo.name = unescape(result.name);
channelInfo.userCount = result.user_count;
channelInfo.totalUserCount = result.total_user_count;
channelInfo.channelType = result.channel_type;
channelInfo.channelPoints = result.channel_points;
return channelInfo;
},
parseUserInfo: function parseUserInfo(result) {
var userInfo = {};
userInfo.ret = 0;
if (typeof (result) == "string") {
result = eval('(' + result + ')');
}
else if (result) {
result.name = unescape(String(result.name))
result.sign = unescape(String(result.sign))
}
userInfo.uid = result.uid;
userInfo.nick = userInfo.name = unescape(result.name);
userInfo.yyId = userInfo.imId = result.imid;
userInfo.role = result.role;
userInfo.points = result.points;
userInfo.level = result.level;
userInfo.gender = userInfo.sex = result.sex;
userInfo.sign = unescape(result.sign);
userInfo.vip = result.vip;
userInfo.vipLevel = result.vip_level;
userInfo.contribution = result.contribution;
return userInfo;
},
parseImUserInfo: function (result) {
var userInfo = {};
userInfo.ret = 0;
var retObj = callExternal("IIM_GetIMUserInfoEx", result.uid);
userInfo.uid = parseInt(result.uid);
userInfo.nick = userInfo.name = unescape(result.nick_name);
userInfo.yyId = userInfo.imId = result.imid;
userInfo.role = 0;
userInfo.points = 0;
userInfo.level = 0;
userInfo.gender = userInfo.sex = 0;
userInfo.sign = "";
userInfo.vip = 0;
userInfo.vipLevel = 0;
userInfo.contribution = 0;
userInfo.age = retObj.age;
userInfo.area = retObj.area;
userInfo.city = retObj.city;
userInfo.province = retObj.province;
userInfo.birthday = "";
return userInfo;
}
};
var obj =
{
tempChannelInfo:null,
tempSubChannelInfo:null,
getChannelInfo: function () {
if(this.tempChannelInfo)
return this.tempChannelInfo;
var result = callExternal("IChannel_GetCurrentChannelInfo");
if (result.ret == 0) {
this.tempChannelInfo = YYUtils.parseChannelInfo(result);
return this.tempChannelInfo;
}
else {
return result;
}
},
getSubChannelInfo: function () {
if(this.tempSubChannelInfo)
return this.tempChannelInfo;
var result = callExternal("IChannel_GetCurrentSubChannelInfo");
if (result.ret == 0) {
this.tempSubChannelInfo = YYUtils.parseChannelInfo(result);
return this.tempSubChannelInfo;
}
else {
return result;
}
},
myUserTemp: null,
getMyUserInfo: function () {
if (this.myUserTemp)
return this.myUserTemp;
var result = callExternal("IUser_GetCurrnetUserInfo");
if (result.ret == 0) {
this.myUserTemp = result = YYUtils.parseUserInfo(result);
return result;
}
else {
return result;
}
},
usersTemp: [],
getUserInfo: function(uid) {
if (this.usersTemp[uid])
return this.usersTemp[uid];
var result = callExternal("IUser_GetUserInfo",uid);
if (result.ret == 0) {
this.usersTemp[uid] = YYUtils.parseUserInfo(result);
return result;
}
else {
return result;
}
},
addChatPubMsgListener: function (fn) {
if (yy.channel && yy.channel.chat)
yy.channel.chat.addEventListener("YY_CHANNEL_CHAT1", fn);
},
addChatFromPubMsgListener: function (fn) {
if (yy.channel && yy.channel.chat)
yy.channel.chat.addEventListener("YY_CHANNEL_CHAT_FROM1", fn);
},
addRightMenuListener: function (fn) {
if (yy.channel && yy.channel.userListPopMenu)
yy.channel.userListPopMenu.addEventListener("YY_POP_MENU_CLICKED", fn);
},
addFontInfoListener: function (fn) {
if (yy.channel)
yy.channel.addEventListener("YY_CHANNEL_INPUT_FONT_INFO_CHANGED", fn);
},
getChannelDetail: function () {
return this.getSubChannelInfo();
},
getFontInfo: function () {
return callExternal("IChannelWindow_getCurrentFontInfo");
},
showSmilebox:function(x,y){
var str = '{\"FontSetting\": 1, \"VipRightPart\": 1, \"VipFacePage\":1, \"GameSmiliesPage\":1, \"VipMallPage\":1, \"VipMallFaces\":1,\"xPos\":'+ x +',\"yPos\":' + y +'}';
str = Base64Tool.encodeBase64(str);
callExternal("IChannelWindow_showChannelSmileWindowWithControl", str);
},
addSmileboxListener: function (fn) {
if (yy.channel && yy.channel)
yy.channel.addEventListener("YY_CHANNEL_SMILE_SELECTED", fn);
},
addSysMessageListener: function (fn) {
if (yy.channel && yy.channel.chat)
yy.channel.chat.addEventListener("YY_CHANNEL_SYSTEM_MESSAGE", fn);
},
addSysMessageListener2: function (fn) {
if (yy.channel && yy.channel.chat)
yy.channel.chat.addEventListener("YY_CHANNEL_SYSTEM_MESSAGE_EX", fn);
},
addChannelStartPrivateChatListener: function (fn) {
if (yy.channel && yy.channel)
yy.channel.addEventListener("YY_CHANNEL_START_PRIVATE_CHAT", fn);
},
gotoChannel : function(sid,subsid){
callExternal("IChannel_JoinChannel",0,sid,subsid,sid,"");
},
getImageInfo : function(imageKey){
return callExternal("IChannelWindow_getImageInfo", imageKey)
},
getClipboardImage : function(){
return callExternal("IChannelWindow_getClipboardImage")
},
openUrl:function(url){
callExternal("ISecurityInternal_OpenUrl", url);
},
showUserMenu:function(uid,userName,userRole){
var sid = this.getChannelInfo().longId;
callExternal("IChannelWindow_showChannelUserMenu", uid, sid, userName, userRole);
},
send: function (cmd, msg) {
var res;
switch (cmd) {
case "sendMessage":
res = callExternal("IChannelChatInternal_Chat", msg);
res.result = res.ret;
break;
case "sendPrivateMessage":
res = callExternal("IChannelChatInternal_ChatTo", parseInt(msg.toUid),msg.msg);
res.result = res.ret;
break;
}
return res;
},
resizeUI : function(){
var newHeight = $(window).height();
if (newHeight < 155)
newHeight = 155;
$(".pkChat .chat-cont").css("height", newHeight + "px");
var chatOprH = $(".chat-opr").height();
$(".pkChat .private-chat").css("bottom",chatOprH + 2);
return newHeight;
},
//关闭私聊,计算尺寸
minChatBox:function(){
var contHeight = this.resizeUI();
var chatOprH = $(".chat-opr").height();
$(".private-chat").css("height","0px");
$(".chat-list").css("height", contHeight- 5 - chatOprH + "px");
$(".chat-text .slimScrollDiv").css("height", contHeight- 5 - chatOprH + "px");
},
//打开私聊,计算尺寸
maxChatBox:function(){
var contHeight = this.resizeUI();
var chatOprH = $(".chat-opr").height();
$(".private-chat").css("height","160px");
var privateHeight = $(".private-chat").height();
$(".chat-list").css("height", contHeight- privateHeight - chatOprH + "px");
$(".chat-text .slimScrollDiv").css("height", contHeight- privateHeight - chatOprH + "px");
},
isReady: true
};
module.exports = obj;
});