📄 util.js
字号:
stat[2]="12:12:12";
if(val)
stat[0]=true;
else
stat[0]=false;
return stat;
break;
}
case "datetime":
{
var val=$$isDatetime(obj);
stat[0]=true;
stat[1]="?????";
stat[2]="2007-12-12 12:12:12";
if(val)
stat[0]=true;
else
stat[0]=false;
return stat;
break;
}
case "idcard":
{
var val=$$isIDCard(obj);
stat[0]=true;
stat[1]="\u8eab\u4efd\u8bc1\u53f7\u7801";
stat[2]="510921196562336592";
if(val)
stat[0]=true;
else
stat[0]=false;
return stat;
break;
}
}
}
return stat;
}
function admin_Validate(obj,msg,minLen,maxLen,exType)
{
if(minLen>maxLen)
maxLen=-1;
var object=$(obj);
if(object!='undefined')
{
var val=object.value;
var len=val.rlen();
if(object.tagName.toString().equalicase("select"))
{
if(val.toString().rlen()<1)
{
alert("\u8bf7\u9009\u62e9\u201c"+ msg +"\u201d");
object.focus();
return false;
}
return true;
}
else
{
if(minLen>-1)
{
if(len<minLen)
{
if(len==0)//\u6ca1\u6709\u586b\u5199\u4efb\u4f55\u4e1c\u897f
if(maxLen>-1)
if(maxLen==minLen)
alert("\u8bf7\u586b\u5199\u597d\u201c"+ msg +"\u201d\uff0c"+ " \u6307\u5b9a\u586b\u5199 "+ maxLen +" \u4e2a\u5b57\u7b26\uff01\n");
else
alert("\u8bf7\u586b\u5199\u597d\u201c"+ msg +"\u201d\uff0c"+ minLen +" \u5230 "+ maxLen +" \u4e2a\u5b57\u7b26\uff01\n");
else
alert("\u8bf7\u586b\u5199\u597d\u201c"+ msg +"\u201d\uff0c\u81f3\u5c11 "+ minLen +" \u4e2a\u5b57\u7b26\uff01\n");
else//\u586b\u5199\u4e86\u90e8\u5206\u6570\u636e
if(maxLen==minLen)
alert("\u60a8\u586b\u5199\u7684\u201c"+ msg +"\u201d\u5b57\u7b26\u592a\u5c11\uff0c\u6307\u5b9a "+minLen+" \u4e2a\u5b57\u7b26\uff01");
else
alert("\u60a8\u586b\u5199\u7684\u201c"+ msg +"\u201d\u5b57\u7b26\u592a\u5c11\uff0c\u81f3\u5c11 "+minLen+" \u4e2a\u5b57\u7b26\uff01");
object.focus();
return false;
}
}
if(maxLen>-1)
{
if(len>maxLen)
{
if(maxLen==minLen)
alert("\u60a8\u586b\u5199\u7684\u201c"+ msg +"\u201d\u5b57\u7b26\u592a\u591a\uff0c\u6307\u5b9a "+maxLen+" \u4e2a\u5b57\u7b26\uff01");
else
alert("\u60a8\u586b\u5199\u7684\u201c"+ msg +"\u201d\u5b57\u7b26\u592a\u591a\uff0c\u6700\u591a "+maxLen+" \u4e2a\u5b57\u7b26\uff01");
object.focus();
return false;
}
}
}
//object.value=object.value.toString().trim();
if(arguments.length==5)
{
if(len==0)
{
alert("\u8bf7\u586b\u5199\u597d\u201c"+ msg +"\u201d");
setFocusEx(object);
return false;
}
stat=validateItemTypeEx(object,exType);
if(stat[0]==false)
{
ms="\u201c"+ msg +"\u201d\u683c\u5f0f\u4e0d\u6b63\u786e\uff01\n\n \u8bf7\u586b\u5199\u5982\uff1a"+stat[2]+"\u7684\u683c\u5f0f";
alert(ms);
setFocusEx(object);
return false;
}
}
if(object.value.toString().trim()==0)
{
if(!confirm("\u60a8\u586b\u5199\u7684\u201c"+ msg +"\u201d\u5168\u4e3a\u7a7a\u683c\uff0c\u786e\u8ba4\u4fe1\u606f\u6b63\u786e\u5417\uff1f"))
{
object.select();
return false;
}
}
return true;
}
else
{
alert("\u9875\u9762\u6ca1\u6709\u627e\u5230\u60a8\u7684\u5bf9\u8c61\u53c2\u6570\uff1a\u201c"+ obj +"\u201d");
return false;
}
}
function $bindTable(object,val,step,headLine,styleCls){
var obj=$(object);
if(obj=='undefined')
return ;
if(!(val instanceof Array))
return ;
if(arguments.length==3){
styleCls="";
headLine="";
}
if(arguments.length==4){
styleCls="";
headLine=headLine.trim();
}
else if(arguments.length==5){
if(styleCls.trim().length>0)
styleCls=" class=\""+styleCls.trim()+"\"";
else
styleCls="";
}
else{
var msg="BindTable Arguments Error!\r\n";
msg+="Fuction :$bindTable(object,val,step,headLine,styleCls)\r\n";
msg+="object :The container Object(needed)\r\n";
msg+="val :The data source,typeof Array(needed)\r\n";
msg+="step :The data step,means the columns length,must be Integer(needed)\r\n";
msg+="headLine:The table's head,must has table tag if has this argument(choosen)\r\n";
msg+="styleCls:The data row style(choosen)\r\n";
alert(msg);
return ;
}
var rows=val.result;
var buffer="";
if(headLine.length<1){
buffer="<table align=\"center\">";
}
else{
buffer=headLine;
}
for(var i=0;i<rows;i++){
buffer+="<tr"+styleCls+">";
for(var j=0;j<step;j++){
buffer+="<td>"+ val[i*step+j] +"</td>";
}
buffer+="</tr>";
}
buffer+="</table>";
$bind(obj,buffer);
}
function sys_init_list(result,step,obj,defaultId,hasNull,fTxt,fValue)
{
var space=0;
if(step>1)
space=1;
var object=$(obj);
if(object=='undefined')
return ;
object.length=0;
var hasNode=false;
if(hasNull)
if(arguments.length==7)
object.options[object.length]=new Option(fTxt,fValue,true,false);
else
object.options[object.length]=new Option("","",true,false);
for(var i=0;i<result.length/step;i=i+1)
{
if(defaultId.toString()==result[i*step])
{
object.options[object.length]=new Option(result[i*step+space],result[i*step],true,true);
object.options[object.length-1].style.cssText="color:#0000FF;";
hasNode=true;
}
else
object.options[object.length]=new Option(result[i*step+space],result[i*step],true,false);
}
if(!hasNode)
{
object.options[0].style.cssText="color:#0000FF;";
}
return true;
}
/////////////////////////////////////////////////////////////////
function sys_check_select_all(obj,subItemName)
{
var subobj=[];
obj=$(obj);
if(obj=='undefined')
return ;
if(arguments.length==2)
subobj=$E(subItemName);
else
subobj=getObjsByType("checkbox");
for(var i=0;i<subobj.length;i=i+1)
{
if(obj!=subobj[i])
subobj[i].checked=obj.checked;
}
}
function sys_check_select_sub(parentObj,obj)
{
var subobj=[];
parentObj=$(parentObj);
if(arguments.length==1)
{
subobj=getObjsByType("checkbox");
}
else
{
obj=$(obj);
subobj=$E(obj.name);
}
var hasSelectOne=false;
for(var i=0;i<subobj.length;i=i+1)
{
if(parentObj!=subobj[i])
{
if(subobj[i].checked)
{
hasSelectOne=true;
break;
}
}
}
parentObj.checked=hasSelectOne;
}
function $$hideFlash(){
$hide("_flash_pane_001221x");
}
function $showFlash(isShow){
var flashObj=$("_flash_pane_001221x");
var rect=$$PageSize();
if(flashObj!=null){
flashObj.style.posLeft=parseInt((rect[2]-flashObj.style.posWidth)/2);
flashObj.style.posTop=parseInt((rect[3]-flashObj.style.posHeight)/2);
if(isShow){
$show(flashObj);
}
else{
setTimeout("$$hideFlash()",300);
}
}
else{
document.body.innerHTML+="<div id=\"_flash_pane_001221x\" style=\"position:absolute;filter:alpha(opacity=90);;display:none;width:142px; height:2px; z-index:10000; border:#00FF00 1px solid; background-color:#333333; color:#00FF00; text-align:center; font-size:12px; padding-left:5px; padding-right:5px; padding-top:10px; padding-bottom:10px; left: 365px; top: 155px;\">操作中,请稍后...</div>";
var flashObj=$("_flash_pane_001221x");
flashObj.style.posLeft=parseInt((rect[2]-flashObj.style.posWidth)/2);
flashObj.style.posTop=parseInt((rect[3]-flashObj.style.posHeight)/2);
if(isShow){
$show(flashObj);
}
else{
setTimeout("$$hideFlash()",500);
}
}
}
function $isShow(obj){
var tObj=$(obj);
if(tObj!=null){
if(tObj.style.display==''||tObj.style.display=="block")
return true;
else
return false;
}
else
return false;
}
function $$PageSize(){
var xScroll, yScroll;
if (window.innerHeight && window.scrollMaxY) {
xScroll = document.body.scrollWidth;
yScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
xScroll = document.body.scrollWidth;
yScroll = document.body.scrollHeight;
} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
xScroll = document.body.offsetWidth;
yScroll = document.body.offsetHeight;
}
var windowWidth, windowHeight;
if (self.innerHeight) { // all except Explorer
windowWidth = self.innerWidth;
windowHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
windowWidth = document.documentElement.clientWidth;
windowHeight = document.documentElement.clientHeight;
} else if (document.body) { // other Explorers
windowWidth = document.body.clientWidth;
windowHeight = document.body.clientHeight;
}
// for small pages with total height less then height of the viewport
if(yScroll < windowHeight){
pageHeight = windowHeight;
} else {
pageHeight = yScroll;
}
// for small pages with total width less then width of the viewport
if(xScroll < windowWidth){
pageWidth = windowWidth;
} else {
pageWidth = xScroll;
}
arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
return arrayPageSize;
}
function sys_initTreeOneList(result,step,object,displayId,defaultId,levelId)
{
var obj=$(object);
if(obj=='undefined')
return ;
for(var i=0;i<result.length/step;i=i+1)
{
if(displayId==result[i*step].toString())
{
sys_initTreeItemList(result,step,obj,result[i*step],defaultId,levelId,result[i*step+1],result[i*step]);
break;
}
}
}
function sys_initTreeItemList(result,step,object,displayId,defaultId,levelId,txt,val)
{
if(displayId.toString().rlen()>0)
{
levelId=levelId+1;
if(arguments.length==8)
{
if(defaultId==val)
{
object.options[object.length]=new Option(sys_getSpaceChar1(levelId)+""+txt,val,true,true);
object.options[object.length-1].style.cssText="color:#0000FF;";
}
else
{
object.options[object.length]=new Option(sys_getSpaceChar1(levelId)+""+txt,val,true,false);
}
for(var i=0;i<(result.length)/step;i=i+1)
{
if(displayId==result[i*step+2].toString())
sys_initTreeItemList(result,step,object,result[i*step],defaultId,levelId,result[i*step+1],result[i*step]);
}
}
else
{
for(var i=0;i<(result.length)/step;i=i+1)
{
if(displayId.toString()==result[i*step+2].toString())
{
sys_initTreeItemList(result,step,object,result[i*step],defaultId,levelId,result[i*step+1],result[i*step]);
break;
}
}
}
}
else
{
levelId=levelId-1;
}
}
function sys_getSpaceChar1(levelId)
{
var buf="";
for(var i=1;i<levelId-1;i=i+1)
{
buf+=" ";
}
if(i==(levelId-1))
buf+=" ";
return buf;
}
function mainHasIncludePower()
{
if(top.location != self.location)
top.location=self.location;
}
function subIncludePower()
{
if(top.location == self.location)
window.location="../";
}
function sys_setSpace_thentai(val)
{
var len=val.length;
var step=parseInt(len/4);
var buf="";
for(var i=0;i<step;i=i+1)
buf+=" ";
return buf;
}
function sys_initItemTreeThentai(object,result,defaultId,hasNull,showText,showVal)
{
var len=result.length;
object=$(object);
if(object=='undefined')
return ;
object.length=0;
if(hasNull)
object.options[0]=new Option(showText,showVal,true,false);
for(var i=0;i<len;i=i+1)
{
if(result[i][0].rlen()<5)
{
sys_initTreeListThentai(object,result,defaultId,result[i]);
}
}
var lens=object.length;
for(var i=0;i<lens;i=i+1)
{
var val=object.options[i].value;
if(val.equals(defaultId))
{
object.selectedIndex=i;
object.options[i].style.cssText="color:#0000FF;";
break;
}
}
}
function sys_initTreeListThentai(object,result,defaultId,curNode)
{
if(curNode.length>0)
{
object.options[object.length]=new Option(sys_setSpace_thentai(curNode[0])+curNode[1],curNode[0],true,false);
var len=result.length;
for(var i=0;i<len;i=i+1)
{
if((result[i][0].indexOf(curNode[0])==0)&&(result[i][0].length>curNode[0].length))
{
if(result[i][0].replace(curNode[0],"").length==4)
{
sys_initTreeListThentai(object,result,defaultId,result[i]);
}
}
}
}
}
//////////////////////////
//
var __sys_sort_column=0;
function QuickSort2(arr)
{
if(arguments.length > 1)
{
var low = arguments[1];
var high = arguments[2];
}
else
{
var low = 0;
var high = arr.length - 1;
}
if(low < high)
{
var i = low;
var j = high;
var pivot = arr[i];
while(i < j)
{
while (i < j && parseInt(arr[j][__sys_sort_column]) >= parseInt(pivot[__sys_sort_column]))
{
j--;
}
if (i < j)
{
arr[i++] = arr[j];
}
while (i < j && parseInt(arr[i][__sys_sort_column]) <= parseInt(pivot[__sys_sort_column]))
{
i++;
}
if (i < j)
{
arr[j--] = arr[i];
}
}
arr[i] = pivot;
var pivotpos = i;
QuickSort2(arr, low, pivotpos - 1);
QuickSort2(arr, pivotpos + 1, high);
}
else
{
return;
}
return arr;
}
//////////////////////////
//no repeat reandom list
function QuickSort(arr) {
if (arguments.length > 1) {
var low = arguments[1];
var high = arguments[2];
} else {
var low = 0;
var high = arr.length - 1;
}
if (low < high) {
var i = low;
var j = high;
var pivot = arr[i];
while (i < j) {
while (i < j && arr[j] >= pivot) {
j--;
}
if (i < j) {
arr[i++] = arr[j];
}
while (i < j && arr[i] <= pivot) {
i++;
}
if (i < j) {
arr[j--] = arr[i];
}
}
arr[i] = pivot;
var pivotpos = i;
QuickSort(arr, low, pivotpos - 1);
QuickSort(arr, pivotpos + 1, high);
} else {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -