Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/ninja-fo.../assets/js/lib
File: global.js
// TODO: Fix error collecting.
[0] Fix | Delete
//window.onerror = function(message, url, lineNumber) {
[1] Fix | Delete
// var data;
[2] Fix | Delete
//
[3] Fix | Delete
// data = {
[4] Fix | Delete
// 'action': 'nf_log_js_error',
[5] Fix | Delete
// 'security': nfFrontEnd.ajaxNonce,
[6] Fix | Delete
// 'message': message,
[7] Fix | Delete
// 'url': url,
[8] Fix | Delete
// 'lineNumber': lineNumber
[9] Fix | Delete
// };
[10] Fix | Delete
//
[11] Fix | Delete
// jQuery.ajax({
[12] Fix | Delete
// url: nfFrontEnd.adminAjax,
[13] Fix | Delete
// type: 'POST',
[14] Fix | Delete
// data: data,
[15] Fix | Delete
// cache: false,
[16] Fix | Delete
// success: function( data, textStatus, jqXHR ) {
[17] Fix | Delete
// try {
[18] Fix | Delete
//
[19] Fix | Delete
// } catch( e ) {
[20] Fix | Delete
// console.log( e );
[21] Fix | Delete
// console.log( 'Parse Error' );
[22] Fix | Delete
// console.log( e );
[23] Fix | Delete
// }
[24] Fix | Delete
//
[25] Fix | Delete
// },
[26] Fix | Delete
// error: function( jqXHR, textStatus, errorThrown ) {
[27] Fix | Delete
// // Handle errors here
[28] Fix | Delete
// console.log('ERRORS: ' + errorThrown);
[29] Fix | Delete
// console.log( jqXHR );
[30] Fix | Delete
//
[31] Fix | Delete
// try {
[32] Fix | Delete
//
[33] Fix | Delete
// } catch( e ) {
[34] Fix | Delete
// console.log( 'Parse Error' );
[35] Fix | Delete
// }
[36] Fix | Delete
// }
[37] Fix | Delete
// });
[38] Fix | Delete
// return false;
[39] Fix | Delete
//};
[40] Fix | Delete
[41] Fix | Delete
var nfRadio = Backbone.Radio;
[42] Fix | Delete
[43] Fix | Delete
nfRadio.channel( 'form' ).on( 'render:view', function() {
[44] Fix | Delete
jQuery( '.g-recaptcha' ).each( function() {
[45] Fix | Delete
var callback = jQuery( this ).data( 'callback' );
[46] Fix | Delete
var fieldID = jQuery( this ).data( 'fieldid' );
[47] Fix | Delete
if ( typeof window[ callback ] !== 'function' ){
[48] Fix | Delete
window[ callback ] = function( response ) {
[49] Fix | Delete
nfRadio.channel( 'recaptcha' ).request( 'update:response', response, fieldID );
[50] Fix | Delete
};
[51] Fix | Delete
}
[52] Fix | Delete
} );
[53] Fix | Delete
} );
[54] Fix | Delete
[55] Fix | Delete
var nfRecaptcha = Marionette.Object.extend( {
[56] Fix | Delete
initialize: function() {
[57] Fix | Delete
/*
[58] Fix | Delete
* If we've already rendered our form view, render our recaptcha fields.
[59] Fix | Delete
*/
[60] Fix | Delete
if ( 0 != jQuery( '.g-recaptcha' ).length ) {
[61] Fix | Delete
this.renderCaptcha();
[62] Fix | Delete
}
[63] Fix | Delete
/*
[64] Fix | Delete
* We haven't rendered our form view, so hook into the view render radio message, and then render.
[65] Fix | Delete
*/
[66] Fix | Delete
this.listenTo( nfRadio.channel( 'form' ), 'render:view', this.renderCaptcha );
[67] Fix | Delete
this.listenTo( nfRadio.channel( 'captcha' ), 'reset', this.renderCaptcha );
[68] Fix | Delete
},
[69] Fix | Delete
[70] Fix | Delete
renderCaptcha: function() {
[71] Fix | Delete
jQuery( '.g-recaptcha:empty' ).each( function() {
[72] Fix | Delete
var opts = {
[73] Fix | Delete
fieldid: jQuery( this ).data( 'fieldid' ),
[74] Fix | Delete
size: jQuery( this ).data( 'size' ),
[75] Fix | Delete
theme: jQuery( this ).data( 'theme' ),
[76] Fix | Delete
sitekey: jQuery( this ).data( 'sitekey' ),
[77] Fix | Delete
callback: jQuery( this ).data( 'callback' )
[78] Fix | Delete
};
[79] Fix | Delete
[80] Fix | Delete
var grecaptchaID = grecaptcha.render( jQuery( this )[0], opts );
[81] Fix | Delete
[82] Fix | Delete
if ( opts.size === 'invisible' ) {
[83] Fix | Delete
try {
[84] Fix | Delete
nf_reprocess_recaptcha( grecaptchaID );
[85] Fix | Delete
setInterval(nf_reprocess_recaptcha, 110000, grecaptchaID);
[86] Fix | Delete
} catch( e ){
[87] Fix | Delete
console.log( 'Notice: Error trying to execute grecaptcha.' );
[88] Fix | Delete
}
[89] Fix | Delete
}
[90] Fix | Delete
} );
[91] Fix | Delete
}
[92] Fix | Delete
} );
[93] Fix | Delete
[94] Fix | Delete
var nfRenderRecaptcha = function() {
[95] Fix | Delete
new nfRecaptcha();
[96] Fix | Delete
}
[97] Fix | Delete
[98] Fix | Delete
const nf_reprocess_recaptcha = ( grecaptchaID ) => {
[99] Fix | Delete
grecaptcha.execute( grecaptchaID );
[100] Fix | Delete
}
[101] Fix | Delete
[102] Fix | Delete
const nf_check_recaptcha_consent = () => {
[103] Fix | Delete
[104] Fix | Delete
let stored_responses = [], services = [];
[105] Fix | Delete
[106] Fix | Delete
//Cookie check
[107] Fix | Delete
if(!nf_check_data_for_recaptcha_consent()){
[108] Fix | Delete
stored_responses.push( false );
[109] Fix | Delete
services.push("missing_cookie");
[110] Fix | Delete
}
[111] Fix | Delete
[112] Fix | Delete
//Build response with services gathered and print it in global scope
[113] Fix | Delete
const response = {
[114] Fix | Delete
"consent_state": stored_responses,
[115] Fix | Delete
"services" : services
[116] Fix | Delete
};
[117] Fix | Delete
[118] Fix | Delete
nfFrontEnd.nf_consent_status_response = response;
[119] Fix | Delete
//Display filterable status to add extra consent check
[120] Fix | Delete
let nf_consent_status_extra_check = new CustomEvent('nf_consent_status_check', {detail: response});
[121] Fix | Delete
document.dispatchEvent(nf_consent_status_extra_check);
[122] Fix | Delete
[123] Fix | Delete
return nfFrontEnd.nf_consent_status_response;
[124] Fix | Delete
}
[125] Fix | Delete
//Get specific recaptcha cookie
[126] Fix | Delete
const nf_check_data_for_recaptcha_consent = () => {
[127] Fix | Delete
return nf_get_cookie_by_name("_grecaptcha") !== "";
[128] Fix | Delete
}
[129] Fix | Delete
//Get a cookie
[130] Fix | Delete
const nf_get_cookie_by_name = (cname) => {
[131] Fix | Delete
let name = cname + "=";
[132] Fix | Delete
let decodedCookie = decodeURIComponent(document.cookie);
[133] Fix | Delete
let ca = decodedCookie.split(';');
[134] Fix | Delete
for(let i = 0; i <ca.length; i++) {
[135] Fix | Delete
let c = ca[i];
[136] Fix | Delete
while (c.charAt(0) == ' ') {
[137] Fix | Delete
c = c.substring(1);
[138] Fix | Delete
}
[139] Fix | Delete
if (c.indexOf(name) == 0) {
[140] Fix | Delete
return c.substring(name.length, c.length);
[141] Fix | Delete
}
[142] Fix | Delete
}
[143] Fix | Delete
return "";
[144] Fix | Delete
}
[145] Fix | Delete
[146] Fix | Delete
const nf_reload_after_cookie_consent = ( submitFieldID, layoutView ) => {
[147] Fix | Delete
if(typeof submitFieldID !== "undefined" && typeof layoutView !== "undefined"){
[148] Fix | Delete
nfRadio.channel( 'fields' ).request("remove:error", submitFieldID, "recaptcha-v3-missing");
[149] Fix | Delete
nfRadio.channel( 'fields' ).request("remove:error", submitFieldID, "recaptcha-v3-consent");
[150] Fix | Delete
nfRadio.channel( 'form' ).trigger( 'render:view', layoutView );
[151] Fix | Delete
}
[152] Fix | Delete
}
[153] Fix | Delete
[154] Fix | Delete
const nf_add_reCaptcha_aria = () => {
[155] Fix | Delete
[156] Fix | Delete
// Callback function to execute when mutations are observed
[157] Fix | Delete
const nf_act_on_inserted_node = (mutationList, observer) => {
[158] Fix | Delete
for (const mutation of mutationList) {
[159] Fix | Delete
if (mutation.type === 'childList' && mutation.target.className === "g-recaptcha") {
[160] Fix | Delete
let nf_recaptchaTextarea = document.getElementById("g-recaptcha-response");
[161] Fix | Delete
if(typeof nf_recaptchaTextarea !== "undefined" ){
[162] Fix | Delete
nf_recaptchaTextarea.setAttribute("aria-hidden", "true");
[163] Fix | Delete
nf_recaptchaTextarea.setAttribute("aria-label", "Silent reCaptcha security check");
[164] Fix | Delete
nf_recaptchaTextarea.setAttribute("aria-readonly", "true");
[165] Fix | Delete
observer.disconnect();
[166] Fix | Delete
}
[167] Fix | Delete
}
[168] Fix | Delete
}
[169] Fix | Delete
observer.disconnect();
[170] Fix | Delete
};
[171] Fix | Delete
//Observe Forms
[172] Fix | Delete
const nf_forms_listed = document.querySelectorAll(".ninja-forms-form-wrap");
[173] Fix | Delete
if(nf_forms_listed.length > 0){
[174] Fix | Delete
let nf_recaptcha_observers = [];
[175] Fix | Delete
nf_forms_listed.forEach((nf_form) => {
[176] Fix | Delete
nf_recaptcha_observers.push({"class": new MutationObserver(nf_act_on_inserted_node), "element": nf_form});
[177] Fix | Delete
});
[178] Fix | Delete
//Add an observer for each form
[179] Fix | Delete
if( nf_recaptcha_observers.length > 0){
[180] Fix | Delete
nf_recaptcha_observers.forEach((object) => {
[181] Fix | Delete
object.class.observe( object.element,
[182] Fix | Delete
{ childList: true, subtree: true }
[183] Fix | Delete
);
[184] Fix | Delete
});
[185] Fix | Delete
}
[186] Fix | Delete
}
[187] Fix | Delete
}
[188] Fix | Delete
[189] Fix | Delete
const nf_remove_noscript_tags_as_needed = () => {
[190] Fix | Delete
const noscripts = document.getElementsByClassName('ninja-forms-noscript-message')
[191] Fix | Delete
[192] Fix | Delete
for (let i = 0; i < noscripts.length; i++) {
[193] Fix | Delete
noscripts[i].parentNode.removeChild(noscripts[i])
[194] Fix | Delete
}
[195] Fix | Delete
}
[196] Fix | Delete
[197] Fix | Delete
jQuery(document).on( 'nfFormReady', () => {
[198] Fix | Delete
nf_remove_noscript_tags_as_needed();
[199] Fix | Delete
nf_add_reCaptcha_aria();
[200] Fix | Delete
});
[201] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function