📄 common.js
字号:
String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g,""); }
function Img(src)
{
this.preload = function()
{
var new_img = new Image();
new_img.src = this.getSrc();
}
this.get = function()
{
return "<img src=\"" + this.getSrc() + "\" />";
}
this.getSrc = function()
{
return this.src;
}
this.src = src;
this.preload();
}
/**
*
*
*/
function preloadImage(mix)
{
if(typeof mix == 'string')
{
new Image().src = mix;
}
else
{
for(var i in mix)
{
new Image().src = mix[i];
}
}
}
/**
* 获取文件扩展名
* dellker.com 2007-10-31
* wkkes.com 2008-9-3 17:44
*/
function getFileext(sFile, bToLower) {
if(! sFile) {
return null;
} else {
var a = sFile.split('.');
if(a.length>0) {
return bToLower === true ? a[a.length-1].toLowerCase() : a[a.length-1];
} else {
return null;
}
}
}
/**
* 加入收藏夹方法
* 兼容 FF & IE
*/
function addFavorite(sURL, sTitle) {
try {
window.external.addFavorite(sURL, sTitle);
} catch(e) {
try {
window.sidebar.addPanel(sTitle, sURL, "");
} catch(e) {
alert("加入收藏失败,请使用Ctrl+D进行添加");
}
}
}
/**
* 打开前台
*
*/
function openFrontStage() {
}
/* 判断是否包含中文
*/
function haveChinese($s) {
return escape($s).indexOf('%u') < 0 ? false : true;
}
/* 显示日期
*/
function showDate() {
var s = '';
var d = new Date();
s += ((document.all)?d.getYear():d.getYear()+1900)+'-'+(d.getMonth()+1)+'-'+d.getDate()+'';
s += ' ' + d.getHours() + ':' + (d.getMinutes()*1 > 9 ? d.getMinutes() : '0'+d.getMinutes());
s += '<span style="background-color:lightyellow;border:solid 1px #EFEFEF;padding:2px;margin-left:3px;margin-right:3px;">';
switch(d.getDay()) {
case 0:
s += ' <font color="#FF0000">Sun';
break;
case 1:
s += ' <font color="#555555">Mon';
break;
case 2:
s += ' <font color="#555555">Tue';
break;
case 3:
s += ' <font color="#555555">Wed';
break;
case 4:
s += ' <font color="#555555">Thu';
break;
case 5:
s += ' <font color="#555555">Fri';
break;
case 6:
s += ' <font color="#FF0000">Sat';
break;
}
s += '</font></span>';
//s += ':' + d.getSeconds();
document.write(s);
//setTimeout('showDate()', 1000);
}
function dump(o) {
var name = '__dump_message_container__';
var s;
if(typeof o == 'object') {
s = dumpExec(o, 1);
} else if(typeof o == 'undefined') {
s = 'UNDEFINED';
} else {
s = o.toString();
}
if(document.getElementById(name)) {
var obj = document.getElementById(name);
} else {
var obj = document.createElement('div');
obj.id = name;
obj.style.backgroundColor = '#FFFFFF';
obj.style.border = 'solid 2px #F00';
obj.style.margin = '1em';
obj.style.padding = '.5em';
obj.style.fontSize = '1.2em';
obj.style.lineHeight = '160%';
document.body.appendChild(obj);
}
obj.innerHTML = s;
}
function dumpExec(o, depth) {
var s = '';
var indent = new Array(depth).join(' ');
for(a in o) {
if(typeof o[a] == 'object') {
s += indent + a + ': {<br />' + dumpExec(o[a], (depth+1)) + indent + '}<br />';
} else {
s += indent + a + ': ' + o[a].toString() + '<br />';
}
}
return s;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -