📄 string.js
字号:
// JavaScript Document
//<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<!--
function getURLencode(GetURL){
GetURL = GetURL.replace('~','%7e');
GetURL = GetURL.replace('@','%40');
GetURL = GetURL.replace('#','%23');
GetURL = GetURL.replace('$','%24');
GetURL = GetURL.replace('%','%25');
GetURL = GetURL.replace('\^','%5e');
GetURL = GetURL.replace('&','%26');
GetURL = GetURL.replace('+','%2b');
GetURL = GetURL.replace('|','%7c');
GetURL = GetURL.replace('\\','%5c');
GetURL = GetURL.replace('\=','%3d');
GetURL = GetURL.replace('`','%60');
GetURL = GetURL.replace('{','%7b');
GetURL = GetURL.replace('}','%7d');
GetURL = GetURL.replace(']','%5d');
GetURL = GetURL.replace('[','%5b');
GetURL = GetURL.replace('"','%22');
GetURL = GetURL.replace(':','%3a');
GetURL = GetURL.replace(';','%3b');
GetURL = GetURL.replace('?','%3f');
GetURL = GetURL.replace('>','%3e');
GetURL = GetURL.replace('<','%3c');
GetURL = GetURL.replace('/','%2f');
GetURL = GetURL.replace(',','%2c');
GetURL = GetURL.replace(' ','+');
return GetURL;
}
function getURLdecode(GetURL){
GetURL = GetURL.replace('%7e','~');
GetURL = GetURL.replace('%40','@');
GetURL = GetURL.replace('%23','#');
GetURL = GetURL.replace('%24','$');
GetURL = GetURL.replace('%25','%');
GetURL = GetURL.replace('%5e','^');
GetURL = GetURL.replace('%26','&');
GetURL = GetURL.replace('%2b','+');
GetURL = GetURL.replace('%7c','|');
GetURL = GetURL.replace('%5c','\\');
GetURL = GetURL.replace('%3d','=');
GetURL = GetURL.replace('%60','`');
GetURL = GetURL.replace('%7b','{');
GetURL = GetURL.replace('%7d','}');
GetURL = GetURL.replace('%5d',']');
GetURL = GetURL.replace('%5b','[');
GetURL = GetURL.replace('%22','"');
GetURL = GetURL.replace('%3a',':');
GetURL = GetURL.replace('%3b',';');
GetURL = GetURL.replace('%3f','?');
GetURL = GetURL.replace('%3e','>');
GetURL = GetURL.replace('%3c','<');
GetURL = GetURL.replace('%2f','/');
GetURL = GetURL.replace('%2c',',');
GetURL = GetURL.replace('+',' ');
return GetURL;
}
function runOpen(GetURL, IsModal, GetWidth, GetHeight){
if (GetURL == null || GetURL == '') return; else GetURL = escape(GetURL);
if (typeof(GetWidth) != 'number' || GetWidth < 0) GetWidth = screen.availWidth/2;
if (typeof(GetHeight) != 'number' || GetHeight < 0) GetHeight = screen.availHeight/2;
var sFeatures = 'dialogHeight =' + GetHeight + 'px;' +
'dialogWidth =' + GetWidth + 'px;' +
'help: no;' +
'status: no;'
if (typeof(IsModal) == 'boolean' && IsModal == false){
window.showModelessDialog('/jsp/dialogbox.jsp?url='+GetURL,window,sFeatures);
}else{
window.showModalDialog('/jsp/dialogbox.jsp?url='+GetURL,window,sFeatures);
}
}
function runCheckForm(FormHandle){
var inputs = FormHandle.all.tags('INPUT');
var areas = FormHandle.all.tags('TEXTAREA');
if (inputs.length > 0){
for (var i = 0; i < inputs.length; i++){
if (!runCheckControl(inputs[i])) return false;
}
}
if (areas.length > 0){
for (var i = 0; i < areas.length; i++){
if (!runCheckControl(areas[i])) return false;
}
}
return true;
}
function runCheckControl(ControlHandle){
var type_num = /[-|+]?\d+\.*\d*$/;
var type_date = /\d{2,4}[-\/]\d{1,2}[-\/]\d{1,2}$/;
var type_time = /^\d{2}:\d{2}(:\d{2})*$/;
var type_datetime = /^\d{4}-\d{1,2}-\d{1,2}\s+\d{2}:\d{2}(:\d{2})*$/;
var type_mail = /\w+([-.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
var type_http = /http:\/\/[\w-]+(\.[\w-]+)*(\/[\w-]?)*$/;
var desc = '未知控件';
if (ControlHandle.desc != null){
desc = ControlHandle.desc;
}else if(ControlHandle.id != null){
desc = ControlHandle.id;
}else if(ControlHandle.name != null){
desc = ControlHandle.name;
}
if (ControlHandle.style.visibility == 'hidden') return true;
//if (ControlHandle.datatype == null) return true;
if (ControlHandle.allownull != null && ControlHandle.allownull == 'true'){
if (ControlHandle.value == '') return true;
}else{
if (ControlHandle.value == ''){
alert('提示信息\n\n 说明: '+desc+'\n 描述: 输入值不能为空!');
ControlHandle.focus();
return false;
}
}
var result = null;
var max = null;
var min = null;
var datatype = ControlHandle.datatype;
if (datatype == 'number') {
if (ControlHandle.max != null){
result = ControlHandle.max.match(type_num);
if (result != null) max = parseFloat(result[0]);
}
if (ControlHandle.min != null){
result = ControlHandle.min.match(type_num);
if (result != null) min = parseFloat(result[0]);
}
}else if(datatype == "date") {
if (ControlHandle.max != null){
result = ControlHandle.max.match(type_date);
result = result[0].replace(/\-/g,'/');
if (result != null) max = new Date(result);
}
if (ControlHandle.min != null){
result = ControlHandle.min.match(type_date);
result = result[0].replace(/\-/g,'/');
if (result != null) min = new Date(result);
}
}
switch (datatype){
case 'number':
result = ControlHandle.value.match(type_num);
if (result == null){
alert('提示信息\n\n 说明: '+desc+'\n 描述: 输入值格式错误!\n 示例: -+0123456789');
ControlHandle.focus();
return false;
}
if (max != null && parseFloat(result[0]) > max){
alert('提示信息\n\n 说明: '+desc+'\n 描述: 输入值不能大于'+max+'!');
ControlHandle.focus();
return false;
}
if (min != null && parseFloat(result[0]) < min){
alert('提示信息\n\n 说明: '+desc+'\n 描述: 输入值不能小于'+min+'!');
ControlHandle.focus();
return false;
}
break;
case 'mail':
result = ControlHandle.value.match(type_mail);
if (result == null){
alert('提示信息\n\n 说明: '+desc+'\n 描述: 输入值格式错误!\n 示例: xxx@xxx.xxx');
ControlHandle.focus();
return false;
}
if (max != null && result[0].length > max){
alert('提示信息\n\n 说明: '+desc+'\n 描述: 输入值长度不能多于'+max+'!');
ControlHandle.focus();
return false;
}
if (min != null && result[0].length < min){
alert('提示信息\n\n 说明: '+desc+'\n 描述: 输入值字节长度不能少于'+min+'!');
ControlHandle.focus();
return false;
}
break;
case 'http':
result = ControlHandle.value.match(type_http);
if (result == null){
alert('提示信息\n\n 说明: '+desc+'\n 描述: 输入值格式错误!\n 示例: http://xxx.xxx.xxx');
ControlHandle.focus();
return false;
}
if (max != null && result[0].length > max){
alert('提示信息\n\n 说明: '+desc+'\n 描述: 输入值字节长度不能多于'+max+'!');
ControlHandle.focus();
return false;
}
if (min != null && result[0].length < min){
alert('提示信息\n\n 说明: '+desc+'\n 描述: 输入值字节长度不能少于'+min+'!');
ControlHandle.focus();
return false;
}
break;
case 'date':
result = ControlHandle.value.match(type_date);
if (result == null){
alert('提示信息\n\n 说明: '+desc+'\n 描述: 输入值格式错误!\n 示例: 2000-09-10');
ControlHandle.focus();
return false;
}
result = result[0].replace(/\-/g,'/');
result = new Date(result);
if (max != null && result > max){
max = max.getFullYear()+'-'+(max.getMonth()+1)+'-'+max.getDate();
alert('提示信息\n\n 说明: '+desc+'\n 描述: 输入值不能大于'+max+'!');
ControlHandle.focus();
return false;
}
if (min != null && result < min){
min = min.getFullYear()+'-'+(min.getMonth()+1)+'-'+min.getDate();
alert('提示信息\n\n 说明: '+desc+'\n 描述: 输入值不能小于'+min+'!');
ControlHandle.focus();
return false;
}
break;
case 'time':
result = ControlHandle.value.match(type_time);
if (result == null){
alert('提示信息\n\n 说明: '+desc+'\n 描述: 输入时间格式错误!\n 示例: 22:01:01 \n小时请按照24小时制输入');
ControlHandle.focus();
return false;
}
break;
case 'datetime':
result = ControlHandle.value.match(type_datetime);
if (result == null){
alert('提示信息\n\n 说明: '+desc+'\n 描述: 输入日期-时间格式错误!\n 示例: 2000-10-01 09:30:31 \n小时请按照24小时制输入');
ControlHandle.focus();
return false;
}
break;
default:
result = getByteLength(ControlHandle.value);
if (max != null && result > max){
alert('提示信息\n\n 说明: '+desc+'\n 描述: 输入值字节长度不能多于'+max+'!');
ControlHandle.focus();
return false;
}
if (min != null && result < min){
alert('提示信息\n\n 说明: '+desc+'\n 描述: 输入值字节长度不能少于'+min+'!');
ControlHandle.focus();
return false;
}
break;
}
return true;
}
function getTrimString(GetString){
GetString = getLTrimString(GetString);
GetString = getRTrimString(GetString);
return GetString;
}
function getLTrimString(GetString){
return GetString.replace(/\s+/,'');
}
function getRTrimString(GetString){
return GetString.replace(/\s+$/,'');
}
function getByteLength(GetString){
var intCount = 0;
for(var i = 0;i < GetString.length;i++)
{
// Ascii码大于255是双字节的字符
if(GetString.charCodeAt(i) > 255) intCount += 2; else intCount += 1;
}
return intCount;
}
function runTableOnClick(TableHandle){
var e = event.srcElement;
if (e.tagName == 'TABLE') return;
while (e.tagName != 'TR') e = e.parentElement;
if (e.rowIndex == 0 || e.className == 'itemDisabled') return;
var el = e;
while (el.tagName != 'TABLE') el = el.parentElement;
for (var i = 0; i < el.rows.length; i++){
if (el.rows(i).className == 'itemOver'){
el.rows(i).className = 'itemOut';
break;
}
}
e.className = 'itemOver';
if (TableHandle != null){
if (event.button == 2) menuShow(TableHandle); else menuHide(TableHandle);
}
}
function getTableSingleSelectedIndex(TableHandle)
{
var oActiveItem = null;
for (i = 1; i < TableHandle.rows.length; i++){
if (TableHandle.rows(i).className == 'itemOver'){
//oMultiple.push(e);
break;
}
}
return i;
}
function getTableSingleSelected(TableHandle){
var oActiveItem = null;
for (i = 1; i < TableHandle.rows.length; i++){
if (TableHandle.rows(i).className == 'itemOver'){
//oMultiple.push(e);
oActiveItem = TableHandle.rows(i);
break;
}
}
return oActiveItem;
}
//-->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -