Authored by 郭成尧

let-to-var

... ... @@ -4,4 +4,4 @@ coverage
public/static/js-sdk
public/static/yas-jssdk
public/js/home/jquery.upload.js
public/js/activity/live/yas_live_data.js
public/js/activity/live
... ...
... ... @@ -4,26 +4,26 @@
* 直播或重播页面上方浮动的下载提示
* 用于跳转到对应的app页面或进入下载页面
*/
let is_wechat = false; //是否在微信中
let is_weibo = false; //是否在微博中
let is_ios = false; //是否是ios
let is_android = false; //是否是android
let is_pod = false;
let is_pc = false;
let $btn_download; //下载按钮
let $btn_close; //关闭按钮
let $download_head_wrapper; //下载div最外部分
let $download_head; //下载div fixed部分
let $download_msg; //在微信中点击下载弹出的提示部分
//let app_ios = 'mtmv://lives?id=6141903674538004481';
let app_ios = 'yohoefashion4In1://'; //ios的scheme
let app_android = 'yohoefashion4In1://'; //android的scheme
let download_ios = 'https://itunes.apple.com/cn/app/id530419467?ls=1&mt=8'; //appstore下载地址
let download_android = 'http://yoho-apps.qiniudn.com/Yoho.apk'; //apk下载地址
let queryArr = []; //地址栏参数
let date_start; //点击下载按钮的时间,用于计算超时的时候跳转到对应下载页面
var is_wechat = false; //是否在微信中
var is_weibo = false; //是否在微博中
var is_ios = false; //是否是ios
var is_android = false; //是否是android
var is_pod = false;
var is_pc = false;
var $btn_download; //下载按钮
var $btn_close; //关闭按钮
var $download_head_wrapper; //下载div最外部分
var $download_head; //下载div fixed部分
var $download_msg; //在微信中点击下载弹出的提示部分
//var app_ios = 'mtmv://lives?id=6141903674538004481';
var app_ios = 'yohoefashion4In1://'; //ios的scheme
var app_android = 'yohoefashion4In1://'; //android的scheme
var download_ios = 'https://itunes.apple.com/cn/app/id530419467?ls=1&mt=8'; //appstore下载地址
var download_android = 'http://yoho-apps.qiniudn.com/Yoho.apk'; //apk下载地址
var queryArr = []; //地址栏参数
var date_start; //点击下载按钮的时间,用于计算超时的时候跳转到对应下载页面
/**
* 通过iframe的方式试图打开APP,如果能正常打开,会直接切换到APP,并自动阻止a标签的默认行为
... ... @@ -32,8 +32,8 @@ let date_start; //銝蝸嚗鈭恣蝞歲頧
* @param link 对应的下载地址
*/
function openAppOrLink(app, link) {
let ifrSrc;
let ifr;
var ifrSrc;
var ifr;
if (is_android) {
//安卓基本上打不开app,只能打开下载地址。。。
date_start = new Date();
... ... @@ -46,8 +46,8 @@ function openAppOrLink(app, link) {
document.body.appendChild(ifr);
setTimeout(function() {
let date_end = new Date();
/*let p = document.createElement('p');
var date_end = new Date();
/*var p = document.createElement('p');
p.innerHTML = date_end - date_start
document.body.appendChild(p);*/
if (date_end.getTime() - date_start.getTime() < 1300) {
... ... @@ -69,7 +69,7 @@ function openAppOrLink(app, link) {
if (!is_pod) {
document.location.href = app;
setTimeout(function() {
let date_end = new Date();
var date_end = new Date();
if (!is_pod) {
if (date_end.getTime() - date_start.getTime() < 1200) {
document.location.href = link;
... ... @@ -80,7 +80,7 @@ function openAppOrLink(app, link) {
} else {
document.location.href = app;
setTimeout(function() {
let date_end = new Date();
var date_end = new Date();
if (is_pod) {
//$('.live-app-desc p').eq(0).text(date_end.getTime() - date_start.getTime());
if (date_end.getTime() - date_start.getTime() < 2003) {
... ... @@ -103,8 +103,8 @@ function openAppOrLink(app, link) {
document.body.appendChild(ifr);
setTimeout(function() {
let date_end = new Date();
/*let p = document.createElement('p');
var date_end = new Date();
/*var p = document.createElement('p');
p.innerHTML = date_end - date_start
document.body.appendChild(p);*/
//alert(date_end.getTime() - date_start.getTime());
... ... @@ -137,7 +137,7 @@ function get_download_link() {
* @returns {boolean}
*/
function check_supperUniversalLink() {
let osversion = navigator.userAgent.match(/iPhone OS (\d*)/);
var osversion = navigator.userAgent.match(/iPhone OS (\d*)/);
//console.log(osversion && osversion[1]);
return osversion && osversion[1];
/*if (osversion && osversion[1] >= 9) {
... ... @@ -166,10 +166,10 @@ function show_download_msg() {
* @constructor
*/
function ManageQueryString() {
let loc = document.location.href;
let variables = '';
let variableArr = [];
let finalArr = [];
var loc = document.location.href;
var variables = '';
var variableArr = [];
var finalArr = [];
if (loc.indexOf('?') > 0) {
variables = loc.split('?')[1];
... ... @@ -179,8 +179,8 @@ function ManageQueryString() {
variableArr = variables.split('&');
}
for (let i = 0; i < variableArr.length; i++) {
let obj = {};
for (var i = 0; i < variableArr.length; i++) {
var obj = {};
obj.name = variableArr[i].split('=')[0];
obj.value = variableArr[i].split('=')[1];
finalArr.push(obj);
... ... @@ -197,8 +197,8 @@ function ManageQueryString() {
*/
function getQueryString(arr, name) {
if (arr.length > 0) {
for (let i = 0; i < arr.length; i++) {
let obj = arr[i];
for (var i = 0; i < arr.length; i++) {
var obj = arr[i];
if (obj.name == name) {
return obj.value;
}
... ... @@ -207,7 +207,7 @@ function getQueryString(arr, name) {
}
function check_sys_open() {
let download_type = '';
var download_type = '';
if (is_android) {
download_type = 'android';
openAppOrLink(app_android, download_android);
... ... @@ -227,11 +227,11 @@ function check_sys_open() {
$(document).ready(function() {
let location = document.location.href;
var location = document.location.href;
queryArr = ManageQueryString();
let is_redirect = getQueryString(queryArr, 'redirect'); //从微信跳转过来的链接自动跳转到对应app
var is_redirect = getQueryString(queryArr, 'redirect'); //从微信跳转过来的链接自动跳转到对应app
let agent = navigator.userAgent.toLowerCase();
var agent = navigator.userAgent.toLowerCase();
//判断环境
if (agent.match(/android/i) == 'android') {
... ... @@ -283,7 +283,7 @@ $(document).ready(function() {
$download_msg = $('.live-app-download-msg'); //提示在浏览器中打开
$btn_download.on('click', function() { //点击下载按钮
let download_type = '';
var download_type = '';
if (is_android) {
download_type = 'android';
openAppOrLink(app_android, download_android);
... ...
... ... @@ -9,19 +9,19 @@ global.msg_obj = [
'{"avatar": "http://img01.yohoboys.com/contentimg/2016/06/15/14/012b97d00097fd444bd8f830ed2e8fe54e.jpg", "cmd": 5, "msg": "别和小编太较真", "name": "YOHO_187****1007", "room": 19177}'
];
let replay_msg = [];
var replay_msg = [];
(function() {
for (let i = 0; i < 300; i++) {
let time = 5 + i * 2;
let rand = Math.floor(Math.random() * 2);
let msg = '';
for (var i = 0; i < 300; i++) {
var time = 5 + i * 2;
var rand = Math.floor(Math.random() * 2);
var msg = '';
if (rand === 1) {
msg = '{"createtime":' + time + ',"avatar":"","name":"\u8c2d\u660e\u4e54' + i + '","msg":"测试消息测试消息测试消息测试消息测试消息测试消息' + i + '","cmd":"5"}'
} else {
msg = '{"createtime":' + time + ',"avatar":"http:\/\/avatar.jpg","name":"测试登录' + i + '","msg":"","cmd":"4"}';
}
let j = JSON.parse(msg);
var j = JSON.parse(msg);
replay_msg.push(j);
}
})();
... ...
// 初始化config信息
let _weChatInterface = '//m.yohobuy.com/activity/wechat/share';// 签名等相关配置,yoho公众号
var _weChatInterface = '//m.yohobuy.com/activity/wechat/share';// 签名等相关配置,yoho公众号
$.getJSON(_weChatInterface + '?url=' + encodeURIComponent(location.href.split('#')[0]) + '&callback=?', function(json) {
if (json && json !== '') {
let _appId = json.appId.toString();
let _timestamp = json.timestamp;
let _nonceStr = json.nonceStr.toString();
let _signature = json.signature.toString();
var _appId = json.appId.toString();
var _timestamp = json.timestamp;
var _nonceStr = json.nonceStr.toString();
var _signature = json.signature.toString();
window.wx.config({
debug: true,
... ... @@ -59,11 +59,11 @@ $.getJSON(_weChatInterface + '?url=' + encodeURIComponent(location.href.split('#
function share() {
window.wx.ready(function() {
// 构造分享信息
let shareTitle = $('#shareTitle').val();
let shareImg = $('#shareImg').val();
let shareDesc = $('#shareDesc').val();
let shareLink = $('#shareLink').val();
let shareData = {
var shareTitle = $('#shareTitle').val();
var shareImg = $('#shareImg').val();
var shareDesc = $('#shareDesc').val();
var shareLink = $('#shareLink').val();
var shareData = {
title: shareTitle,
desc: shareDesc,
imgUrl: shareImg,
... ...
... ... @@ -3,12 +3,12 @@
* 用于处理一些统计数据
*/
let live_data_type = [
var live_data_type = [
'M_LIVE_DOWNLOAD_APP_TOP',
'M_LIVE_DOWNLOAD_APP_CENTER',
'M_LIVE_PLAYBUTTON_CLICK',
'M_LIVE_SHARE'];
let play_count = 0;
var play_count = 0;
function send_data(obj) {
console.log(obj);
... ... @@ -18,21 +18,21 @@ function send_data(obj) {
}
function get_live_data() {
let data_prefix = 'YOHOBOYS';
var data_prefix = 'YOHOBOYS';
if (document.location.hostname.indexOf('boy') > 0) {
data_prefix = 'YOHOBOYS';
} else if (document.location.hostname.indexOf('girl') > 0) {
data_prefix = 'YOHOGIRLS';
}
let data_type = (typeof(arguments[0]) === 'undefined') ? 0 : arguments[0];
let data_value = (typeof(arguments[1]) === 'undefined') ? 0 : arguments[1];
var data_type = (typeof(arguments[0]) === 'undefined') ? 0 : arguments[0];
var data_value = (typeof(arguments[1]) === 'undefined') ? 0 : arguments[1];
console.log(data_type, data_value);
if (data_type != 0 && data_prefix != '') {
let data_type_str = data_prefix + live_data_type[data_type - 1];
let obj = {};
var data_type_str = data_prefix + live_data_type[data_type - 1];
var obj = {};
obj.type = data_type_str;
if (data_value != 0) {
... ...
... ... @@ -13,44 +13,44 @@
* manage_replay_chat_msg ===> 通过requestAnimationFrame每帧调用用于判断是否可以展示重播消息和点赞
* replay_barrage_callback_handler ===> 由video的各个事件中调取的callback方法
*/
let prefixes = 'webkit moz ms o'.split(' '); //各浏览器前缀
let requestAnimationFrame = window.requestAnimationFrame;
let cancelAnimationFrame = window.cancelAnimationFrame;
let site_url = STATIC_RESOURCE_PATH;
let $btn_play;
let video_width = 375;
let video_height = 667;
let video_id = 'yoho_live'; //视频video标签id
let is_live = true; //是否是直播,根据地址栏参数可以判断
let get_socket_server_url = '/activity/live/barrage'; //获取websocket服务器的接口
let get_replay_chat_url = '/activity/live/replay/barrage'; //获取重播弹幕
let query_arr = []; //地址栏参数数组
let link_type = 'webksocket'; //连接类型
let live_ws; //websocket
let heart_beat_interval; //心跳计时器
let live_time_interval; //播放时间计时器
let live_duration = 0; //播放时间计数器
let now_like_nums = 0; //当前点赞数
let $live_like_pannel; //点赞div,用于存放小脸动画
let is_animate = false; //用于控制动画的频率
let replay_video;
let replay_new_start_time = 1466591331; //根据play进度调整的当前时间,用于获取重播弹幕
let replay_chat_interval = 60; //重播弹幕获取的时间区间长度,接口默认是5分钟
let replay_chat_arr = []; //用于存储重播弹幕obj
let replay_chat_frame_count = 0; //用于计算执行requstAnimationFrames的次数
let is_replay_chat_loading = false; //是否正在调取接口
let can_seek = true; //
let replay_per_like = 0; //平均每秒增加的点赞数
let replay_per_request_like = 0; //平均每帧增加的点赞数(大概)
let replay_video_duration = 0; //重播视频
let replay_now_like = 0; //当前重播的点赞数
let is_wating = false;
let test_count = 99;
let CMD = {
var prefixes = 'webkit moz ms o'.split(' '); //各浏览器前缀
var requestAnimationFrame = window.requestAnimationFrame;
var cancelAnimationFrame = window.cancelAnimationFrame;
var site_url = STATIC_RESOURCE_PATH;
var $btn_play;
var video_width = 375;
var video_height = 667;
var video_id = 'yoho_live'; //视频video标签id
var is_live = true; //是否是直播,根据地址栏参数可以判断
var get_socket_server_url = '/activity/live/barrage'; //获取websocket服务器的接口
var get_replay_chat_url = '/activity/live/replay/barrage'; //获取重播弹幕
var query_arr = []; //地址栏参数数组
var link_type = 'webksocket'; //连接类型
var live_ws; //websocket
var heart_beat_interval; //心跳计时器
var live_time_interval; //播放时间计时器
var live_duration = 0; //播放时间计数器
var now_like_nums = 0; //当前点赞数
var $live_like_pannel; //点赞div,用于存放小脸动画
var is_animate = false; //用于控制动画的频率
var replay_video;
var replay_new_start_time = 1466591331; //根据play进度调整的当前时间,用于获取重播弹幕
var replay_chat_interval = 60; //重播弹幕获取的时间区间长度,接口默认是5分钟
var replay_chat_arr = []; //用于存储重播弹幕obj
var replay_chat_frame_count = 0; //用于计算执行requstAnimationFrames的次数
var is_replay_chat_loading = false; //是否正在调取接口
var can_seek = true; //
var replay_per_like = 0; //平均每秒增加的点赞数
var replay_per_request_like = 0; //平均每帧增加的点赞数(大概)
var replay_video_duration = 0; //重播视频
var replay_now_like = 0; //当前重播的点赞数
var is_wating = false;
var test_count = 99;
var CMD = {
LOGIN: 1, //客户端发送登录消息
SEND_MESSAGE: 2, //客户端发送消息
LOGOUT: 3, //客户端发送退出消息
... ... @@ -66,11 +66,11 @@ let CMD = {
};
function set_duration () {
let video = $('.video_player').find('video')[0];
let duration;
let durationH;
let durationM;
let durationS;
var video = $('.video_player').find('video')[0];
var duration;
var durationH;
var durationM;
var durationS;
if (video) {
video.addEventListener('loadedmetadata', function() {
... ... @@ -103,16 +103,16 @@ function set_duration () {
*/
function init_play_button() {
global.$btn_play = $btn_play = $('.live-video-play-button a');
let video_source = $('#video_container').attr('data-video');
var video_source = $('#video_container').attr('data-video');
$btn_play.on('click', function() {
$('#live-watermark').removeClass('hide');
if (live_type === 1 || live_type === 3) {
if ($('#' + video_id)[0] == undefined) {
get_chat_info(); //获取弹幕信息
let _is_ios = true;
let _is_wechat = false;
let agent = navigator.userAgent.toLowerCase();
var _is_ios = true;
var _is_wechat = false;
var agent = navigator.userAgent.toLowerCase();
//判断环境
if (agent.match(/android/i) == 'android') {
_is_ios = false;
... ... @@ -130,20 +130,20 @@ function init_play_button() {
$('.live-video-cover').hide(); //隐藏封面
$('.live-app-download-head-wrap').hide(); //隐藏头部
let temp_height = $(window).height();
let temp_width = $(document).width();
var temp_height = $(window).height();
var temp_width = $(document).width();
if (temp_width > 540) {
temp_width = 540;
}
let scale = 17.1 / 20;
var scale = 17.1 / 20;
// if (temp_height > 30.15 * scale * (temp_width / 320 * 20)) {
// temp_height = 30.15 * scale + 'rem';
// } else {
// temp_height = temp_height + 'px'
// }
let v_width = temp_width + 'px';
let v_height = 32.575 * scale + 'rem';
var v_width = temp_width + 'px';
var v_height = 32.575 * scale + 'rem';
$('.live-loading-container').show(); //显示loading
init_video(video_source, _is_wechat, _is_ios, '100%', '100%');
... ... @@ -271,7 +271,7 @@ function get_chat_info() {
* @param type 参数类型:websocket,tcp,用于获取不同协议的服务器地址
*/
function get_websocket_server(type) {
let param = type;
var param = type;
$.ajax({
url: get_socket_server_url,
data: {
... ... @@ -282,11 +282,11 @@ function get_websocket_server(type) {
success: function(data) {
console.log(data);
if (data.code === 200) {
let arr = data.data[0].split(':');
let ip = arr[0];
let port = arr[1];
let protocol = 'ws'
// let protocol = location.protocol === 'https:' ? 'wss' :'ws'
var arr = data.data[0].split(':');
var ip = arr[0];
var port = arr[1];
var protocol = 'ws'
// var protocol = location.protocol === 'https:' ? 'wss' :'ws'
if (is_live) {
... ... @@ -304,7 +304,7 @@ function get_websocket_server(type) {
* @param port
*/
function link_to_websocket_server(ip, port) {
let path = ip + ':' + port;
var path = ip + ':' + port;
live_ws = new WebSocket(path);
live_ws.onopen = function(event) {
... ... @@ -328,7 +328,7 @@ function link_to_websocket_server(ip, port) {
live_ws.onmessage = function(event) {
if (event.data) {
let msg_obj = JSON.parse(event.data);
var msg_obj = JSON.parse(event.data);
console.log(msg_obj, msg_obj.cmd);
switch (msg_obj.cmd) {
case 4:
... ... @@ -365,7 +365,7 @@ function get_replay_chat_barrage(start_time, duration) {
replay_new_start_time = start_time;
}
is_replay_chat_loading = true;
let ajax = $.ajax({
var ajax = $.ajax({
url: get_replay_chat_url,
data: {
id: live_room,
... ... @@ -403,7 +403,7 @@ function get_replay_chat_barrage(start_time, duration) {
});
//用于测试
/* let test_arr = test_replay(start_time, duration);
/* var test_arr = test_replay(start_time, duration);
test_arr.forEach(function (obj) {
replay_chat_arr.push(obj);
});
... ... @@ -418,7 +418,7 @@ function get_replay_chat_barrage(start_time, duration) {
* 开始
*/
function set_replay_chat_frame() {
let element = $('#live_chat_ul');
var element = $('#live_chat_ul');
requestAnimationFrame(manage_replay_chat_msg);
}
... ... @@ -430,7 +430,7 @@ function manage_replay_chat_msg() {
if (replay_video != undefined) {
if (!replay_video.paused && !is_wating) {
let time = parseInt(replay_video.currentTime);
var time = parseInt(replay_video.currentTime);
if (!isNaN(replay_video.duration) && replay_video.duration != 0) {
if (replay_video_duration === 0) {
replay_video_duration = replay_video.duration;
... ... @@ -448,20 +448,20 @@ function manage_replay_chat_msg() {
if (replay_now_like - now_like_nums >= 1) {
now_like_nums = parseInt(replay_now_like);
let msg = '{"cmd":9,"msg":' + now_like_nums + ',"room":' + live_room + ',"uid":1}';
let msg_obj = JSON.parse(msg);
var msg = '{"cmd":9,"msg":' + now_like_nums + ',"room":' + live_room + ',"uid":1}';
var msg_obj = JSON.parse(msg);
insert_like(msg_obj);
}
} else if (replay_video.currentTime < 10) {
let msg = '{"cmd":9,"msg":0,"room":' + live_room + ',"uid":1}';
let msg_obj = JSON.parse(msg);
var msg = '{"cmd":9,"msg":0,"room":' + live_room + ',"uid":1}';
var msg_obj = JSON.parse(msg);
insert_like(msg_obj);
}
}
if (replay_chat_arr.length > 0) {
let obj = replay_chat_arr[0];
var obj = replay_chat_arr[0];
if (obj.create_time <= time) {
if (obj.cmd == 5) {
insert_msg(obj)
... ... @@ -542,7 +542,7 @@ function replay_barrage_callback_handler(time, v_type) {
* @returns {string}
*/
function get_cmd(cmd) {
let result = '';
var result = '';
switch (cmd) {
case 1:
result = '{"cmd":' + cmd + ',"uid":"","name":"","avatar":"","room":' + live_room + '}';
... ... @@ -570,10 +570,10 @@ function send_heart_beat() {
*/
function insert_msg(obj) {
let $ul = $('#live_chat_ul');
let msg_html
var $ul = $('#live_chat_ul');
var msg_html
if (obj.avatar == '' || obj.avatar == undefined) {
let rand = Math.floor(Math.random() * 5) + 1;
var rand = Math.floor(Math.random() * 5) + 1;
// obj.avatar = site_url + '/img/activity/live/live/head_' + rand + '.png';
msg_html = '<div class="live-item2"><div class="live-item2-head">' +
... ... @@ -606,7 +606,7 @@ function insert_msg(obj) {
'</div>' +
'</div>';
}
let li = document.createElement('li');
var li = document.createElement('li');
li.innerHTML = msg_html;
if ($ul.children().length >= 4) {
$ul.find('li').eq(0).remove();
... ... @@ -620,9 +620,9 @@ function insert_msg(obj) {
*/
function insert_user(obj) {
if (obj.name.length > 1) {
let $ul = $('#live_chat_ul');
let msg_html = '<div class="live-item1">' + '@' + obj.name + ' <span>已加入</span>' + '</div>';
let li = document.createElement('li');
var $ul = $('#live_chat_ul');
var msg_html = '<div class="live-item1">' + '@' + obj.name + ' <span>已加入</span>' + '</div>';
var li = document.createElement('li');
li.innerHTML = msg_html;
if ($ul.children().length >= 4) {
$ul.find('li').eq(0).remove();
... ... @@ -638,7 +638,7 @@ function insert_user(obj) {
* @param obj
*/
function insert_like(obj) {
let num = obj.msg.toString();
var num = obj.msg.toString();
if (num.indexOf('万') < 0) {
num = parseInt(num);
... ... @@ -651,15 +651,15 @@ function insert_like(obj) {
} else {
if (!is_animate) {
is_animate = true;
let like_rand = Math.floor(Math.random() * 3) + 1;
let img_rand = Math.floor(Math.random() * 5) + 1;
let img_path = site_url + '/img/activity/live/live/like_icon' + img_rand + '.png';
let id = 'js_keyframes_' + Math.random();
let like_class = 'like-icon' + ' scroll_animate_' + like_rand;
let msg_html = '<img src="' + img_path + '">';
var like_rand = Math.floor(Math.random() * 3) + 1;
var img_rand = Math.floor(Math.random() * 5) + 1;
var img_path = site_url + '/img/activity/live/live/like_icon' + img_rand + '.png';
var id = 'js_keyframes_' + Math.random();
var like_class = 'like-icon' + ' scroll_animate_' + like_rand;
var msg_html = '<img src="' + img_path + '">';
let anim_div = document.createElement('div');
var anim_div = document.createElement('div');
anim_div.id = id;
anim_div.className = like_class;
anim_div.innerHTML = msg_html;
... ... @@ -695,9 +695,9 @@ function insert_audience(obj) {
* @param obj
*/
function insert_end(obj) {
let user_num = obj.audienceNums.toString();
let like_num = obj.likeNums.toString();
let video_len = obj.videoLen.toString();
var user_num = obj.audienceNums.toString();
var like_num = obj.likeNums.toString();
var video_len = obj.videoLen.toString();
if (user_num.indexOf('万') < 0) {
user_num = parseInt(user_num);
... ... @@ -715,7 +715,7 @@ function insert_end(obj) {
like_num = (like_num / 10000).toFixed(1) + '万';
}
let video = $('#' + video_id)[0];
var video = $('#' + video_id)[0];
if (video) {
setTimeout(function() {
video.pause();
... ... @@ -724,7 +724,7 @@ function insert_end(obj) {
}
live_ws.close();
clearInterval(live_time_interval);
let $liveEnd = $('#live-state-end');
var $liveEnd = $('#live-state-end');
$liveEnd.show();
$liveEnd.find('.audience .val').text(user_num);
$liveEnd.find('.duration .val').text(video_len);
... ... @@ -751,7 +751,7 @@ function receive_init(obj) {
*/
function get_live_time() {
if (live_start_time) {
let date = new Date();
var date = new Date();
live_duration = parseInt(date.getTime() / 1000) - live_start_time;
console.log('live_duration=' + live_duration);
$('#live_time').text(get_time_text(live_duration));
... ... @@ -765,10 +765,10 @@ function get_live_time() {
* @returns {string}
*/
function get_time_text(time) {
let time_text = '00:00:00';
let sec;
let min;
let hour;
var time_text = '00:00:00';
var sec;
var min;
var hour;
if (time < 0) {
time = 0;
}
... ... @@ -794,7 +794,7 @@ function get_time_text(time) {
} else {
hour = hour + ':';
}
let rests = time % 3600;
var rests = time % 3600;
min = (rests - rests % 60) / 60;
if (min < 10) {
min = '0' + min;
... ... @@ -826,10 +826,10 @@ function set_interval_time() {
* requestAnimationFrame
*/
function init_request_animation_frames() {
let lastTime = 0;
let prefix;
var lastTime = 0;
var prefix;
//通过遍历各浏览器前缀,来得到requestAnimationFrame和cancelAnimationFrame在当前浏览器的实现形式
for (let i = 0; i < prefixes.length; i++) {
for (var i = 0; i < prefixes.length; i++) {
if (requestAnimationFrame && cancelAnimationFrame) {
break;
}
... ... @@ -841,10 +841,10 @@ function init_request_animation_frames() {
//如果当前浏览器不支持requestAnimationFrame和cancelAnimationFrame,则会退到setTimeout
if (!requestAnimationFrame || !cancelAnimationFrame) {
requestAnimationFrame = function(callback) {
let currTime = new Date().getTime();
var currTime = new Date().getTime();
//为了使setTimteout的尽可能的接近每秒60帧的效果
let timeToCall = Math.max(0, 16 - (currTime - lastTime));
let id = window.setTimeout(function() {
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
var id = window.setTimeout(function() {
callback(currTime + timeToCall);
}, timeToCall);
lastTime = currTime + timeToCall;
... ... @@ -893,8 +893,8 @@ $(document).ready(function() {
});
global.test = function test() { //测试弹幕样式
let rand = Math.floor(Math.random() * msg_obj.length);
let obj = JSON.parse(msg_obj[rand].toString());
var rand = Math.floor(Math.random() * msg_obj.length);
var obj = JSON.parse(msg_obj[rand].toString());
switch (obj.cmd) {
case 4:
insert_user(obj);
... ... @@ -906,21 +906,21 @@ global.test = function test() { //测试弹幕样式
}
global.test_like = function test_like() {
let rand = Math.floor(Math.random() * 5);
var rand = Math.floor(Math.random() * 5);
test_count += rand;
let obj_text = '{"cmd":9,"msg":' + test_count + ',"room":' + live_room + ',"uid":0}';
let obj = JSON.parse(obj_text);
var obj_text = '{"cmd":9,"msg":' + test_count + ',"room":' + live_room + ',"uid":0}';
var obj = JSON.parse(obj_text);
insert_like(obj);
}
global.test_replay = function test_replay(starttime, timeinterval) {
let start = starttime - live_start_time;
let end = start + timeinterval;
let test_arr = [];
var start = starttime - live_start_time;
var end = start + timeinterval;
var test_arr = [];
if (replay_msg.length > 0) {
for (let i = 0; i < replay_msg.length; i++) {
let obj = replay_msg[i];
let create_time = parseInt(obj.createtime);
for (var i = 0; i < replay_msg.length; i++) {
var obj = replay_msg[i];
var create_time = parseInt(obj.createtime);
if (create_time >= start && create_time <= end) {
test_arr.push(obj);
}
... ...
... ... @@ -2,7 +2,7 @@
* Created by qiujun on 16/6/5.
*/
let info_text = '<p>今晚《奔跑吧兄弟》继续开跑,这期从预告片来看,怎么都觉得有点恐怖啊!</p>' +
var info_text = '<p>今晚《奔跑吧兄弟》继续开跑,这期从预告片来看,怎么都觉得有点恐怖啊!</p>' +
'<div style="margin-top:10px;"></div>' +
'<img width="640px" h="640px" "style="margin:0 auto;border:0;display:block;" class="lazy" src="http://img02.yohoboys.com/contentimg/2016/06/10/21/02c6f92a8d88dbe1373f9f6215ea021348.jpg" data-original="http://img02.yohoboys.com/contentimg/2016/06/10/21/02c6f92a8d88dbe1373f9f6215ea021348.jpg" style="display: block;">' +
'<span style="color:#B2AAA4;">▲游戏设施长这样!</span>' +
... ...
... ... @@ -6,15 +6,15 @@
*/
let share_sina_url = 'http://service.weibo.com/share/share.php?appkey=3910025296';
let share_qzon_url = 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey';
let share_facebook_url = 'https://www.facebook.com/sharer/sharer.php';
let share_twitter_url = 'http://twitter.com/intent/tweet';
let true_yoho_img = '//img03.res.yoho.cn/blogimg/2016/06/21/18/01bec2ddcbb55247b2ac4869b3e4255286.png';
let fake_yoho_img = '//img03.res.yoho.cn/blogimg/2016/06/21/18/01db287fedae82aa7f0155727b0b5a0936.png';
let true_yohogirl_img = '//cdn.yoho.cn/yohocn/160315/images/ewm-yoho02.png';
let fake_yohogirl_img = '//cdn.yoho.cn/yohocn/160315/images/ewm-yoho02-no.png';
let touch_timeout;
var share_sina_url = 'http://service.weibo.com/share/share.php?appkey=3910025296';
var share_qzon_url = 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey';
var share_facebook_url = 'https://www.facebook.com/sharer/sharer.php';
var share_twitter_url = 'http://twitter.com/intent/tweet';
var true_yoho_img = '//img03.res.yoho.cn/blogimg/2016/06/21/18/01bec2ddcbb55247b2ac4869b3e4255286.png';
var fake_yoho_img = '//img03.res.yoho.cn/blogimg/2016/06/21/18/01db287fedae82aa7f0155727b0b5a0936.png';
var true_yohogirl_img = '//cdn.yoho.cn/yohocn/160315/images/ewm-yoho02.png';
var fake_yohogirl_img = '//cdn.yoho.cn/yohocn/160315/images/ewm-yoho02-no.png';
var touch_timeout;
$(document).ready(function() {
// init_share_button();
... ... @@ -28,16 +28,16 @@
* 分享按钮
*/
function init_share_button() {
let $btn_share_sina = $('.live-share-button-sina a');
let $btn_share_qzone = $('.live-share-button-qzone a');
let $btn_share_facebook = $('.live-share-button-facebook a');
let $btn_share_twitter = $('.live-share-button-twitter a');
let local_url = document.location.href;
let protocol = document.location.protocol;
let share_url = '';
let share_img = $('#share').attr('cover');
let share_title_sina = document.title + ' @YOHO潮流志 @YOHOGIRL ';
let share_title_qzone = document.title + ' | 来自YOHO!';
var $btn_share_sina = $('.live-share-button-sina a');
var $btn_share_qzone = $('.live-share-button-qzone a');
var $btn_share_facebook = $('.live-share-button-facebook a');
var $btn_share_twitter = $('.live-share-button-twitter a');
var local_url = document.location.href;
var protocol = document.location.protocol;
var share_url = '';
var share_img = $('#share').attr('cover');
var share_title_sina = document.title + ' @YOHO潮流志 @YOHOGIRL ';
var share_title_qzone = document.title + ' | 来自YOHO!';
if (share_img.indexOf('http') < 0 && share_img.indexOf('https') < 0) {
share_img = protocol + share_img;
... ... @@ -77,8 +77,8 @@
* 由于微信不能同时识别两个二维码,所以按一个二维码的同时把另外一个二维码给换成点击的二维码的图片
*/
function check_qr_touch() {
let $clz_img = $('#qr_clz img');
let $girl_img = $('#qr_girl img');
var $clz_img = $('#qr_clz img');
var $girl_img = $('#qr_girl img');
$clz_img.on('touchstart', function() {
$clz_img.attr('src', true_yoho_img);
... ...
... ... @@ -3,7 +3,7 @@
* Created by qiujun on 16/05/24
* 一个所谓的video插件(伪)
*/
let _defaults = {
var _defaults = {
video_id: 'yoho_video',
islive: false, //是否是直播
width: '100%',
... ... @@ -19,8 +19,8 @@ let _defaults = {
is_ios: true
};
let that; //用于引用this
let video_src;
var that; //用于引用this
var video_src;
function YohoVideo($ele, options) { //构造函数
this.$ele = $ele;
... ... @@ -39,15 +39,15 @@ YohoVideo.prototype = {
this.bindEvent(); //初始化视频各个事件
},
innserVideoHtml: function() {
let _options = this._options;
var _options = this._options;
this._width = _options.width || '100%';
this._height = _options.height || '100%';
let _preload = _options.preload || false;
let _autoplay = _options.autoplay || false;
let _controls = _options.controls || false;
let _poster = _options.poster || false;
let _loop = _options.loop || false;
let _src = _options.src || '';
var _preload = _options.preload || false;
var _autoplay = _options.autoplay || false;
var _controls = _options.controls || false;
var _poster = _options.poster || false;
var _loop = _options.loop || false;
var _src = _options.src || '';
this._loading_div = _options.loading_div || '.live-video-loading';
this._video_id = _options.video_id || 'yoho_video';
this._islive = _options.islive || false;
... ... @@ -55,13 +55,13 @@ YohoVideo.prototype = {
this._is_ios = _options.is_ios || true;
//console.log(_width,_height,_preload,_autoplay,_controls,_poster,_loop,_src);
/*let video = document.createElement('video');
/*var video = document.createElement('video');
video.id = this._video_id;
video.setAttribute('webkit-playsinline',true);*/
video_src = _src;
let _attributes = '';
let _styles = '';
let _source = '';
var _attributes = '';
var _styles = '';
var _source = '';
if (this._height != undefined) {
_styles += ' height:' + this._height + ';';
//video.style.height = _height;
... ... @@ -95,11 +95,11 @@ YohoVideo.prototype = {
//video.src = _src;
}
let _source_html = '';
var _source_html = '';
//console.log(this._islive);
if (!this._islive || this._islive) {
let _len = _src.length - _src.lastIndexOf('.');
let _type = _src.substr(_src.lastIndexOf('.') + 1, _len);
var _len = _src.length - _src.lastIndexOf('.');
var _type = _src.substr(_src.lastIndexOf('.') + 1, _len);
if (_type === 'm3u8') {
_type = 'application/x-mpegurl';
} else {
... ... @@ -107,22 +107,22 @@ YohoVideo.prototype = {
}
_source_html = '<source src="' + _src + '" type="' + _type + '">';
/*let source = document.createElement('source');
/*var source = document.createElement('source');
source.src = _src;
source.type = _type;
video.appendChild(source);*/
}
let _video_html = '<video id="' + this._video_id + '" webkit-playsinline="true"' + _attributes + ' style="' + _styles + 'background:rgb(0,0,0)" webkit-playsinline>' +
var _video_html = '<video id="' + this._video_id + '" webkit-playsinline="true"' + _attributes + ' style="' + _styles + 'background:rgb(0,0,0)" webkit-playsinline>' +
_source_html +
'</video>';
//console.log(_video_html);
this.$ele.html(_video_html);
let video = $('#' + this._video_id)[0];
var video = $('#' + this._video_id)[0];
video.allowFullScreen = false;
if (this._islive || _type == 'application/x-mpegurl') {
if (video.hasChildNodes()) {
let source_node = video.childNodes[0];
var source_node = video.childNodes[0];
video.removeChild(source_node);
video.src = _src;
video.play();
... ... @@ -135,9 +135,9 @@ YohoVideo.prototype = {
//this.$ele.append(video);
},
exitFull: function() { //退出全屏
let _video = $('#' + this._video_id)[0];
var _video = $('#' + this._video_id)[0];
//let _video = this._video;
//var _video = this._video;
//alert(_video.exitFullscreen || _video.msExitFullscreen || _video.oRequestFullscreen || _video.webkitCancelFullScreen || _video.webkitExitFullscreen);
if (_video.exitFullScreen) {
_video.exitFullScreen();
... ... @@ -152,27 +152,27 @@ YohoVideo.prototype = {
}
},
bindEvent: function() {
let _video = $('#' + this._video_id)[0];
var _video = $('#' + this._video_id)[0];
_video.isFullscreen = false;
_video.scrollLeft = 0;
_video.scrollTop = 0;
//console.log(this._width,this._height);
_video.scrollWidth = this._width;
_video.scrollHeight = this._height;
// _video.scrollWidth = this._width;
// _video.scrollHeight = this._height;
//let _video = this._video;
//var _video = this._video;
console.log('video=', _video);
let _msg_pannel = $(this._loading_div);
let _msg = _msg_pannel.find('p');
let _progress_count = 0;
var _msg_pannel = $(this._loading_div);
var _msg = _msg_pannel.find('p');
var _progress_count = 0;
let _error_count = 0;
var _error_count = 0;
//networkState:0.此元素未初始化 1.正常但没有使用网络 2.正在下载数据 3.没有找到资源
//readyState:
// 1:HAVE_NOTHING 2:HAVE_METADATA 3.HAVE_CURRENT_DATA 4.HAVE_FUTURE_DATA 5.HAVE_ENOUGH_DATA
let media_events = {
var media_events = {
LOAD_START: 'loadstart',
PROGRESS: 'progress',
SUSPEND: 'suspend',
... ...