PageSourceSearch

http://palomniki.su/assets/templates/common/js/ieButtonFix.js

js palomniki.su collected 2026-10-02 09:54:00 UTC 2,770 bytes, 94 lines download raw bytes

1//--(Begin)-->fetch value of button via outerHTML
2function getButtonTagValue(buttonObj) {
3var regexObj = /<[^<]*value="([^"'<>]*)"[^>]*>/;
4//'
5var match = regexObj.exec(buttonObj.outerHTML);
6if (match != null && match.length > 1) {
7return match[1];
8} else {
9return '';
10}
11}
12//--(End)-->fetch value of button via outerHTML
13
14function insertHiddenField(parentObj, name, value) {
15var hiddenField = document.createElement('input');
16hiddenField.type='hidden';
17hiddenField.name=name;
18hiddenField.value=value;
19parentObj.parentNode.appendChild(hiddenField);
20}
21
22function fixIeButtonTagBug(formId) {
23if (document.all || 1==1) {
24var baseObject=document;
25var elms;
26var custFunc;
27var theForms = []; // pixelchutes
28
29if (formId) baseObject=document.getElementById(formId);
30elms=baseObject.getElementsByTagName('button');
31
32if (elms) { 
33for (var x=0; x<elms.length; x++)
34if (elms[x].tagName=='BUTTON') {
35	
36	// Add first associated form to theForms array (if needed) -  pixelchutes
37	if( theForms.length == 0 ) theForms[0] = elms[x].form;
38	// Loop through defined forms and push if needed -  pixelchutes
39	for (var f=0; f<theForms.length; f++)
40		if( theForms[f].id != elms[x].form.id )
41			theForms[f+1] = elms[x].form;
42	
43	
44//this.setAttribute('value', getButtonTagValue(this)); this.setAttribute('name', '"+elms[x].name+"');
45custFunc=new Function(
46"insertHiddenField(this,'"+elms[x].name+"',getButtonTagValue(this));"+
47"return true;"
48);
49
50elms[x].onclick=custFunc;
51elms[x].name='serviceButtonValue';
52}
53}
54
55	// Loop through associated forms -  pixelchutes
56	for (var f=0; f<theForms.length; f++){
57		theForm = theForms[f];
58		
59		// Loop through theForm's elements -  pixelchutes
60		for( el=0; el<theForm.elements.length; el=el+1 )
61			// Tie keypress event handler to text fields
62            if( ( theForm.elements[el].type == 'text' || theForm.elements[el].type == 'password' ) ){
63                 theForm.elements[el].onkeypress = function(e){
64                 
65                 	// Determine the keyCode
66                 	var code;
67					if (!e) var e = window.event;
68					if (e.keyCode) code = e.keyCode;
69					else if (e.which) code = e.which;
70
71					// Handle Enter key
72					if( code == 13 ){
73						// Grab theForm's Buttons
74						theFormEls = this.form.getElementsByTagName('button');
75
76						// Fire first button's onclick
77						if (theFormEls[0].tagName=='BUTTON'){
78							theFormEls[0].onclick(); // Invoke the first button's onclick event
79						}
80						else return false; // Last resort: Prevent submit on enter
81					}
82                 };
83                
84            }		
85	} // pixelchutes
86
87}
88}
89
90if (window.addEventListener)
91window.addEventListener("load", function() {fixIeButtonTagBug();}, false)
92else if (window.attachEvent)
93window.attachEvent("onload", function() {fixIeButtonTagBug();})
94	

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.