📄 common(1).js
字号:
/******************************************************************************
Crossday Discuz! Board - Common Modules for Discuz!
Copyright 2001-2006 Comsenz Inc. (http://www.comsenz.com)
*******************************************************************************/
var sPop = null;
var postSubmited = false;
document.write("<style type='text/css'id='defaultPopStyle'>");
document.write(".cPopText { font-family: Tahoma, Verdana; background-color: #FFFFCC; border: 1px #000000 solid; font-size: 12px; padding-right: 4px; padding-left: 4px; line-height: 18px; padding-top: 2px; padding-bottom: 2px; visibility: hidden; filter: Alpha(Opacity=80)}");
document.write("</style>");
document.write("<div id='popLayer' style='position:absolute;z-index:1000' class='cPopText'></div>");
function showPopupText(event) {
if(event.srcElement) o = event.srcElement; else o = event.target;
MouseX=event.clientX;
MouseY=event.clientY;
if(o.alt!=null && o.alt!="") { o.pop=o.alt;o.alt="" }
if(o.title!=null && o.title!=""){ o.pop=o.title;o.title="" }
if(o.pop!=sPop) {
sPop=o.pop;
if(sPop==null || sPop=="") {
document.getElementById("popLayer").style.visibility="hidden";
} else {
if(o.dyclass!=null) popStyle=o.dyclass; else popStyle="cPopText";
document.getElementById("popLayer").style.visibility="visible";
showIt();
}
}
}
function showIt() {
document.getElementById("popLayer").className=popStyle;
document.getElementById("popLayer").innerHTML=sPop.replace(/<(.*)>/g,"<$1>").replace(/\n/g,"<br>");;
popWidth=document.getElementById("popLayer").clientWidth;
popHeight=document.getElementById("popLayer").clientHeight;
if(MouseX+12+popWidth>document.body.clientWidth) popLeftAdjust=-popWidth-24; else popLeftAdjust=0;
if(MouseY+12+popHeight>document.body.clientHeight) popTopAdjust=-popHeight-24; else popTopAdjust=0;
document.getElementById("popLayer").style.left=MouseX+12+document.body.scrollLeft+popLeftAdjust;
document.getElementById("popLayer").style.top=MouseY+12+document.body.scrollTop+popTopAdjust;
}
function ctlent(event) {
if(postSubmited == false && (event.ctrlKey && event.keyCode == 13) || (event.altKey && event.keyCode == 83)) {
if(this.document.input.pmsubmit) {
postSubmited = true;
this.document.input.pmsubmit.disabled = true;
this.document.input.submit();
} else if(validate(this.document.input)) {
postSubmited = true;
if(this.document.input.topicsubmit) this.document.input.topicsubmit.disabled = true;
if(this.document.input.replysubmit) this.document.input.replysubmit.disabled = true;
if(this.document.input.editsubmit) this.document.input.editsubmit.disabled = true;
this.document.input.submit();
}
}
}
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 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 copycode(obj) {
var rng = document.body.createTextRange();
rng.moveToElementText(obj);
rng.scrollIntoView();
rng.select();
rng.execCommand("Copy");
rng.collapse(false);
}
function toggle_collapse(objname) {
obj = findobj(objname);
img = findobj(objname+"_img");
collapsed = getcookie("discuz_collapse");
cookie_start = collapsed ? collapsed.indexOf(objname) : -1;
cookie_end = cookie_start + objname.length + 1;
if(obj.style.display == "none") {
obj.style.display = "";
img_re = new RegExp("_yes\\.gif$");
img.src = img.src.replace(img_re, '_no.gif');
if(cookie_start != -1) collapsed = collapsed.substring(0, cookie_start) + collapsed.substring(cookie_end, collapsed.length);
} else {
obj.style.display = "none";
img_re = new RegExp("_no\\.gif$");
img.src = img.src.replace(img_re, '_yes.gif');
if(cookie_start == -1) collapsed = collapsed + objname + " ";
}
expires = new Date();
expires.setTime(expires.getTime() + (collapsed ? 86400 * 30 : -(86400 * 30 * 1000)));
document.cookie = "discuz_collapse=" + escape(collapsed) + "; expires=" + expires.toGMTString() + "; path=/";
}
function toggle_collapse_new(obj) {
if(getbyid(obj).style.display == 'none') {
getbyid(obj).style.display = '';
} else {
getbyid(obj).style.display = 'none';
}
}
function toggle_collapse_display(obj,yn) {
if(yn==1) {
getbyid(obj).style.display = '';
} else {
getbyid(obj).style.display = 'none';
}
}
function shop_show(obj,yn) {
if(yn==1) {
getbyid(obj).style.display = '';
getbyid('addin_menu').style.display='none';
} else {
getbyid(obj).style.display = 'none';
}
}
function index_show(who) {
getbyid('lst'+who).style.display = '';
who=1-who;
getbyid('lst'+who).style.display = 'none';
}
function imgzoom(o) {
if(event.ctrlKey) {
var zoom = parseInt(o.style.zoom, 10) || 100;
zoom -= event.wheelDelta / 12;
if(zoom > 0) {
o.style.zoom = zoom + '%';
}
return false;
} else {
return true;
}
}
function getcookie(name) {
var cookie_start = document.cookie.indexOf(name);
var cookie_end = document.cookie.indexOf(";", cookie_start);
return cookie_start == -1 ? '' : unescape(document.cookie.substring(cookie_start + name.length + 1, (cookie_end > cookie_start ? cookie_end : document.cookie.length)));
}
//if(!document.onmouseover) {
// document.onmouseover = function(e) {
// if (!e) showPopupText(window.event); else showPopupText(e);
// };
//}
/**
* aaa
* @param string id: id string
*/
function getbyid(id) {
if(document.getElementById) {
return document.getElementById(id);
} else if(document.all(id)) {
return document.all(id);
} else if(document.all.id) {
return document.all.id;
}
}
function addtr(trid, tbid) {
var tdobj,trobj = getbyid(trid).children;
var newtrobj = document.createElement("tr");
for(var i=0;i<trobj.length;i++) {
tdobj = document.createElement("td");
tdobj.innerHTML = trobj[i].innerHTML;
newtrobj.appendChild(tdobj);
}
getbyid(tbid).children[0].appendChild(newtrobj);
}
function getcitylist(init) {
var http;
try {
http = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try{
http = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
http = new XMLHttpRequest();
}
}
http.open("POST","ajax/getgeo.php?action=getcity&init="+init,false);
http.send();
if(http.readyState == 4) {
var o = getbyid('city');
o.innerHTML = http.responseText;
}
}
function getbycity(cityid, init) {
var city = getbyid(cityid).value;
var http;
try {
http = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try{
http = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
http = new XMLHttpRequest();
}
}
http.open("POST","ajax/getgeo.php?action=getzone&cityid="+city+"&init="+init,false);
http.send();
if(http.readyState == 4) {
var o = getbyid('zone');
if(http.responseText) {
o.innerHTML = http.responseText;
} else {
o.innerHTML = '<select name="newzone"><option value="0">请选择城区</option></select>';
}
}
}
function getbyzone(cityid, zoneid, init) {
var city = getbyid(cityid).value;
var zone = getbyid(zoneid).value;
var http;
try {
http = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try{
http = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
http = new XMLHttpRequest();
}
}
http.open("POST","ajax/getgeo.php?action=getarea&cityid="+city+"&zoneid="+zone+"&init="+init,false);
http.send();
if(http.readyState == 4) {
var o = getbyid('area');
o.innerHTML = http.responseText ? http.responseText : '<select name="newarea"><option value="0">请选择商区</option></select>';
}
}
function setkup(deepth, init) {
var o = getbyid(deepth);
if(o.value > 1) {
var http;
try {
http = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try{
http = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
http = new XMLHttpRequest();
}
}
http.open("POST","ajax/getkup.php?deepth="+o.value+"&init="+init,false);
http.send();
if(http.readyState == 4) {
var o = getbyid('kupid');
o.innerHTML = http.responseText ? http.responseText : '<select name="newarea"><option value="0">请选择上级分类</option></select>';
}
}
}
function getsubkids(kid, init) {
if(kid > 0) {
var http;
try {
http = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try{
http = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
http = new XMLHttpRequest();
}
}
http.open("POST","ajax/getkup.php?kup="+kid+"&init="+init,false);
http.send();
if(http.readyState == 4) {
var o = getbyid('subkid');
o.innerHTML = http.responseText ? http.responseText : '<select name="srchkid"><option value="0">请选择子类别</option></select>';
}
}
}
function addtag() {
var tag = getbyid('tag');
var newtag = getbyid('newtag').value;
var oldtag;
if(checktag(newtag)) {
//tagnum = tagnum + 1;
if(getbyid('tagnameid'+newtag)==null){
tag.innerHTML += '<input type="button" name="tagnamebtn[]" value="'+newtag+'" onclick="deletetag(this)"><input type="hidden" name="tagname[]" id="tagnameid'+newtag+'" value="'+newtag+'">';
}
}
getbyid('newtag').value='';
}
function deletetag(thebtn) {
if(confirm('确定删除TAG: '+thebtn.value+'?')) {
//tagnum = tagnum - 1;
getbyid('tagnameid'+thebtn.value).disabled = true;
thebtn.disabled = true;
thebtn.style.display = "none";
}
}
function checktag(Sting) {
if(Sting.length < 2 || Sting.length > 10) {
alert('TAG长度不符合要求');
return false;
}
//常用的符号
var compStr = "§№☆★○●◎◇◆□■△▲※→←↑↓〓#&@\^_ ̄〖〗【】()[]{}.』『」「》《〉〈〕〔‘’“”々~‖∶"'`|¨ˇˉ·—…!?:;,、。 ~!@#$%^&*()-+={}|[]\\:;\"'<,>.?/";
var length2 = Sting.length;
for (var iIndex=0;iIndex<length2;iIndex++) {
var temp1 = compStr.indexOf(Sting.charAt(iIndex));
if(temp1>=0){
alert('TAG名中包含非法字符');
return false;
}
}
return true;
}
function cleanandfocus(oid) {
var obj = getbyid(oid);
if(obj.value == '关键字') {
obj.value = '';
obj.focus();
}
}
function ajax() {
var request = false;
if(window.ActiveXObject) {
var versions = ['Microsoft.XMLHTTP', 'MSXML.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.7.0', 'Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP'];
for(var i=0; i<versions.length; i++) {
try {
request = new ActiveXObject(versions[i]);
if(request) {
return request;
}
} catch(e) {}
}
}else if(window.XMLHttpRequest) {
request = new XMLHttpRequest();
request.overrideMimeType('text/xml');
}
return request;
}
function getmap(shopid) {
var http=ajax();
if(http){
http.onreadystatechange= function(){
if(http.readyState == 4) {
if(http.status==200){
getbyid('maplink').innerHTML += http.responseText;
}
}
};
http.open("POST","map.php?shopid="+shopid,true);
http.send(null);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -