📄 common.js
字号:
if(document.all)
{
document.execCommand("BackgroundImageCache", false, true);
}
if(!window.attachEvent && window.addEventListener)
{
Window.prototype.attachEvent = HTMLDocument.prototype.attachEvent=
HTMLElement.prototype.attachEvent=function(en, func, cancelBubble)
{
var cb = cancelBubble ? true : false;
this.addEventListener(en.toLowerCase().substr(2), func, cb);
};
Window.prototype.detachEvent = HTMLDocument.prototype.detachEvent=
HTMLElement.prototype.detachEvent=function(en, func, cancelBubble)
{
var cb = cancelBubble ? true : false;
this.removeEventListener(en.toLowerCase().substr(2), func, cb);
};
}
if(typeof Event!="undefined" && !window.opera)
{
var t=Event.prototype;
t.__defineSetter__("returnValue", function(b){if(!b)this.preventDefault(); return b;});
t.__defineSetter__("cancelBubble",function(b){if(b) this.stopPropagation(); return b;});
}
document.onkeydown=function ()
{
var event = arguments[0]||window.event;
var k = event.charCode||event.keyCode;
if (k == 13)
{
event.cancelBubble = true;
event.returnValue = false;
}
}
window.onerror=function()
{
return true;
}
function WebForm_FireDefaultButton(event, target)
{
if(event.srcElement.id == 'gopage1' && event.keyCode != 13)
{
return true;
}
else
return false;
}
function MouseCursor(obj)
{
if (is_ie)
obj.style.cursor = 'hand';
else
obj.style.cursor = 'pointer';
}
function convertdate(strdate)
{
strdate = strdate.replace(/-/ig,'/');
var d = new Date(strdate);
var now = new Date();
var result;
if (d.getYear() == now.getYear() && d.getMonth() == now.getMonth())
{
var xday = now.getDate() - d.getDate();
switch (xday)
{
case 0:
result = "今天 " + d.getHours() + " : " + d.getMinutes();
break;
case 1:
result = "昨天 " + d.getHours() + " : " + d.getMinutes();
break;
case 2:
result = "前天 " + d.getHours() + " : " + d.getMinutes();
break;
default:
result = d.format("yyyy.MM.dd hh:mm");
break;
}
}
else
{
result = d.format("yyyy.MM.dd hh:mm");
}
return result;
}
function convertdate2(strdate)
{
strdate = strdate.replace(/-/ig,'/');
var d = new Date(strdate);
var now = new Date();
var result = now - d;
alert('result:'+result);
if (now.getYear() == d.getYear() && now.getMonth() == d.getMonth() && now.getDate() - d.getDate() > 0)
{
result = (now.getDate() - d.getDate()) + " 天前";
}
else if (now.getYear() == d.getYear() && now.getMonth() == d.getMonth() && now.getDate() == d.getDate() && now.getHours() - d.getHours() > 0)
{
result = (now.getHours() - d.getHours()) + " 小时前"
}
else if (now.getYear() == d.getYear() && now.getMonth() == d.getMonth() && now.getDate() == d.getDate() && now.getHours() == d.getHours() && now.getMinutes() - d.getMinutes() > 0)
{
result = (now.getMinutes() - d.getMinutes()) + " 分钟前"
}
else
{
result = d.format("yyyy.MM.dd hh:mm");
}
return result;
}
Date.prototype.format = function(format)
{
var o = {
"M+" : this.getMonth()+1, //month
"d+" : this.getDate(), //day
"h+" : this.getHours(), //hour
"m+" : this.getMinutes(), //minute
"s+" : this.getSeconds(), //second
"q+" : Math.floor((this.getMonth()+3)/3), //quarter
"S" : this.getMilliseconds() //millisecond
};
if(/(y+)/.test(format))
{
format = format.replace(RegExp.$1,
(this.getFullYear() + "").substr(4 - RegExp.$1.length));
}
for(var k in o)
{
if(new RegExp("("+ k +")").test(format))
format = format.replace(RegExp.$1,
RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length));
}
return format;
}
function undefined(variable) {
return typeof variable == 'undefined' ? true : false;
}
function findobj(n, d) {
var p, i, x;
if(!d) d = document;
if((p = n.indexOf("?"))>0 && parent.frames.length) {
d = parent.frames[n.substring(p + 1)].document;
n = n.substring(0, p);
}
if(x != d[n] && d.all) x = d.all[n];
for(i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
for(i = 0; !x && d.layers && i < d.layers.length; i++) x = findobj(n, d.layers[i].document);
if(!x && document.getElementById) x = document.getElementById(n);
return x;
}
function expandoptions(id)
{
var a = document.getElementById(id);
if(a.style.display=='')
{
a.style.display='none';
}
else
{
a.style.display='';
}
}
function cloneObj(oClone, oParent, count) {
if(oParent.childNodes.length < count) {
var newNode = oClone.cloneNode(true);
oParent.appendChild(newNode);
return newNode;
}
return false;
}
function delObj(oParent, count) {
if(oParent.childNodes.length > count) {
oParent.removeChild(oParent.lastChild);
return true;
}
return false;
}
function cloneObj_1(oClone, oParent, i, count, msgtext)
{
var tempcount = 1;
for(k=0;k<oParent['childNodes'].length;k++){
if (oParent['childNodes'][k].tagName){
if (oParent['childNodes'][k].id == oClone.id){
tempcount ++;
}
}
}
if(tempcount <= count)
{
for(;i>0;i--)
{
newNode = oClone.cloneNode(true);
oParent.appendChild(newNode);
}
}
else
{
alert(msgtext);
}
}
function clonePoll(maxpoll){
var newNode = cloneObj(document.getElementById('divPollItem'), document.getElementById('polloptions') ,maxpoll);
if(!newNode){
alert('投票项不能多于 ' + maxpoll + ' 个');
}
var inputs = findtags(newNode, 'input');
var attach;
for(i in inputs) {
if(inputs[i].name == 'pollitemid') {
inputs[i].value="";
inputs[i].id = "pollitemid";
}
}
}
function delOjb_1(oParent, count, msgtext)
{
var tempcount = 0;
for(k=0;k<oParent['childNodes'].length;k++){
if (oParent['childNodes'][k].tagName){
tempcount ++;
}
}
if(tempcount > count)
{
oParent.removeChild(oParent.lastChild);
}
else
{
alert(msgtext);
}
}
//选择或取消选反列表中全部记录
function checkall(form, prefix, checkall) {
var checkall = checkall ? checkall : 'chkall';
for(var i = 0; i < form.elements.length; i++) {
var e = form.elements[i];
if(e.name != checkall && (!prefix || (prefix && e.name.match(prefix)))) {
e.checked = form.elements[checkall].checked;
}
}
}
//显示主题图标
function showicons(icons,iconscount,iconscolcount){
var row=null;
var col=null;
var img=null;
var rowIndex=0;
var colIndex=0;
var iCount = 0;
if(undefined(iconscount)) {
var iconscount = 0;
}
if(undefined(iconscolcount)) {
var iconscolcount = 0;
}
try{
var icons_container = findobj('iconsdiv');
var iconstable = document.createElement('table');
iconstable.cellPadding="2";
iconstable.cellSpacing="0";
iconstable.border=0;
//iconstable.className="altbg1";
iconstable.style.border="0px";
iconstable.id="topiciconstable";
if (!icons.length){
iCount = 0;
}
else{
iCount = icons.length
}
if (iconscount > 0 ){
if (iCount > iconscount){
iCount = iconscount
}
}
iCount = iCount + 1;
if (iconscolcount <1){
iconscolcount = parseInt((iCount + 1) / 2)
}
var temp_iCount = 1;
row=iconstable.insertRow(-1);
col=row.insertCell(-1);
col.vAlign="middle";
col.align = "left";
col.width = "49";
col.innerHTML = '<input type="radio" id="icon_0" name="iconid" value="0"> <label for="icon_0">无</label>';
colIndex++;
for(i=0;i<icons.length;i++)
{
if (icons[i]){
temp_iCount ++;
if (temp_iCount>iCount){
break;
}
if (colIndex>=iconscolcount || colIndex<1){
row=iconstable.insertRow(-1);
colIndex=0;
}
col=row.insertCell(-1);
col.vAlign="middle";
col.align = "left";
col.width = "49";
col.innerHTML = '<input type="radio" id="icon_' + icons[i][0] + '" name="iconid" value="' + icons[i][0] + '"> <img src="images/posticons/' + icons[i][1] + '" width="19" height="19" />';
/*
input = document.createElement('input');
input.type = "radio";
input.value = icons[i][0];
input.id = "icon_" + icons[i][0];
input.name = "iconid";
col.appendChild(input);
img=document.createElement('img');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -