1/* 2 * Plugin: reCAPTCHA in WP comments form 3 * Path: /js 4 * File: base.js 5 * Since: 9.1.0 6 * Version: 9.1.0 7 */ 8 9// 10// Common javascript Tools 11// 12class griwpc_tools { 13 *iteratingOver ( c ) { // c: an objects collection 14 let ks = Object.getOwnPropertyNames( c ); 15 while (ks.length) { 16 let k = ks.shift(); 17 yield [k, c[k]]; 18 } 19 } 20 21 // Old themes forced output mode 22 GetElementById( n, id ) { 23 var r = null; 24 if ( n.getAttribute('id') == id ) return n; 25 for ( var i = 0; i < n.childNodes.length; i++ ) { 26 if ( n.childNodes[i].nodeType == 1 ) { 27 r = this.GetElementById( n.childNodes[i], id ); 28 if ( r != null ) break; 29 } 30 } 31 return r; 32 } 33 34 getForm () { 35 36 let ele = undefined, previous; 37 38 switch ( parseInt( griwpco.standardQueries) ) { 39 case 0: 40 case 2: 41 ele = document.getElementById ( griwpco.formID ) 42 break; 43 case 1: 44 case 3: 45 previous = document.querySelectorAll ( griwpco.formQuery ); 46 if ( previous.length ) 47 ele = previous[ griwpco.formQueryElem ]; 48 break; 49 } 50 51 return (( ele !== undefined ) ? ele : undefined); 52 53 } 54 55 getButton ( form ) { 56 57 let ele = undefined, previous; 58 59 switch ( parseInt( griwpco.standardQueries) ) { 60 case 0: 61 case 1: 62 ele = this.GetElementById (form, griwpco.buttonID ); 63 break; 64 case 2: 65 case 3: 66 previous = document.querySelectorAll ( griwpco.buttonQuery ); 67 if ( previous.length ) 68 ele = previous[ griwpco.buttonQueryElem ]; 69 break; 70 } 71 72 return (( ele !== undefined ) ? ele : undefined); 73 74 } 75 76} 77const GriwpcTools = new griwpc_tools(); 78 79// 80// javaScript pseudo jQuery.Ajax interface 81// 82class griwpc_ajax_interface { 83 84 constructor() { 85 this.versions = [ "MSXML2.XmlHttp.6.0", "MSXML2.XmlHttp.5.0", "MSXML2.XmlHttp.4.0", "MSXML2.XmlHttp.3.0", "MSXML2.XmlHttp.2.0", "Microsoft.XmlHttp" ]; 86 } 87 88 init () { 89 90 if (typeof XMLHttpRequest !== 'undefined') 91 return new XMLHttpRequest(); 92 93 let xhr; 94 95 for (var i = 0; i < this.versions.length; i++) { 96 try { 97 xhr = new ActiveXObject(versions[i]); 98 break; 99 } catch (e) { 100 } 101 } 102 return xhr; 103 104 } 105 106 send (url, callback, method, data, async = true) { 107 let x = this.init(); 108 109 if ( async === undefined ) 110 async = true; 111 112 x.open(method, url, async); 113 x.onreadystatechange = function () { 114 if ((x.readyState === 4) && (typeof callback === 'function')) { 115 // we send the whole response so, inside this callback function, you're allow to perform all .error, .success, .always, .done, etc... routines 116 callback( x ) 117 } 118 }; 119 120 if ( ( method === 'POST' ) || ( method === 'post' ) ) { 121 x.setRequestHeader( 'Content-type', 'application/x-www-form-urlencoded' ); 122 } 123 x.send( data ) 124 } 125 126 get ( url, data, callback, async) { 127 let query = []; 128 for (var key in data) { 129 query.push(encodeURIComponent(key) + '=' + encodeURIComponent(data[key])); 130 } 131 this.send( url + (query.length ? '?' + query.join('&') : ''), callback, 'GET', null, async) 132 } 133 134 post (url, data, callback, async ) { 135 var query = []; 136 for ( var key in data ) { 137 query.push( encodeURIComponent(key) + '=' + encodeURIComponent( data[key] ) ); 138 } 139 this.send( url, callback, 'POST', query.join('&'), async) 140 } 141 142} 143const GriwpcAjax = new griwpc_ajax_interface();
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.