📄 sugar_3.js
字号:
} if(min!='undef' && max!='undef' && _default!='undef'){ if(!inRange(_default,min,max)){ invalidLogic=true; showErrorsOn.min.show=true; showErrorsOn.max.show=true; showErrorsOn._default.show=true; } } if(min!='undef' && max!= 'undef' && min > max){ invalidLogic = true; showErrorsOn.min.show=true; showErrorsOn.max.show=true; } if(min!='undef' && _default!='undef' && _default < min){ invalidLogic = true; showErrorsOn.min.show=true; showErrorsOn._default.show=true; } if(max!='undef' && _default !='undef' && _default>max){ invalidLogic = true; showErrorsOn.max.show=true; showErrorsOn._default.show=true; } if(invalidLogic){ isError=true; for(var error in showErrorsOn) if(showErrorsOn[error].show) add_error_style(formname,showErrorsOn[error].value, formsWithFieldLogic.msg); } else if (!isError) formsWithFieldLogic = null; } } if(formWithPrecision){ if (!isValidPrecision(formWithPrecision.float.value, formWithPrecision.precision.value)){ isError = true; add_error_style(formname, 'default', 'is not compatible with precision value'); }else if(!isError){ isError = false; } }//END BUG# 15102 if (isError == true) { var nw, ne, sw, se; if (self.pageYOffset) // all except Explorer { nwX = self.pageXOffset; seX = self.innerWidth; nwY = self.pageYOffset; seY = self.innerHeight; } else if (document.documentElement && document.documentElement.scrollTop) // Explorer 6 Strict { nwX = document.documentElement.scrollLeft; seX = document.documentElement.clientWidth; nwY = document.documentElement.scrollTop; seY = document.documentElement.clientHeight; } else if (document.body) // all other Explorers { nwX = document.body.scrollLeft; seX = document.body.clientWidth; nwY = document.body.scrollTop; seY = document.body.clientHeight; } var inView = true; // is there an error within viewport of browser for(var wp = 0; wp < inputsWithErrors.length; wp++) { var elementCoor = findElementPos(inputsWithErrors[wp]); if(!(elementCoor.x >= nwX && elementCoor.y >= nwY && elementCoor.x <= seX && elementCoor.y <= seY)) { // if input is not within viewport inView = false; scrollToTop = elementCoor.y - 75; scrollToLeft = elementCoor.x - 75; } else { // on first input within viewport, don't scroll break; } } if(!inView) window.scrollTo(scrollToTop, scrollToLeft); return false; } return true;}/** * This array is used to remember mark status of rows in browse mode */var marked_row = new Array;/** * Sets/unsets the pointer and marker in browse mode * * @param object the table row * @param interger the row number * @param string the action calling this script (over, out or click) * @param string the default background color * @param string the color to use for mouseover * @param string the color to use for marking a row * * @return boolean whether pointer is set or not */function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor) { var theCells = null; // 1. Pointer and mark feature are disabled or the browser can't get the // row -> exits if ((thePointerColor == '' && theMarkColor == '') || typeof(theRow.style) == 'undefined') { return false; } // 2. Gets the current row and exits if the browser can't get it if (typeof(document.getElementsByTagName) != 'undefined') { theCells = theRow.getElementsByTagName('td'); } else if (typeof(theRow.cells) != 'undefined') { theCells = theRow.cells; } else { return false; } // 3. Gets the current color... var rowCellsCnt = theCells.length; var domDetect = null; var currentColor = null; var newColor = null; // 3.1 ... with DOM compatible browsers except Opera that does not return // valid values with "getAttribute" if (typeof(window.opera) == 'undefined' && typeof(theCells[0].getAttribute) != 'undefined') { currentColor = theCells[0].getAttribute('bgcolor'); domDetect = true; } // 3.2 ... with other browsers else { currentColor = theCells[0].style.backgroundColor; domDetect = false; } // end 3 // 4. Defines the new color // 4.1 Current color is the default one if (currentColor == '' || (currentColor!= null && (currentColor.toLowerCase() == theDefaultColor.toLowerCase()))) { if (theAction == 'over' && thePointerColor != '') { newColor = thePointerColor; } else if (theAction == 'click' && theMarkColor != '') { newColor = theMarkColor; marked_row[theRowNum] = true; } } // 4.1.2 Current color is the pointer one else if (currentColor!= null && (currentColor.toLowerCase() == thePointerColor.toLowerCase()) && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) { if (theAction == 'out') { newColor = theDefaultColor; } else if (theAction == 'click' && theMarkColor != '') { newColor = theMarkColor; marked_row[theRowNum] = true; } } // 4.1.3 Current color is the marker one else if (currentColor!= null && (currentColor.toLowerCase() == theMarkColor.toLowerCase())) { if (theAction == 'click') { newColor = (thePointerColor != '') ? thePointerColor : theDefaultColor; marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum]) ? true : null; } } // end 4 // 5. Sets the new color... if (newColor) { var c = null; // 5.1 ... with DOM compatible browsers except Opera if (domDetect) { for (c = 0; c < rowCellsCnt; c++) { theCells[c].setAttribute('bgcolor', newColor, 0); } // end for } // 5.2 ... with other browsers else { for (c = 0; c < rowCellsCnt; c++) { theCells[c].style.backgroundColor = newColor; } } } // end 5 return true;} // end of the 'setPointer()' function/** * listbox redirection */function goToUrl(selObj, goToLocation) { eval("document.location.href = '" + goToLocation + "pos=" + selObj.options[selObj.selectedIndex].value + "'");}var json_objects = new Object();function getXMLHTTPinstance() { var xmlhttp = false; var userAgent = navigator.userAgent.toLowerCase() ; // IE Check supports ActiveX controls if (userAgent.indexOf("msie") != -1 && userAgent.indexOf("mac") == -1 && userAgent.indexOf("opera") == -1) { var version = navigator.appVersion.match(/MSIE (.\..)/)[1] ; if(version >= 5.5 ) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } } } if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp = new XMLHttpRequest(); } return xmlhttp;}// NOW LOAD THE OBJECT..var global_xmlhttp = getXMLHTTPinstance();function http_fetch_sync(url,post_data) { global_xmlhttp = getXMLHTTPinstance(); var method = 'GET'; if(typeof(post_data) != 'undefined') method = 'POST'; try { global_xmlhttp.open(method, url,false); } catch(e) { alert('message:'+e.message+":url:"+url); } if(method == 'POST') { global_xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); } global_xmlhttp.send(post_data); var args = {"responseText" : global_xmlhttp.responseText, "responseXML" : global_xmlhttp.responseXML, "request_id" : request_id}; return args;}// this is a GET unless post_data is definedfunction http_fetch_async(url,callback,request_id,post_data) { var method = 'GET'; if(typeof(post_data) != 'undefined') { method = 'POST'; } try { global_xmlhttp.open(method, url,true); } catch(e) { alert('message:'+e.message+":url:"+url); } if(method == 'POST') { global_xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); } global_xmlhttp.onreadystatechange = function() { if(global_xmlhttp.readyState==4) { if(global_xmlhttp.status == 200) { var args = {"responseText" : global_xmlhttp.responseText, "responseXML" : global_xmlhttp.responseXML, "request_id" : request_id }; callback.call(document,args); } else { alert("There was a problem retrieving the XML data:\n" + global_xmlhttp.statusText); } } } global_xmlhttp.send(post_data);}function call_json_method(module,action,vars,variable_name,callback) { global_xmlhttp.open("GET", "index.php?entryPoint=json&module="+module+"&action="+action+"&"+vars,true); global_xmlhttp.onreadystatechange= function() { if(global_xmlhttp.readyState==4) { if(global_xmlhttp.status == 200) { // cn: bug 12274 - pass through JSON.parse() to remove security envelope json_objects[variable_name] = JSON.parse(global_xmlhttp.responseText); // cn: bug 12274 - safe from CSRF, render response as expected var respText = JSON.parseNoSecurity(global_xmlhttp.responseText); var args = {responseText:respText, responseXML:global_xmlhttp.responseXML}; callback.call(document, args); } else { alert("There was a problem retrieving the XML data:\n" + global_xmlhttp.statusText); } } } global_xmlhttp.send(null);}function insert_at_cursor(field, value) { //ie: if (document.selection) { field.focus(); sel = document.selection.createRange(); sel.text = value; } //mozilla: else if(field.selectionStart || field.selectionStart == '0') { var start_pos = field.selectionStart; var end_pos = field.selectionEnd; field.value = field.value.substring(0, start_pos) + value + field.value.substring(end_pos, field.value.length); } else { field.value += value; }}function checkParentType(type,button) { if(button == null) { return; } if(typeof(disabledModules[type]) != 'undefined') { button.disabled='disabled'; } else { button.disabled = false; }}function parseDate(input, format) { date = input.value; format = format.replace(/%/g, ''); sep = format.charAt(1); yAt = format.indexOf('Y') // 1-1-06 or 1-12-06 or 1-1-2006 or 1-12-2006 if(date.match(/^\d{1,2}[\/-]\d{1,2}[\/-]\d{2,4}$/) && yAt == 4) { if(date.match(/^\d{1}[\/-].*$/)) date = '0' + date; if(date.match(/^\d{2}[\/-]\d{1}[\/-].*$/)) date = date.substring(0,3) + '0' + date.substring(3,date.length); if(date.match(/^\d{2}[\/-]\d{2}[\/-]\d{2}$/)) date = date.substring(0,6) + '20' + date.substring(6,date.length); } // 06-11-1 or 06-1-1 else if(date.match(/^\d{2,4}[\/-]\d{1,2}[\/-]\d{1,2}$/)) { if(date.match(/^\d{2}[\/-].*$/)) date = '20' + date; if(date.match(/^\d{4}[\/-]\d{1}[\/-].*$/)) date = date.substring(0,5) + '0' + date.substring(5,date.length); if(date.match(/^\d{4}[\/-]\d{2}[\/-]\d{1}$/)) date = date.substring(0,8) + '0' + date.substring(8,date.length); } else if(date.match(/^\d{4,8}$/)) { // digits only digits = 0; if(date.match(/^\d{8}$/)) digits = 8;// match for 8 digits else if(date.match(/\d{6}/)) digits = 6;// match for 5 digits else if(date.match(/\d{4}/)) digits = 4;// match for 5 digits else if(date.match(/\d{5}/)) digits = 5;// match for 5 digits switch(yAt) { case 0: switch(digits) { case 4: date = '20' + date.substring(0,2) + sep + '0' + date.substring(2, 3) + sep + '0' + date.substring(3,4); break; case 5: date = '20' + date.substring(0,2) + sep + date.substring(2, 4) + sep + '0' + date.substring(4,5); break; case 6: date = '20' + date.substring(0,2) + sep + date.substring(2, 4) + sep + date.substring(4,6); break; case 8: date = date.substring(0,4) + sep + date.substring(4, 6) + sep + date.substring(6,8); break; } break; case 2: switch(digits) { case 4: date = '0' + date.substring(0,1) + sep + '20' + date.substring(1, 3) + sep + '0' + date.substring(3,4); break; case 5: date = date.substring(0,2) + sep + '20' + date.substring(2, 4) + sep + '0' + date.substring(4,5); break; case 6: date = date.substring(0,2) + sep + '20' + date.substring(2, 4) + sep + date.substring(4,6); break; case 8: date = date.substring(0,2) + sep + date.substring(2, 6) + sep + date.substring(6,8); break; } case 4: switch(digits) { case 4: date = '0' + date.substring(0,1) + sep + '0' + date.substring(1, 2) + sep + '20' + date.substring(2,4); break; case 5: date = '0' + date.substring(0,1) + sep + date.substring(1, 3) + sep + '20' + date.substring(3,5); break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -