📄 general.js
字号:
nleftEnd = "0" + nleftEnd; // prepend zero to LHS of number
}
if (useSeparator) nleftEnd = separate(nleftEnd, separator); // add separator
var output = nleftEnd + ((nrightEnd != "") ? "." + nrightEnd : ""); // combine parts
output = ((useCurrency) ? currency : "") + output + ((usePercent) ? percent : "");
if (isNegative) {
output = (useCurrency) ? "(" + output + ")" : "-" + output;
}
return output;
}
function strip(input, chars) { // strip all characters in 'chars' from input
var output = ""; // initialise output string
for (var i=0; i < input.length; i++)
if (chars.indexOf(input.charAt(i)) == -1)
output += input.charAt(i);
return output;
}
function separate(input, separator) { // format input using 'separator' to mark 000's
input = "" + input;
var output = ""; // initialise output string
for (var i=0; i < input.length; i++) {
if (i != 0 && (input.length - i) % 3 == 0) output += separator;
output += input.charAt(i);
}
return output;
}
function SetMaxLength(objID, maxLen)
{
var obj = document.getElementById(objID);
if (obj.value.length > maxLen)
{
obj.value = obj.value.substring(0, maxLen);
}
}
function confirmDelete()
{
var lblIsDeleteQuestion = '';
if (langId.toLowerCase() == 'cht'){
lblIsDeleteQuestion = "確定要刪除這項記錄?";
}
else if (langId.toLowerCase() == 'chs'){
lblIsDeleteQuestion = "确定要删除这项记录?";
}
else{
lblIsDeleteQuestion = "Are you sure to delete this record?";
}
return confirm(lblIsDeleteQuestion);
}
function confirmVoid()
{
var lblIsDeleteQuestion = '';
if (langId.toLowerCase() == 'cht'){
lblIsDeleteQuestion = "確定要取消這項記錄?";
}
else if (langId.toLowerCase() == 'chs'){
lblIsDeleteQuestion = "确定要取消这项记录?";
}
else{
lblIsDeleteQuestion = "Are you sure to void this record?";
}
return confirm(lblIsDeleteQuestion);
}
function confirmPost()
{
var lblIsDeleteQuestion = '';
if (langId.toLowerCase() == 'cht'){
lblIsDeleteQuestion = "確定要核准這項記錄?";
}
else if (langId.toLowerCase() == 'chs'){
lblIsDeleteQuestion = "确定要核准这项记录?";
}
else{
lblIsDeleteQuestion = "Are you sure to post this record?";
}
return confirm(lblIsDeleteQuestion);
}
function confirmComplete()
{
var lblIsDeleteQuestion = '';
if (langId.toLowerCase() == 'cht'){
lblIsDeleteQuestion = "確定要完成這項記錄?";
}
else if (langId.toLowerCase() == 'chs'){
lblIsDeleteQuestion = "确定要完成这项记录?";
}
else{
lblIsDeleteQuestion = "Are you sure to complete this record?";
}
return confirm(lblIsDeleteQuestion);
}
function confirmCancel()
{
var lblIsCancelQuestion = '';
if (langId.toLowerCase() == 'cht'){
lblIsCancelQuestion = "記錄還未儲存,確定離開此狀態?\n此記錄之更改會被放棄。";
}
else if (langId.toLowerCase() == 'chs'){
lblIsCancelQuestion = "记录还未储存,确定离开此状态?\n此记录之更改会被放弃。";
}
else{
lblIsCancelQuestion = "Your changes may not saved yet. Do you really want to proceed?\nYou will lose all the changes if you proceed without saving.";
}
return confirm(lblIsCancelQuestion);
}
function popSearchListWithParam(searchListId, url, formName, returnFieldName, sourceFieldName, preloadFieldName, otherParameters)
{
var url = resMgr.AppRootPath + url + "?action=newSearch&searchListId=";
url += "&returnFormName=" + formName;
for(var i=0; i<returnFieldName.length; i++){
url += "&returnFieldName" + i + "=" + returnFieldName[i];
}
if (sourceFieldName != null){
for(var i=0; i<sourceFieldName.length; i++) {
url += "&sourceFieldName" + i + "=" + sourceFieldName[i];
}
}
if (preloadFieldName != null){
for(var i=0; i<preloadFieldName.length; i++) {
url += "&preloadFieldName" + i + "=" + preloadFieldName[i];
}
}
url += "&returnSize=" + returnFieldName.length;
if (sourceFieldName != null){
url += "&sourceSize=" + sourceFieldName.length;
}
else{
url += "&sourceSize=0";
}
if (preloadFieldName != null){
url += "&preloadSize=" + preloadFieldName.length;
}
else{
url += "&preloadSize=0";
}
if (otherParameters != ''){
url += "&" + otherParameters;
}
var feature = "height=450,width=650,resizable=yes,scrollbars=yes,status=yes,toolbar=no,menubar=no,location=no,left=100,top=75";
window.open(url, "", feature);
}
function popSearchList(searchListId, url, formName, returnFieldName, sourceFieldName, preloadFieldName)
{
popSearchListWithParam(searchListId, url, formName, returnFieldName, sourceFieldName, preloadFieldName, '');
}
function popTextAreaEditor(returnFormName, returnFieldName, editable, pageTitleKey, maxLength)
{
var url = resMgr.AppRootPath + "/common/textAreaEditor.jsp" + "?";
url += "returnFormName=" + returnFormName;
url += "&returnFieldName=" + returnFieldName;
url += "&editable=" + editable;
url += "&pageTitleKey=" + pageTitleKey;
url += "&maxLength=" + maxLength;
var feature = "height=450,width=650,resizable=yes,scrollbars=yes,status=yes,toolbar=no,menubar=no,location=no,left=100,top=75";
window.open(url, "", feature);
}
function selectRecord(returnValue)
{
var form = '';
var field = '';
var size = eval('document.forms[0].returnSize.value');
var retValue = '';
var i = 0;
for(i=0; i<size; i++)
{
form = eval('document.forms[0].returnFormName.value');
field = eval('document.forms[0].item(\'returnFieldName' + i + '\').value');
if (field != '')
{
retValue = returnValue[i];
if (retValue != 'null'){
returnField = eval('opener.document.' + form + '.item(\'' + field + '\')');
returnField.value = retValue;
}
}
}
window.close();
}
function menuNavi(url)
{
var isCancel = false;
var mode = null;
var form = document.forms[0];
if (form != null){
if (form.item("mode") != null){
mode = form.item("mode").value;
}
}
if (mode == "edit" || mode == "addNew"){
if(mode == "edit"){
if (langId.toLowerCase() == 'cht')
{
isCancel = confirm('確定要放棄編輯?');
}
else if (langId.toLowerCase() == 'chs')
{
isCancel = confirm('确定要放弃编辑?');
}
else
{
isCancel = confirm('Are you sure to cancel edit?');
}
}
else if (mode == "addNew"){
if (langId.toLowerCase() == 'cht')
{
isCancel = confirm('確定要放棄新增?');
}
else if (langId.toLowerCase() == 'chs')
{
isCancel = confirm('确定要放弃新增?');
}
else
{
isCancel = confirm('Are you sure to cancel add new?');
}
}
if (isCancel){
window.navigate(url);
return true;
}
else{
return false;
}
}
else
{
window.navigate(url);
return true;
}
}
function getRowText(i)
{
var rowText = '';
if (langId.toLowerCase() == 'cht')
{
rowText = '(第' + i + '行)';
}
else if (langId.toLowerCase() == 'chs')
{
rowText = '(第' + i + '行)';
}
else
{
rowText = '(row ' + i + ')';
}
return rowText;
}
function chkTxtMonthYearDate(field, fieldName, required)
{
if (field.value != "")
{
if (isTxtMonthYearDate(field.value) == false)
{
if (langId == 'cht')
{
addMsg(fieldName + '必須是日期格式(MM/YYYY)。', field);
}
else if (langId == 'chs')
{
addMsg(fieldName + '必须是日期格式(MM/YYYY)。', field);
}
else
{
addMsg(fieldName + ' should be in date format(MM/YYYY).', field);
}
return false;
}
else
{
return true;
}
}
else
{
if(required)
{
return chkEmpty(field, fieldName);
}
else
{
return true;
}
}
}
function isTxtMonthYearDate(value)
{
var pos1 = value.indexOf(dtCh);
if (pos1 == -1)
return false;
var strMonth = value.substring(0,pos1);
var strYear = value.substring(pos1+1);
if ((strMonth.charAt(0) == '0') && (strMonth.length > 1))
strMonth = strMonth.substring(1);
for (var i = 1; i <= 3; i++)
{
if ((strYear.charAt(0) == '0') && (strYear.length > 1))
strYear = strYear.substring(1);
}
var month = 0;
var year = 0;
if (isInteger(strMonth) == true)
month = parseInt(strMonth);
else
return false;
if (isInteger(strYear) == true)
year = parseInt(strYear);
else
return false;
if ((strMonth.length < 1) || (month < 1) || (month > 12))
return false;
if ((strYear.length != 4) || (year == 0) || (year < minYear) || (year > maxYear))
return false;
return true;
}
function Document_OnKeyDown () {
if (document.all) {
if (showAboutThis())
return checkSpecialKey();
else
return false;
}
}
// capture the backspace in keydown event
function checkSpecialKey() {
//we can backspace in a textbox
if(event.srcElement.type && (event.srcElement.type.match("text") || event.srcElement.type.match("password"))) {
return true;
}
if(event && (event.keyCode == UKC_BACKSPACE)) {
event.cancelBubble = true;
event.returnValue = false;
return false;
}
return true;
}
//Check Month
function chkTxtMonth(field, fieldName, required)
{
if (trim(field.value) == '')
{
if (required == true)
{
if (langId == 'cht')
{
addMsg('請輸入' + fieldName + '。', field);
}
else if (langId == 'chs')
{
addMsg('请输入' + fieldName + '。', field);
}
else{
addMsg('Please enter the ' + fieldName + '.', field);
}
return false;
}
else
{
return true;
}
}
else if (isTxtMonth(field.value))
{
return true;
}
else
{
if (langId == 'cht')
{
addMsg(fieldName + '必須是 ' + minMonth + ' - ' + maxMonth + ' 之間。', field);
}
else if (langId == 'chs')
{
addMsg(fieldName + '必须是 ' + minMonth + ' - ' + maxMonth + ' 之间。', field);
}
else{
addMsg(fieldName + ' should be within ' + minMonth + ' - ' + maxMonth + '.', field);
}
return false;
}
}
function isTxtMonth(strMonth)
{
if (IsNumeric(strMonth, 2, 0))
{
var intMonth = parseInt(strMonth);
if (intMonth >= minMonth && intMonth <= maxMonth)
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -