PageSourceSearch

https://www.powerplustools.de/js/jquery/plugins/jquery.typewatch.js

js powerplustools.de collected 2026-09-25 20:43:12 UTC 2,298 bytes, 89 lines download raw bytes

1/*
2 *	TypeWatch 2.0 - Original by Denny Ferrassoli / Refactored by Charles Christolini
3 *
4 *	Examples/Docs: www.dennydotnet.com
5 *	
6 *  Copyright(c) 2007 Denny Ferrassoli - DennyDotNet.com
7 *  Coprright(c) 2008 Charles Christolini - BinaryPie.com
8 *  Modified by Lucas CHERIFI @ PrestaShop : now this plugin works with the Dean Edward's JS Packer
9 *  
10 *  Dual licensed under the MIT and GPL licenses:
11 *  http://www.opensource.org/licenses/mit-license.php
12 *  http://www.gnu.org/licenses/gpl.html
13*/
14
15(function(jQuery) {
16	jQuery.fn.typeWatch = function(o){
17		// Options
18		var options = jQuery.extend({
19			wait : 750,
20			callback : function() { },
21			highlight : true,
22			captureLength : 2
23		}, o);
24			
25		function checkElement(timer, override) {
26			var elTxt = jQuery(timer.el).val();
27		
28			// Fire if text > options.captureLength AND text != saved txt OR if override AND text > options.captureLength
29			if ((elTxt.length > options.captureLength && elTxt.toUpperCase() != timer.text) 
30			|| (override && elTxt.length > options.captureLength)) {
31				timer.text = elTxt.toUpperCase();
32				timer.cb(elTxt);
33			}
34		};
35		
36		function watchElement(elem) {			
37			// Must be text or textarea
38			if (elem.type.toUpperCase() == "TEXT" || elem.nodeName.toUpperCase() == "TEXTAREA") {
39
40				// Allocate timer element
41				var timer = {
42					timer : null, 
43					text : jQuery(elem).val().toUpperCase(),
44					cb : options.callback, 
45					el : elem, 
46					wait : options.wait
47				};
48
49				// Set focus action (highlight)
50				if (options.highlight) {
51					jQuery(elem).focus(
52						function() {
53							this.select();
54						});
55				}
56
57				// Key watcher / clear and reset the timer
58				var startWatch = function(evt) {
59					var timerWait = timer.wait;
60					var overrideBool = false;
61					
62					if (evt.keyCode == 13 && this.type.toUpperCase() == "TEXT") {
63						timerWait = 1;
64						overrideBool = true;
65					}
66					
67					var timerCallbackFx = function()
68					{
69						checkElement(timer, overrideBool);
70					}
71					
72					// Clear timer					
73					clearTimeout(timer.timer);
74					timer.timer = setTimeout(timerCallbackFx, timerWait);				
75										
76				};
77				
78				jQuery(elem).keydown(startWatch);
79			}
80		};
81		
82		// Watch Each Element
83		return this.each(function(index){
84			watchElement(this);
85		});
86		
87	};
88
89})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.