⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sugnew.js

📁 很好的传感器学习资料
💻 JS
📖 第 1 页 / 共 2 页
字号:
var autos = new Array();// array of autoformsvar tid = 0; // timer idvar httpBaseURL;var startswithServlet;var resultCache=new Object(); // This is a cache of results from the server...var keycode=0; //holds the last keycode pressedvar req = null;var enter = false;var textkeyword="";var currfid;function AutoForm(fid,aid,inputfield,pagetype){this.id = fid;this.autoid = aid;var thisform = document.getElementById(fid);this.inputfield = inputfield;this.pagetype=pagetype;this.ftype="2";this.rows = 0;this.rowDivList = null;this.highlightedSuggestionIndex = -1;this.highlightedSuggestionDiv= null;this.topicArray = new Array(10); this.countArray = new Array(10);this.cursorUpDownPressed = false;this.currentInputFieldValue=""; this.partialquery="";this.currTopic = ""; this.currCount = ""; this.keycode = 0;if (this.inputfield.addEventListener)this.inputfield.addEventListener("keypress", KeyPress, true);thisform.onsubmit= returnFalse;if(pagetype=="1"){document.getElementById(aid).style.margin = (!window.XMLHttpRequest)?"-5px 0px 0px 0px":"-5px 0px 0px 0px";}else if(pagetype=="2") {document.getElementById(aid).style.margin = (!window.XMLHttpRequest)?"-200px 0px 0px 80px":"-200px 0px 0px 80px";document.getElementById(aid).style.width = "289px";}}function returnFalse() {return false;}function returnTrue(){return true;}function InitForm(fid,aid,inputfield,pagetype){var autoform = new AutoForm(fid,aid,document.getElementById(inputfield),pagetype);autos[fid] = autoform;}function BodyLoad(HttpBaseURL, StartsWithServlet,s, fid,setFocus){	return 0;httpBaseURL = HttpBaseURL;startswithServlet = StartsWithServlet;currfid=fid;    var queryfield = document.getElementById(s);    //Don't set focus for sitePages - check the value of boolean setFocus    if ((queryfield && queryfield.value=="") && ((setFocus != null && setFocus == true) || setFocus == null)){           queryfield.focus(); // focus on first inputfield if available and empty    }    textkeyword=queryfield.value;    setTimeout("everytenms()",10);}function KeyDown(fid,evt){    var ctrl = 0;    if(!evt && window.event){        evt=window.event;    }        if(document.layers)        ctrl = (evt.modifiers & Event.CONTROL_MASK) > 0;    else        ctrl = evt.ctrlKey;            if (tid)return;keycode = evt.keyCode;    if (ctrl)       return true;    if (isCtrlKey(keycode))        return true;return UpDown(fid,keycode);}function KeyPress(event){if (event.which == 0 && !isShowKey(keycode)) {if (event.preventDefault)event.preventDefault();return false;}}UpDown = function(fid,keycode){var inputfield = autos[fid].inputfield;var inputfieldValue = inputfield.value;autos[fid].keycode = keycode;if(handleCursorUpDownEnter(keycode,fid,inputfieldValue) || isShowKey(keycode))return true;elsereturn false;}// returns false if cursor up / cursor down or enter pressed...function handleCursorUpDownEnter(eventCode,fid,inputfieldValue){var highlightedSuggestionIndex = autos[fid].highlightedSuggestionIndex;var autodiv = document.getElementById(autos[fid].autoid);    if (eventCode == 33) // page up{if (autodiv.style.visibility=="visible"){setStyleForElement(autos[fid].highlightedSuggestionDiv,"1");autos[fid].highlightedSuggestionIndex = 0;highlightNewValue(fid,0);}return false;}else if (eventCode == 34) // page down{if (autodiv.style.visibility=="visible"){setStyleForElement(autos[fid].highlightedSuggestionDiv,"1");autos[fid].highlightedSuggestionIndex = autos[fid].rows-1;highlightNewValue(fid,autos[fid].rows-1);}return false;}else if(eventCode==40){if (autodiv.style.visibility=="visible"){highlightNewValue(fid,highlightedSuggestionIndex+1);return false;}}else if(eventCode==38){if (autodiv.style.visibility=="visible"){highlightNewValue(fid,highlightedSuggestionIndex-1);return false;}}else if(eventCode==13||eventCode==3){if (eventCode==13) {if(autos[fid].currTopic!=""){autos[fid].inputfield.value=autos[fid].currTopic;textkeyword=autos[fid].currTopic;}document.getElementById(autos[fid].autoid).style.visibility="hidden";return submitForm(fid);}return false;}if (keycode != 0)ForEachKeyPressed(inputfieldValue,fid);return true;}// Called when cursor up/down pressed... selects new entry in autodiv...function highlightNewValue(fid,C){autos[fid].currentInputFieldValue= autos[fid].partialquery;//autos[fid].inputfield.value=autos[fid].partialquery;if(!autos[fid].rowDivList){return;}ShowDiv(fid);if(C>=autos[fid].rows){        if (autos[fid].dir=="up")        {            C=autos[fid].rows;        }        else        {            C=autos[fid].rows-1            autos[fid].highlightedSuggestionDiv=autos[fid].rowDivList.item(C);        }    }if(C<0){        if (autos[fid].dir=="up")        {            C=0;            autos[fid].highlightedSuggestionDiv=autos[fid].rowDivList.item(C);        }        else        {            C=-1;            autos[fid].highlightedSuggestionIndex=-1            autos[fid].highlightedSuggestionDiv= null;            setStyleForElement(autos[fid].rowDivList.item(0),"1");        }    } if(autos[fid].highlightedSuggestionIndex!=-1&&C!=autos[fid].highlightedSuggestionIndex) {setStyleForElement(autos[fid].highlightedSuggestionDiv,"1");autos[fid].highlightedSuggestionIndex=-1}if (C>=0){autos[fid].highlightedSuggestionIndex=C;autos[fid].highlightedSuggestionDiv=autos[fid].rowDivList.item(C);setStyleForElement(autos[fid].highlightedSuggestionDiv,"0");currentInputFieldValue=autos[fid].partialquery;var q = valueOfAutodiv(autos[fid].highlightedSuggestionDiv);autos[fid].currTopic = autos[fid].topicArray[C];autos[fid].currCount = autos[fid].countArray[C];}else{autos[fid].currTopic ="";autos[fid].currCount ="";}}// This function gets called for every keypress I make...function ForEachKeyPressed(partialquery,fid){var localInputField = autos[fid].inputfield;var autoid = autos[fid].autoid;var autodiv = document.getElementById(autoid);var highlightedSuggestionIndex= autos[fid].highlightedSuggestionIndex;    // This becomes the rows in our suggestion list...var J=autodiv.getElementsByTagName("LI");// # of rows in list...var rows = J.length;autos[fid].rows = rows;autos[fid].rowDivList=J;autos[fid].partialquery=partialquery;autos[fid].currTopic = ""; //resetautos[fid].currCount = ""; //resetvar s= localInputField.value;if(s=="" || rows==0 || keycode==27 || s.search(/\S/)==-1 || (autodiv.style.visibility=="hidden" && ( keycode==35 || keycode==36))) //escHideDiv(fid);for(var f=0; f<rows; f++){setStyleForElement(J.item(f),"1");}var highlightedSuggestionDiv = autos[fid].highlightedSuggestionDiv;var noncharkey = false;switch(autos[fid].keycode){case 8: // back spacecase 33: //page upcase 34: // page downcase 35: // endcase 36: // homecase 37: // left arrowcase 39: // right arrowcase 45: //????case 46: // deletenoncharkey=true;break;default:// regular keypress ...break}if(!noncharkey && highlightedSuggestionDiv){setStyleForElement(highlightedSuggestionDiv,"0");var z;z=valueOfAutodiv(highlightedSuggestionDiv);if(z!=localInputField.value){if(localInputField.value!=partialquery){return;}}}else{highlightedSuggestionIndex=-1;    }}// Return null if i undefined...// otherwise return value of span 3...function valueOfAutodiv(i){if(!i){return null;}return findSpanValueForClass(i,"5")}// Find span value with className = dc...function findSpanValueForClass(i,dc){var ga=i.getElementsByTagName("span");if(ga){for(var f=0; f<ga.length; ++f){if(ga[f].className==dc){var value=ga[f].innerHTML;if(value=="&nbsp;") {return"";} else{var z=stripCRFromString(value);return z}}}}else{return""}}// strip CR from string...function stripCRFromString(va){for(var f=0,oa="",zb="\n\r"; f<va.length; f++){if (zb.indexOf(va.charAt(f))==-1)oa+=va.charAt(f);elseoa+=" ";}return oa}function SendQuery(fid){tid =0;var autoid = autos[fid].autoid;var s = autos[fid].inputfield;var query = s.value;if(query.length!=0 && query.search(/\S/)!=-1){var result=resultCache[autos[fid].ftype+query];if(result){// Found in our cache...ShowDiv(autoid);startswithResult(query,result[0],result[1],fid);}else{var url= httpBaseURL+startswithServlet+"?w=" + query +"&c="+document.getElementById("scate").value;//alert(url);if (req)req.abort();req = (!window.XMLHttpRequest)? (window.ActiveXObject ? (new ActiveXObject("Microsoft.XMLHTTP")):""):(new XMLHttpRequest());req.open("GET", url, true);req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');req.onreadystatechange = new Function("Process('" + fid + "')");req.send(null);}}elseHideDiv(fid);}function Process(fid){if (req.readyState == 4){try // ff throws an exception sometimes{if (req.status == 200){if(req.responseText=="")HideDiv(fid);else{//alert(req.responseText);eval('startswithResult(' + req.responseText + '"' + fid + '");');}}}catch(e){}}}function ShowDiv(fid){if (autos[fid]){document.getElementById(autos[fid].autoid).style.visibility="visible";showHideSelects(fid,false);}}function HideDiv(fid)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -