actb.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. function addEvent(obj,event_name,func_name){
  2. if (obj.attachEvent){
  3. obj.attachEvent("on"+event_name, func_name);
  4. }else if(obj.addEventListener){
  5. obj.addEventListener(event_name,func_name,true);
  6. }else{
  7. obj["on"+event_name] = func_name;
  8. }
  9. }
  10. function removeEvent(obj,event_name,func_name){
  11. if (obj.detachEvent){
  12. obj.detachEvent("on"+event_name,func_name);
  13. }else if(obj.removeEventListener){
  14. obj.removeEventListener(event_name,func_name,true);
  15. }else{
  16. obj["on"+event_name] = null;
  17. }
  18. }
  19. function stopEvent(evt){
  20. evt || window.event;
  21. if (evt.stopPropagation){
  22. evt.stopPropagation();
  23. evt.preventDefault();
  24. }else if(typeof evt.cancelBubble != "undefined"){
  25. evt.cancelBubble = true;
  26. evt.returnValue = false;
  27. }
  28. return false;
  29. }
  30. function getElement(evt){
  31. if (window.event){
  32. return window.event.srcElement;
  33. }else{
  34. return evt.currentTarget;
  35. }
  36. }
  37. function getTargetElement(evt){
  38. if (window.event){
  39. return window.event.srcElement;
  40. }else{
  41. return evt.target;
  42. }
  43. }
  44. function stopSelect(obj){
  45. if (typeof obj.onselectstart != 'undefined'){
  46. addEvent(obj,"selectstart",function(){ return false;});
  47. }
  48. }
  49. function getCaretEnd(obj){
  50. if(typeof obj.selectionEnd != "undefined"){
  51. return obj.selectionEnd;
  52. }else if(document.selection&&document.selection.createRange){
  53. var M=document.selection.createRange();
  54. try{
  55. var Lp = M.duplicate();
  56. Lp.moveToElementText(obj);
  57. }catch(e){
  58. var Lp=obj.createTextRange();
  59. }
  60. Lp.setEndPoint("EndToEnd",M);
  61. var rb=Lp.text.length;
  62. if(rb>obj.value.length){
  63. return -1;
  64. }
  65. return rb;
  66. }
  67. }
  68. function getCaretStart(obj){
  69. if(typeof obj.selectionStart != "undefined"){
  70. return obj.selectionStart;
  71. }else if(document.selection&&document.selection.createRange){
  72. var M=document.selection.createRange();
  73. try{
  74. var Lp = M.duplicate();
  75. Lp.moveToElementText(obj);
  76. }catch(e){
  77. var Lp=obj.createTextRange();
  78. }
  79. Lp.setEndPoint("EndToStart",M);
  80. var rb=Lp.text.length;
  81. if(rb>obj.value.length){
  82. return -1;
  83. }
  84. return rb;
  85. }
  86. }
  87. function setCaret(obj,l){
  88. obj.focus();
  89. if (obj.setSelectionRange){
  90. obj.setSelectionRange(l,l);
  91. }else if(obj.createTextRange){
  92. m = obj.createTextRange();
  93. m.moveStart('character',l);
  94. m.collapse();
  95. m.select();
  96. }
  97. }
  98. function setSelection(obj,s,e){
  99. obj.focus();
  100. if (obj.setSelectionRange){
  101. obj.setSelectionRange(s,e);
  102. }else if(obj.createTextRange){
  103. m = obj.createTextRange();
  104. m.moveStart('character',s);
  105. m.moveEnd('character',e);
  106. m.select();
  107. }
  108. }
  109. String.prototype.addslashes = function(){
  110. return this.replace(/(["\\\.\|\[\]\^\*\+\?\$\(\)])/g, '\\$1');
  111. }
  112. String.prototype.trim = function () {
  113. return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
  114. };
  115. function curTop(obj){
  116. toreturn = 0;
  117. while(obj){
  118. toreturn += obj.offsetTop;
  119. obj = obj.offsetParent;
  120. }
  121. return toreturn;
  122. }
  123. function curLeft(obj){
  124. toreturn = 0;
  125. while(obj){
  126. toreturn += obj.offsetLeft;
  127. obj = obj.offsetParent;
  128. }
  129. return toreturn;
  130. }
  131. function isNumber(a) {
  132. return typeof a == 'number' && isFinite(a);
  133. }
  134. function replaceHTML(obj,text){
  135. while(el = obj.childNodes[0]){
  136. obj.removeChild(el);
  137. };
  138. obj.appendChild(document.createTextNode(text));
  139. }
  140. function actb(obj,ca){
  141. /* ---- Public Variables ---- */
  142. this.actb_timeOut = -1; // Autocomplete Timeout in ms (-1: autocomplete never time out)
  143. this.actb_lim = 4; // Number of elements autocomplete can show (-1: no limit)
  144. this.actb_firstText = false; // should the auto complete be limited to the beginning of keyword?
  145. this.actb_mouse = true; // Enable Mouse Support
  146. this.actb_delimiter = new Array(';',','); // Delimiter for multiple autocomplete. Set it to empty array for single autocomplete
  147. this.actb_startcheck = 1; // Show widget only after this number of characters is typed in.
  148. /* ---- Public Variables ---- */
  149. /* --- Styles --- */
  150. this.actb_bgColor = '#888888';
  151. this.actb_textColor = '#FFFFFF';
  152. this.actb_hColor = '#000000';
  153. this.actb_fFamily = 'Verdana';
  154. this.actb_fSize = '11px';
  155. this.actb_hStyle = 'text-decoration:underline;font-weight="bold"';
  156. /* --- Styles --- */
  157. /* ---- Private Variables ---- */
  158. var actb_delimwords = new Array();
  159. var actb_cdelimword = 0;
  160. var actb_delimchar = new Array();
  161. var actb_display = false;
  162. var actb_pos = 0;
  163. var actb_total = 0;
  164. var actb_curr = null;
  165. var actb_rangeu = 0;
  166. var actb_ranged = 0;
  167. var actb_bool = new Array();
  168. var actb_pre = 0;
  169. var actb_toid;
  170. var actb_tomake = false;
  171. var actb_getpre = "";
  172. var actb_mouse_on_list = 1;
  173. var actb_kwcount = 0;
  174. var actb_caretmove = false;
  175. this.actb_keywords = new Array();
  176. /* ---- Private Variables---- */
  177. this.actb_keywords = ca;
  178. var actb_self = this;
  179. actb_curr = obj;
  180. addEvent(actb_curr,"focus",actb_setup);
  181. function actb_setup(){
  182. addEvent(document,"keydown",actb_checkkey);
  183. addEvent(actb_curr,"blur",actb_clear);
  184. addEvent(document,"keypress",actb_keypress);
  185. }
  186. function actb_clear(evt){
  187. if (!evt) evt = event;
  188. removeEvent(document,"keydown",actb_checkkey);
  189. removeEvent(actb_curr,"blur",actb_clear);
  190. removeEvent(document,"keypress",actb_keypress);
  191. actb_removedisp();
  192. }
  193. function actb_parse(n){
  194. if (actb_self.actb_delimiter.length > 0){
  195. var t = actb_delimwords[actb_cdelimword].trim().addslashes();
  196. var plen = actb_delimwords[actb_cdelimword].trim().length;
  197. }else{
  198. var t = actb_curr.value.addslashes();
  199. var plen = actb_curr.value.length;
  200. }
  201. var tobuild = '';
  202. var i;
  203. if (actb_self.actb_firstText){
  204. var re = new RegExp("^" + t, "i");
  205. }else{
  206. var re = new RegExp(t, "i");
  207. }
  208. var p = n.search(re);
  209. for (i=0;i<p;i++){
  210. tobuild += n.substr(i,1);
  211. }
  212. tobuild += "<font style='"+(actb_self.actb_hStyle)+"'>"
  213. for (i=p;i<plen+p;i++){
  214. tobuild += n.substr(i,1);
  215. }
  216. tobuild += "</font>";
  217. for (i=plen+p;i<n.length;i++){
  218. tobuild += n.substr(i,1);
  219. }
  220. return tobuild;
  221. }
  222. function actb_generate(){
  223. if (document.getElementById('tat_table')){ actb_display = false;document.body.removeChild(document.getElementById('tat_table')); }
  224. if (actb_kwcount == 0){
  225. actb_display = false;
  226. return;
  227. }
  228. a = document.createElement('table');
  229. a.cellSpacing='1px';
  230. a.cellPadding='2px';
  231. a.style.position='absolute';
  232. a.style.top = eval(curTop(actb_curr) + actb_curr.offsetHeight) + "px";
  233. a.style.left = curLeft(actb_curr) + "px";
  234. a.style.backgroundColor=actb_self.actb_bgColor;
  235. a.id = 'tat_table';
  236. document.body.appendChild(a);
  237. var i;
  238. var first = true;
  239. var j = 1;
  240. if (actb_self.actb_mouse){
  241. a.onmouseout = actb_table_unfocus;
  242. a.onmouseover = actb_table_focus;
  243. }
  244. var counter = 0;
  245. for (i=0;i<actb_self.actb_keywords.length;i++){
  246. if (actb_bool[i]){
  247. counter++;
  248. r = a.insertRow(-1);
  249. if (first && !actb_tomake){
  250. r.style.backgroundColor = actb_self.actb_hColor;
  251. first = false;
  252. actb_pos = counter;
  253. }else if(actb_pre == i){
  254. r.style.backgroundColor = actb_self.actb_hColor;
  255. first = false;
  256. actb_pos = counter;
  257. }else{
  258. r.style.backgroundColor = actb_self.actb_bgColor;
  259. }
  260. r.id = 'tat_tr'+(j);
  261. c = r.insertCell(-1);
  262. c.style.color = actb_self.actb_textColor;
  263. c.style.fontFamily = actb_self.actb_fFamily;
  264. c.style.fontSize = actb_self.actb_fSize;
  265. c.innerHTML = actb_parse(actb_self.actb_keywords[i]);
  266. c.id = 'tat_td'+(j);
  267. c.setAttribute('pos',j);
  268. if (actb_self.actb_mouse){
  269. c.style.cursor = 'pointer';
  270. c.onclick=actb_mouseclick;
  271. c.onmouseover = actb_table_highlight;
  272. }
  273. j++;
  274. }
  275. if (j - 1 == actb_self.actb_lim && j < actb_total){
  276. r = a.insertRow(-1);
  277. r.style.backgroundColor = actb_self.actb_bgColor;
  278. c = r.insertCell(-1);
  279. c.style.color = actb_self.actb_textColor;
  280. c.style.fontFamily = 'arial narrow';
  281. c.style.fontSize = actb_self.actb_fSize;
  282. c.align='center';
  283. replaceHTML(c,'\\/');
  284. if (actb_self.actb_mouse){
  285. c.style.cursor = 'pointer';
  286. c.onclick = actb_mouse_down;
  287. }
  288. break;
  289. }
  290. }
  291. actb_rangeu = 1;
  292. actb_ranged = j-1;
  293. actb_display = true;
  294. if (actb_pos <= 0) actb_pos = 1;
  295. }
  296. function actb_remake(){
  297. document.body.removeChild(document.getElementById('tat_table'));
  298. a = document.createElement('table');
  299. a.cellSpacing='1px';
  300. a.cellPadding='2px';
  301. a.style.position='absolute';
  302. a.style.top = eval(curTop(actb_curr) + actb_curr.offsetHeight) + "px";
  303. a.style.left = curLeft(actb_curr) + "px";
  304. a.style.backgroundColor=actb_self.actb_bgColor;
  305. a.id = 'tat_table';
  306. if (actb_self.actb_mouse){
  307. a.onmouseout= actb_table_unfocus;
  308. a.onmouseover=actb_table_focus;
  309. }
  310. document.body.appendChild(a);
  311. var i;
  312. var first = true;
  313. var j = 1;
  314. if (actb_rangeu > 1){
  315. r = a.insertRow(-1);
  316. r.style.backgroundColor = actb_self.actb_bgColor;
  317. c = r.insertCell(-1);
  318. c.style.color = actb_self.actb_textColor;
  319. c.style.fontFamily = 'arial narrow';
  320. c.style.fontSize = actb_self.actb_fSize;
  321. c.align='center';
  322. replaceHTML(c,'/\\');
  323. if (actb_self.actb_mouse){
  324. c.style.cursor = 'pointer';
  325. c.onclick = actb_mouse_up;
  326. }
  327. }
  328. for (i=0;i<actb_self.actb_keywords.length;i++){
  329. if (actb_bool[i]){
  330. if (j >= actb_rangeu && j <= actb_ranged){
  331. r = a.insertRow(-1);
  332. r.style.backgroundColor = actb_self.actb_bgColor;
  333. r.id = 'tat_tr'+(j);
  334. c = r.insertCell(-1);
  335. c.style.color = actb_self.actb_textColor;
  336. c.style.fontFamily = actb_self.actb_fFamily;
  337. c.style.fontSize = actb_self.actb_fSize;
  338. c.innerHTML = actb_parse(actb_self.actb_keywords[i]);
  339. c.id = 'tat_td'+(j);
  340. c.setAttribute('pos',j);
  341. if (actb_self.actb_mouse){
  342. c.style.cursor = 'pointer';
  343. c.onclick=actb_mouseclick;
  344. c.onmouseover = actb_table_highlight;
  345. }
  346. j++;
  347. }else{
  348. j++;
  349. }
  350. }
  351. if (j > actb_ranged) break;
  352. }
  353. if (j-1 < actb_total){
  354. r = a.insertRow(-1);
  355. r.style.backgroundColor = actb_self.actb_bgColor;
  356. c = r.insertCell(-1);
  357. c.style.color = actb_self.actb_textColor;
  358. c.style.fontFamily = 'arial narrow';
  359. c.style.fontSize = actb_self.actb_fSize;
  360. c.align='center';
  361. replaceHTML(c,'\\/');
  362. if (actb_self.actb_mouse){
  363. c.style.cursor = 'pointer';
  364. c.onclick = actb_mouse_down;
  365. }
  366. }
  367. }
  368. function actb_goup(){
  369. if (!actb_display) return;
  370. if (actb_pos == 1) return;
  371. document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_bgColor;
  372. actb_pos--;
  373. if (actb_pos < actb_rangeu) actb_moveup();
  374. document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_hColor;
  375. if (actb_toid) clearTimeout(actb_toid);
  376. if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list=0;actb_removedisp();},actb_self.actb_timeOut);
  377. }
  378. function actb_godown(){
  379. if (!actb_display) return;
  380. if (actb_pos == actb_total) return;
  381. document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_bgColor;
  382. actb_pos++;
  383. if (actb_pos > actb_ranged) actb_movedown();
  384. document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_hColor;
  385. if (actb_toid) clearTimeout(actb_toid);
  386. if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list=0;actb_removedisp();},actb_self.actb_timeOut);
  387. }
  388. function actb_movedown(){
  389. actb_rangeu++;
  390. actb_ranged++;
  391. actb_remake();
  392. }
  393. function actb_moveup(){
  394. actb_rangeu--;
  395. actb_ranged--;
  396. actb_remake();
  397. }
  398. /* Mouse */
  399. function actb_mouse_down(){
  400. document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_bgColor;
  401. actb_pos++;
  402. actb_movedown();
  403. document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_hColor;
  404. actb_curr.focus();
  405. actb_mouse_on_list = 0;
  406. if (actb_toid) clearTimeout(actb_toid);
  407. if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list=0;actb_removedisp();},actb_self.actb_timeOut);
  408. }
  409. function actb_mouse_up(evt){
  410. if (!evt) evt = event;
  411. if (evt.stopPropagation){
  412. evt.stopPropagation();
  413. }else{
  414. evt.cancelBubble = true;
  415. }
  416. document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_bgColor;
  417. actb_pos--;
  418. actb_moveup();
  419. document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_hColor;
  420. actb_curr.focus();
  421. actb_mouse_on_list = 0;
  422. if (actb_toid) clearTimeout(actb_toid);
  423. if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list=0;actb_removedisp();},actb_self.actb_timeOut);
  424. }
  425. function actb_mouseclick(evt){
  426. if (!evt) evt = event;
  427. if (!actb_display) return;
  428. actb_mouse_on_list = 0;
  429. actb_pos = this.getAttribute('pos');
  430. actb_penter();
  431. }
  432. function actb_table_focus(){
  433. actb_mouse_on_list = 1;
  434. }
  435. function actb_table_unfocus(){
  436. actb_mouse_on_list = 0;
  437. if (actb_toid) clearTimeout(actb_toid);
  438. if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list = 0;actb_removedisp();},actb_self.actb_timeOut);
  439. }
  440. function actb_table_highlight(){
  441. actb_mouse_on_list = 1;
  442. document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_bgColor;
  443. actb_pos = this.getAttribute('pos');
  444. while (actb_pos < actb_rangeu) actb_moveup();
  445. while (actb_pos > actb_ranged) actb_movedown();
  446. document.getElementById('tat_tr'+actb_pos).style.backgroundColor = actb_self.actb_hColor;
  447. if (actb_toid) clearTimeout(actb_toid);
  448. if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list = 0;actb_removedisp();},actb_self.actb_timeOut);
  449. }
  450. /* ---- */
  451. function actb_insertword(a){
  452. if (actb_self.actb_delimiter.length > 0){
  453. str = '';
  454. l=0;
  455. for (i=0;i<actb_delimwords.length;i++){
  456. if (actb_cdelimword == i){
  457. prespace = postspace = '';
  458. gotbreak = false;
  459. for (j=0;j<actb_delimwords[i].length;++j){
  460. if (actb_delimwords[i].charAt(j) != ' '){
  461. gotbreak = true;
  462. break;
  463. }
  464. prespace += ' ';
  465. }
  466. for (j=actb_delimwords[i].length-1;j>=0;--j){
  467. if (actb_delimwords[i].charAt(j) != ' ') break;
  468. postspace += ' ';
  469. }
  470. str += prespace;
  471. str += a;
  472. l = str.length;
  473. if (gotbreak) str += postspace;
  474. }else{
  475. str += actb_delimwords[i];
  476. }
  477. if (i != actb_delimwords.length - 1){
  478. str += actb_delimchar[i];
  479. }
  480. }
  481. actb_curr.value = str;
  482. setCaret(actb_curr,l);
  483. }else{
  484. actb_curr.value = a;
  485. }
  486. actb_mouse_on_list = 0;
  487. actb_removedisp();
  488. }
  489. function actb_penter(){
  490. if (!actb_display) return;
  491. actb_display = false;
  492. var word = '';
  493. var c = 0;
  494. for (var i=0;i<=actb_self.actb_keywords.length;i++){
  495. if (actb_bool[i]) c++;
  496. if (c == actb_pos){
  497. word = actb_self.actb_keywords[i];
  498. break;
  499. }
  500. }
  501. actb_insertword(word);
  502. l = getCaretStart(actb_curr);
  503. }
  504. function actb_removedisp(){
  505. if (actb_mouse_on_list==0){
  506. actb_display = 0;
  507. if (document.getElementById('tat_table')){ document.body.removeChild(document.getElementById('tat_table')); }
  508. if (actb_toid) clearTimeout(actb_toid);
  509. }
  510. }
  511. function actb_keypress(e){
  512. if (actb_caretmove) stopEvent(e);
  513. return !actb_caretmove;
  514. }
  515. function actb_checkkey(evt){
  516. if (!evt) evt = event;
  517. a = evt.keyCode;
  518. caret_pos_start = getCaretStart(actb_curr);
  519. actb_caretmove = 0;
  520. switch (a){
  521. case 38:
  522. actb_goup();
  523. actb_caretmove = 1;
  524. return false;
  525. break;
  526. case 40:
  527. actb_godown();
  528. actb_caretmove = 1;
  529. return false;
  530. break;
  531. case 13: case 9:
  532. if (actb_display){
  533. actb_caretmove = 1;
  534. actb_penter();
  535. return false;
  536. }else{
  537. return true;
  538. }
  539. break;
  540. default:
  541. setTimeout(function(){actb_tocomplete(a)},50);
  542. break;
  543. }
  544. }
  545. function actb_tocomplete(kc){
  546. if (kc == 38 || kc == 40 || kc == 13) return;
  547. var i;
  548. if (actb_display){
  549. var word = 0;
  550. var c = 0;
  551. for (var i=0;i<=actb_self.actb_keywords.length;i++){
  552. if (actb_bool[i]) c++;
  553. if (c == actb_pos){
  554. word = i;
  555. break;
  556. }
  557. }
  558. actb_pre = word;
  559. }else{ actb_pre = -1};
  560. if (actb_curr.value == ''){
  561. actb_mouse_on_list = 0;
  562. actb_removedisp();
  563. return;
  564. }
  565. if (actb_self.actb_delimiter.length > 0){
  566. caret_pos_start = getCaretStart(actb_curr);
  567. caret_pos_end = getCaretEnd(actb_curr);
  568. delim_split = '';
  569. for (i=0;i<actb_self.actb_delimiter.length;i++){
  570. delim_split += actb_self.actb_delimiter[i];
  571. }
  572. delim_split = delim_split.addslashes();
  573. delim_split_rx = new RegExp("(["+delim_split+"])");
  574. c = 0;
  575. actb_delimwords = new Array();
  576. actb_delimwords[0] = '';
  577. for (i=0,j=actb_curr.value.length;i<actb_curr.value.length;i++,j--){
  578. if (actb_curr.value.substr(i,j).search(delim_split_rx) == 0){
  579. ma = actb_curr.value.substr(i,j).match(delim_split_rx);
  580. actb_delimchar[c] = ma[1];
  581. c++;
  582. actb_delimwords[c] = '';
  583. }else{
  584. actb_delimwords[c] += actb_curr.value.charAt(i);
  585. }
  586. }
  587. var l = 0;
  588. actb_cdelimword = -1;
  589. for (i=0;i<actb_delimwords.length;i++){
  590. if (caret_pos_end >= l && caret_pos_end <= l + actb_delimwords[i].length){
  591. actb_cdelimword = i;
  592. }
  593. l+=actb_delimwords[i].length + 1;
  594. }
  595. var ot = actb_delimwords[actb_cdelimword].trim();
  596. var t = actb_delimwords[actb_cdelimword].addslashes().trim();
  597. }else{
  598. var ot = actb_curr.value;
  599. var t = actb_curr.value.addslashes();
  600. }
  601. if (ot.length == 0){
  602. actb_mouse_on_list = 0;
  603. actb_removedisp();
  604. }
  605. if (ot.length < actb_self.actb_startcheck) return this;
  606. if (actb_self.actb_firstText){
  607. var re = new RegExp("^" + t, "i");
  608. }else{
  609. var re = new RegExp(t, "i");
  610. }
  611. actb_total = 0;
  612. actb_tomake = false;
  613. actb_kwcount = 0;
  614. for (i=0;i<actb_self.actb_keywords.length;i++){
  615. actb_bool[i] = false;
  616. if (re.test(actb_self.actb_keywords[i])){
  617. actb_total++;
  618. actb_bool[i] = true;
  619. actb_kwcount++;
  620. if (actb_pre == i) actb_tomake = true;
  621. }
  622. }
  623. if (actb_toid) clearTimeout(actb_toid);
  624. if (actb_self.actb_timeOut > 0) actb_toid = setTimeout(function(){actb_mouse_on_list = 0;actb_removedisp();},actb_self.actb_timeOut);
  625. actb_generate();
  626. }
  627. return this;
  628. }