anxiao_web/rtc/js/timestampFormat.js

69 lines
1.8 KiB
JavaScript

export function timestampFormat(){
var currentTime = new Date();
var year = currentTime.getFullYear();
var getMonth = (currentTime.getMonth()) + 1;
var getDate = currentTime.getDate();
var getHours = currentTime.getHours();
var getMinutes = currentTime.getMinutes();
var getSeconds = currentTime.getSeconds();
if(getMonth < 10) {
getMonth = "0" + getMonth;
}
if(getDate < 10) {
getDate = "0" + getDate;
}
if(getHours < 10) {
getHours = "0" + getHours;
}
if(getMinutes < 10) {
getMinutes = "0" + getMinutes;
}
if(getSeconds < 10) {
getSeconds = "0" + getSeconds;
}
return year + "年" + getMonth + "月" + getDate + "日" + getHours + "时" + getMinutes + "分" + getSeconds+"秒";
}
//接受url的值,进行解析
export function getParams(key) {
var reg = new RegExp("(^|&)" + key + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) {
return unescape(r[2]);
}
return null;
};
//全屏
export function fullScreen() {
var element = document.documentElement;
if (element.requestFullscreen) {
element.requestFullscreen();
} else if (element.msRequestFullscreen) {
element.msRequestFullscreen();
} else if (element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if (element.webkitRequestFullscreen) {
element.webkitRequestFullscreen();
}
}
//退出全屏
export function exitFullscreen() {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
}
}