PageSourceSearch

https://regionalsprache.de/Scripts/jQuery/jquery.typewatch.js

js regionalsprache.de collected 2026-09-25 04:27:22 UTC 2,312 bytes, 85 lines download raw bytes

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