?? gwp.js
字號:
break;
case "nospecialchar" :
//TODO:對不允許輸入特殊字符的輸入域進行鍵入時檢查
var special = specialChars.source;
break;
default :
break;
}
}
}
if (myevent.keyCode == 8) {
if (tagName != "input" && tagName != "textarea" && tagName != "select") {
myevent.keyCode = 0;
myevent.returnValue = 0;
return;
}
}
quickKey(myevent);
if (myevent.keyCode == 116 || myevent.keyCode == 122) {
myevent.keyCode = 0;
myevent.returnValue = 0;
return;
}
if (myevent.ctrlKey == true && myevent.keyCode == 78) {
myevent.keyCode = 0;
myevent.returnValue = 0;
return;
}
}
//得到快捷鍵進行處理
function quickKey(myevent){
for (var i=0;i<keyArray.length;i++){
var key =keyArray[i].quickKey;
if (typeof(key) != "undefined"){
if (isAscii(key,getFunctionKey(keyArray[i]))){
if (typeof(keyArray[i].quickFunction) != "undefined" && "" != keyArray[i].quickFunction){
var add = new Function("return " + keyArray[i].quickFunction);
add();
}else{
keyArray[i].onclick();
}
myevent.keyCode = 0;
myevent.returnValue = 0;
}
}
}
}
//判斷功能鍵
function getFunctionKey(myevent){
var functionKey = myevent.functionKey;
if (typeof(functionKey) != "undefined"){
switch (functionKey.toLowerCase()) {
case "alt" :
return functionKey.toLowerCase();
break;
case "ctrl" :
return functionKey.toLowerCase();
break;
case "shift" :
return functionKey.toLowerCase();
break;
case "none" :
return functionKey.toLowerCase();
break;
default :
break;
}
}
return "ctrl";
}
//判斷按鍵
function isAscii(key,functionKey){
switch (functionKey){
case "ctrl":
if (event.ctrlKey && key.toLowerCase().charCodeAt(0)==event.keyCode){
return true;
}
if (event.ctrlKey && key.toUpperCase().charCodeAt(0)==event.keyCode){
return true;
}
break;
case "alt":
if (event.altKey && key.toLowerCase().charCodeAt(0)==event.keyCode){
return true;
}
if (event.altKey && key.toUpperCase().charCodeAt(0)==event.keyCode){
return true;
}
break;
case "none":
if (!event.ctrlKey && !event.altKey && !event.shiftKey && key.toLowerCase().charCodeAt(0)==event.keyCode){
return true;
}
if (!event.ctrlKey && !event.altKey && !event.shiftKey && key.toUpperCase().charCodeAt(0)==event.keyCode){
return true;
}
break;
case "shift":
if (event.shiftKey && key.toLowerCase().charCodeAt(0)==event.keyCode){
return true;
}
if (event.shiftKey && key.toUpperCase().charCodeAt(0)==event.keyCode){
return true;
}
break;
default :
break;
}
return false;
}
//處理獲取焦點事件,使本域處于全部選中狀態
function initFocusIn(srcElement) {
if (srcElement==null)
return;
var tagName = srcElement.tagName.toLowerCase();
if ((tagName == "input" && (srcElement.type == "text" || srcElement.type == "password")) || tagName == "textarrea") {
srcElement.select();
}
}
//處理丟失焦點事件,并檢查域中的值是否符合設定的數據驗證類型
function checkType(srcElement) {
try {
var tagName = srcElement.tagName.toLowerCase();
var location = srcElement.getAttribute("inputname");
if (location == null || location == "") {
location = "光標所在處";
}
if ((tagName == "input" && srcElement.type == "text")
|| tagName == "textarea") {
var len = srcElement.getAttribute("maxlength");
if (len != null && !isNaN(parseInt(len)) && parseInt(len) > 0) {
if (srcElement.value.getByte() > parseInt(len)) {
alert(location + "輸入的內容超過限定的最大長度!\n最大長度為:" + len + "字節\n輸入內容的長度為:" + srcElement.value.getByte() + "字節!");
srcElement.focus();
return false;
}
}
}
if (tagName == "input" && srcElement.type == "text") {
var checktype = srcElement.getAttribute("checktype");
if (checktype == null
|| checktype.trim() == ""
|| checktype.trim().toLowerCase() == "none"
|| srcElement.value == null
|| srcElement.value == "") {
return true;
}
switch (checktype.toLowerCase()) {
case "number" :
if (!srcElement.value.isNumber()) {
srcElement.focus();
alert(location + "只能輸入半角型數字!");
srcElement.focus();
return false;
}
break;
case "int" :
if (!srcElement.value.isInt()) {
srcElement.focus();
alert(location + "只能輸入半角型整數!");
srcElement.focus();
return false;
}
break;
case "float" :
if (!srcElement.value.isFloat()) {
srcElement.focus();
alert(location + "只能輸入半角型浮點數!");
srcElement.focus();
return false;
}
break;
case "plus" :
if (!srcElement.value.isPlus()) {
srcElement.focus();
alert(location + "只能輸入半角型正數!");
srcElement.focus();
return false;
}
break;
case "plusint" :
if (!srcElement.value.isPlusInt()) {
srcElement.focus();
alert(location + "只能輸入半角型正整數!");
srcElement.focus();
return false;
}
break;
case "plusfloat" :
if (!srcElement.value.isPlusFloat()) {
srcElement.focus();
alert(location + "只能輸入半角型正浮點數!");
srcElement.focus();
return false;
}
break;
case "minus" :
if (!srcElement.value.isMinus()) {
srcElement.focus();
alert(location + "只能輸入半角型負數!");
srcElement.focus();
return false;
}
break;
case "minusint" :
if (!srcElement.value.isMinusInt()) {
srcElement.focus();
alert(location + "只能輸入半角型負整數!");
srcElement.focus();
return false;
}
break;
case "minusfloat" :
if (!srcElement.value.isMinusFloat()) {
srcElement.focus();
alert(location + "只能輸入半角型負浮點數!");
srcElement.focus();
return false;
}
break;
case "wordchar" :
if (!srcElement.value.isLeastCharSet()) {
srcElement.focus();
alert(location + "只能輸入半角型大小寫字母、數字和下劃線,不包括空格!");
srcElement.focus();
return false;
}
break;
case "zip" :
if (!srcElement.value.isZip()) {
srcElement.focus();
alert(location + "輸入的字符串不符合郵政編碼標準!");
srcElement.focus();
return false;
}
break;
case "mobile" :
if (!srcElement.value.isMobileTelephone()) {
srcElement.focus();
alert(location + "輸入的字符串不符合手機號標準!\n標準的手機號格式為:13xxxxxxxxx");
srcElement.focus();
return false;
}
break;
case "telephone" :
if (!srcElement.value.isTelephone()) {
srcElement.focus();
alert(location + "輸入的字符串不符合電話號碼標準!標準格式為:(xxxx)xxxxxxxx或者xxxx-xxxxxxxx");
srcElement.focus();
return false;
}
break;
case "fax" :
if (!srcElement.value.isTelephone()) {
srcElement.focus();
alert(location + "輸入的字符串不符合傳真號碼標準!標準格式為:(xxxx)xxxxxxxx或者xxxx-xxxxxxxx");
srcElement.focus();
return false;
}
break;
case "email" :
if (!srcElement.value.isEmail()) {
srcElement.focus();
alert(location + "輸入的字符串不符合電子郵件標準!\n標準的電子郵件格式為:xx@xx.xx");
srcElement.focus();
return false;
}
break;
case "date" :
if (!srcElement.value.isDate()) {
srcElement.focus();
alert(location + "輸入的字符串不符合日期格式標準!\n標準的日期格式為:2004-04-23");
srcElement.focus();
return false;
}
break;
case "time" :
if (!srcElement.value.isTime()) {
srcElement.focus();
alert(location + "輸入的字符串不符合時間格式標準!\n標準的時間格式為:09:30:50");
srcElement.focus();
return false;
}
break;
case "datetime" :
if (!srcElement.value.isDateTime()) {
srcElement.focus();
alert(location + "輸入的字符串不符合日期時間格式標準!\n標準的日期時間格式為:2004-04-23 09:30:50");
srcElement.focus();
return false;
}
break;
case "nospecialchar" :
if (srcElement.value.hasSpecialChar()) {
srcElement.focus();
alert(location + "輸入的字符串中包含特殊字符!\n以下字符集為特殊字符集:\n" + specialChars.source);
srcElement.focus();
return false;
}
break;
default :
break;
}
}
return true;
}
catch (e) {
alert(e);
return false;
}
return true;
}
//對頁面上的各種輸入域做初始化處理
function initControl(myevent) {
var selEls = window.document.getElementsByTagName("select");
for (var i = 0; i < selEls.length; i++) {
/*if (selEls[i].className == 'inputselect') {
selEls[i].outerHTML = '<div class="inputtext">' + selEls[i].outerHTML + '</div>';
}
else if (selEls[i].className == 'inputselectshort') {
selEls[i].outerHTML = '<div class="inputtextshort">' + selEls[i].outerHTML + '</div>';
}*/
if (selEls[i].disabled) {
selEls[i].className = selEls[i].className + "readonly";
}
}
var writeEls = window.document.getElementsByTagName("input");
for (var i = 0; i < writeEls.length; i++) {
if (writeEls[i].readOnly || writeEls[i].disabled) {
writeEls[i].className = writeEls[i].className + "readonly";
}
if (writeEls[i].type == "button"){
keyLoad(writeEls[i]);
}
}
var writeEls = window.document.getElementsByTagName("textarea");
for (var i = 0; i < writeEls.length; i++) {
if (writeEls[i].readOnly || writeEls[i].disabled) {
writeEls[i].className = writeEls[i].className + "readonly";
}
}
var writeEls = window.document.getElementsByTagName("button");
for (var i = 0; i < writeEls.length; i++) {
keyLoad(writeEls[i]);
}
}
function keyLoad(els){
keyArray[keyArray.length] = els;
}
function gwpEvent() {
this.onclick = "";
this.onkeydown = "";
this.onfocusin = "";
this.onfocusout = "";
this.onload = "";
this.run = function (exp) {
if (exp != null && exp.trim() != "") {
eval(exp);
}
};
}
var gwpEventor = new gwpEvent();
/*
//頁面加載時屏蔽右鍵菜單
document.oncontextmenu = function() {
return closeContextMenu(window.event);
};
//頁面加載時屏蔽shift加左鍵點擊鏈接時從新窗口打開
document.onclick = function() {
gwpEventor.run(gwpEventor.onclick);
return closeNewWindow(window.event);
};*/
document.onkeydown = function () {
gwpEventor.run(gwpEventor.onkeydown);
checkKeyDown(window.event);
};
document.onfocusin = function () {
gwpEventor.run(gwpEventor.onfocusin);
initFocusIn(window.event.srcElement);
};
document.onfocusout = function () {
gwpEventor.run(gwpEventor.onfocusout);
//checkType(window.event.srcElement);
};
window.onload = function() {
initControl(window.event);
gwpEventor.run(gwpEventor.onload);
};
function initTab(str,index){
if(str==null || str=="") return
var tabobj=document.all("tab")
if(tabobj==null) return;
var row = tabobj.rows[0];
var arr = str.split(",");
for (i = 0; i < arr.length; i++){
var otd = row.insertCell();
otd.innerText = arr[i];
if(index==i)
otd.className='taboncss';
else
otd.className='taboffcss';
}
doSelectTab(index);
}
function doTabClick(){
var obj=window.event.srcElement;
if(obj==null || obj.tagName!='TD') return;
var index=obj.cellIndex;
var tabobj=document.all("tab")
if(tabobj==null) return;
for(var i=0;i<tabobj.rows[0].cells.length;i++){
tabobj.rows[0].cells[i].className='taboffcss';}
tabobj.rows[0].cells[index].className='taboncss';
doSelectTab(index);
}
function doSelectTab(index){
var tabobj=document.all("tab")
if(tabobj==null) return;
var divAll=tabobj.nextSibling;
if(divAll==null) return;
for(var j=0;j<divAll.children.length;j++)
divAll.children[j].style.display='none';
divAll.children[index].style.display='block';
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -