/**
* copyright (c), 2011
*/
var marked_row = new array;
var regexenum =
{
intege:/^-?\d+$/, //整数
intege1:/^\d+$/, //正整数
intege2:/^((-\d+)|(0+))$/, //负整数
num:/^[0-9]*$/, //数字
// email:/^\\w+((-\\w+)|(\\.\\w+))*\\@[a-za-z0-9]+((\\.|-)[a-za-z0-9]+)*\\.[a-za-z0-9]+$/, //邮件
email:/^[\w-]+(\.[\w-]+)*@[\w-]+(\.(\w)+)*(\.(\w){2,3})$/,
notempty:/[^\\0]+/, //非空
english:/[a-za-z][a-za-z0-9_]*/, //用来用户注册。匹配由数字、26个英文字母或者下划线组成的字符串
username:/[a-za-z][a-za-z0-9_]*/, //用来用户注册。匹配由数字、26个英文字母或者下划线组成的字符串
password:/[a-za-z][a-za-z0-9_]*/, //用来用户注册。匹配由数字、26个英文字母或者下划线组成的字符串
date:/^\d{4}-(0?[1-9]|1[0-2])-(0?[1-9]|[1-2]\d|3[0-1])$/, //日期
time:/^((\d{2}(([02468][048])|([13579][26]))[\-\/\s]?((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|([1-2][0-9])))))|(\d{2}(([02468][1235679])|([13579][01345789]))[\-\/\s]?((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|(1[0-9])|(2[0-8]))))))(\s(((0?[0-9])|(1[0-9])|(2[0-3]))\:(([0-5][0-9])|([0-9]))(((\s)|(\:(([0-5][0-9])|([0-9]))))?)))?$/
}
//气泡提示窗口
function hintdialog(obj_id, obj_title, obj_type) {
var objstyle = "style=\"position:absolute;top:" + ($("#" + obj_id).offset().top - 43) + "px;left:" + ($("#" + obj_id).offset().left - 10) + "px;width:200px;\"";
var varmessage = "
"
+"
"
+"
"
+obj_title
+"
"
+"
"
+"
"
+""
+"";
if (obj_type == 1) {
varmessage = "" + obj_title + ""; objstyle = "";
}
if (obj_type == 2) {
objstyle = "style=\"position:absolute;top:" + ($("#" + obj_id).offset().top +20) + "px;left:" + ($("#" + obj_id).offset().left - 10) + "px;width:300px;\"";
varmessage = ""
+ ""
+ ""
+ "
"
+ "
"
+ obj_title
+ "
"
+ "
"
+ "
";
}
$("#" + obj_id).focus();
$("#" + obj_id).after("");
$("#message" + obj_id).append(varmessage);
$("body").mousedown(function () { $("#message" + obj_id).empty(); });
}
//输入内容验证
function isreginput(obj_type, id, type, title, min, max) {
var pattern = regexenum[type];
var strvalue = $("#" + id).val().replace("-","");
var returntype = true;
if (getlength(strvalue) >= min && getlength(strvalue) <= max) {
if (getlength(strvalue) > 0) {
if (pattern.test(strvalue) == false) {
returntype = false;
}
}
}
else {
returntype = false;
}
if (returntype == false) {
alert(title);
//new hintdialog(id, "" + title, obj_type);
}
return returntype;
}
//两输入框内容比较验证
function iscompinput(obj_type, id1, id2, title) {
var returntype = true;
if ($("#" + id1).val() != $("#" + id2).val()) {
new hintdialog(id2, "" + title, obj_type);
returntype = false;
}
return returntype;
}
//返回对象长度
function getlength(realstr) {
var str = realstr.split('');
var length = 0;
for (var i = 0; i < str.length; i++) {
length += 1;
if (isexistspecialchar(str[i])) {
length += 1;
}
}
return length;
}
function isexistspecialchar(str) {
return escape(str).indexof("%u") == "-1" ? false : true;
}
//截取字符
function gettitle(str, startp, endp) {
var i = 0; c = 0; unicode = 0; rstr = '';
var len = str.length;
var sblen = getlength(str);
if (startp < 0) {
startp = sblen + startp;
}
if (endp < 1) {
endp = sblen + endp; // - ((str.charcodeat(len-1) < 127) ? 1 : 2);
}
// 寻找起点
for (i = 0; i < len; i++) {
if (c >= startp) {
break;
}
var unicode = str.charcodeat(i);
if (unicode < 127) {
c += 1;
} else {
c += 2;
}
}
// 开始取
for (i = i; i < len; i++) {
var unicode = str.charcodeat(i);
if (unicode < 127) {
c += 1;
} else {
c += 2;
}
rstr += str.charat(i);
if (c >= endp) {
break;
}
}
return rstr;
}
var lableselectclassid = "";
function list_lablemenu(lablename,lableid) {
if (lableselectclassid != "") {
$("#" + lablename + lableselectclassid).attr("class", "");
$("#"+lablename+"table" + lableselectclassid).hide();
$("#" + lablename + "table" + lableselectclassid).fadeout("slow");
}
if ($("#" + lablename + lableid).attr("class") == "") {
$("#" + lablename + lableid).attr("class", "current");
$("#" + lablename + "table" + lableid).fadein("slow");
lableselectclassid = lableid;
}
}
//只能输入数字 onkeypress="isnum()"
function isnum() {
var keycode = event.keycode;
if ((keycode >= 48 && keycode <= 57))
{
event.returnvalue = true;
} else {
event.returnvalue = false;
}
}
//隔行变色
function tablecolor(tablename){
var rows=document.getelementbyid(tablename).getelementsbytagname("tr");
for (i=1;i 0 ) {
unique_id = this.id;
} else {
return;
}
if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) {
marked_row[unique_id] = true;
} else {
marked_row[unique_id] = false;
}
if ( marked_row[unique_id] ) {
this.classname += ' marked';
} else {
this.classname = this.classname.replace(' marked', '');
}
if ( checkbox && checkbox.disabled == false ) {
checkbox.checked = marked_row[unique_id];
}
}
// ... and disable label ...
var labeltag = rows[i].getelementsbytagname('label')[0];
if ( labeltag ) {
labeltag.onclick = function() {
return false;
}
}
// .. and checkbox clicks
var checkbox = rows[i].getelementsbytagname('input')[0];
if ( checkbox ) {
checkbox.onclick = function() {
// opera does not recognize return false;
this.checked = ! this.checked;
}
}
}
}
// 全选操作
function markall(obj)
{
if(obj.checked)
{
if(markallrows('table')) return false;
}
else
{
if(unmarkallrows('table')) return false;
}
}
// 全选操作
function markallrows(container_id)
{
var rows = document.getelementbyid(container_id).getelementsbytagname('tr');
var unique_id;
var checkbox;
for ( var i = 0; i < rows.length; i++ )
{
checkbox = rows[i].getelementsbytagname( 'input' )[0];
if ( checkbox && checkbox.type == 'checkbox' )
{
unique_id = checkbox.name + checkbox.value;
if ( checkbox.disabled == false )
{
checkbox.checked = true;
if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] )
{
rows[i].classname += ' marked';
marked_row[unique_id] = true;
}
}
}
}
return true;
}
function unmarkallrows(container_id)
{
var rows = document.getelementbyid(container_id).getelementsbytagname('tr');
var unique_id;
var checkbox;
for ( var i = 0; i < rows.length; i++ )
{
checkbox = rows[i].getelementsbytagname( 'input' )[0];
if ( checkbox && checkbox.type == 'checkbox' )
{
unique_id = checkbox.name + checkbox.value;
checkbox.checked = false;
rows[i].classname = rows[i].classname.replace(' marked', '');
marked_row[unique_id] = false;
}
}
return true;
}
//选择操作模式
function getaction(formname) {
selectnum = 0
for (var i = 0; i < eval(formname + ".elements.length"); i++) {
var e = eval(formname + ".elements[i]");
if (e.type == 'checkbox') {
if (e.checked == true) { selectnum = 1; }
}
}
if (selectnum == 0) { $("info_action").selectedindex = 0; alert("请选择操作对象!"); return false; }
eval("document." + formname + ".submit();")
$("info_action").selectedindex = 0;
}
//打开上传模态对话框
function showuploaddialog(textname,opw,oph)
{
//window.open(functionstr+url,null,"modal=yes,width="+opw*1.2+",height="+oph+",resizable=no,scrollbars=yes,status=no");
window.showmodaldialog("../../upload/upfile.php?textname="+textname,window,"dialogwidth:" + opw + "px;dialogheight:" + oph + "px;help:no;scroll:no;status:no");
}
function selcolors(filedname,picname,path)
{
if (typeof(path)=="undefined" || path==""){path="../../";}
var retval;
retval = window.showmodaldialog(path+"script/inc/selectcolor/select_color.htm","selcolor","dialogwidth:290px;dialogheight:250px;dialogleft:372px;dialogtop:210px;directories:no;localtion:no;menubar:no;status:no;toolbar:no;scrollbars:yes;resizeable:no;help:no");
if (retval!=null)
{
document.getelementbyid(filedname).value = retval;
if (typeof(picname)!="undefined" && picname != "")
{
document.getelementbyid(picname).style.backgroundcolor = retval;
}
}
}
//设置tags内容
function selecttag(tagsvalueid,tag)
{
tags = document.getelementbyid(tagsvalueid);
if(!tags)
tags = document.getelementbyid(tagsvalueid);
if (tags.value.indexof(tag) < 0)
{
if ((tag.indexof(" ")>0) || (tag.indexof(",")>0) || (tag.indexof(" ")>0) || (tag.indexof(",")>0))
{
tags.value += " \"" + tag + "\"";
}
else
{ if(tags.value=="")
{tags.value= tag;}
else
{tags.value += "," + tag;}
}
}
}
//显示隐藏div内容
function displaydiv(tagsvalueid)
{
tagsdiv = document.getelementbyid(tagsvalueid);
if(tagsdiv.style.display=="none")
{tagsdiv.style.display="";}
else
{tagsdiv.style.display="none";}
}
//上传组件
function uploaddialog(textname) {
alert("fdfas");
colorbox({href: "/upload/admin_upfile?textname=" + textname});
}
//打开上传模态对话框
function insertuploaddialog(url,opw,oph)
{
//window.open(functionstr+url,null,"modal=yes,width="+opw*1.2+",height="+oph+",resizable=no,scrollbars=yes,status=no");
window.showmodaldialog(functionstr+url,window,"dialogwidth:" + opw + "px;dialogheight:" + oph + "px;help:no;scroll:no;status:no");
}
//打开预览信息模态对话框
function insertinfopreviewdialog(url,opw,oph)
{
window.showmodaldialog(url,window,"dialogwidth:" + opw + "px;dialogheight:" + oph + "px;help:no;scroll:auto;status:no");
}
function switchtag(tag)
{
var rows=document.getelementbyid("seltage").getelementsbytagname("a");
for (i=1;i/g," ");
str = str.replace(/<\/?[^>]*>/g,''); //去除html tag
str.value = str.replace(/[ | ]*\n/g,'\n'); //去除行尾空白
str = str.replace(/\n[\s| | ]*\r/g,'\n'); //去除多余空行
str = str.replace(/</g,"<");
str = str.replace(/>/g,">");
str = str.replace(/ /g," ");
return str;
}
function getdescribe(str,str2)
{
$("#"+str2).value=removehtml($("#"+str).value).substr(0,130);
}