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
File: admin-import-export.js
jQuery( document ).ready( function( $ ) {
[0] Fix | Delete
/**
[1] Fix | Delete
* Stores the selected file details for form imports.
[2] Fix | Delete
*
[3] Fix | Delete
* name is the filename from the user's computer, including extension.
[4] Fix | Delete
* content is the base64 encoded contents as a result of using the HTML5 FileReader API.
[5] Fix | Delete
* @type {Object}
[6] Fix | Delete
*/
[7] Fix | Delete
var importFormFile = {
[8] Fix | Delete
name: '',
[9] Fix | Delete
content: '',
[10] Fix | Delete
extraChecksOff: false
[11] Fix | Delete
};
[12] Fix | Delete
[13] Fix | Delete
/**
[14] Fix | Delete
* Listen for clicks on our "import" button.
[15] Fix | Delete
* It sets data for our batch processor and then instantiates a batch process.
[16] Fix | Delete
*
[17] Fix | Delete
* @since 3.4.0
[18] Fix | Delete
* @param object e Click Event
[19] Fix | Delete
* @return void
[20] Fix | Delete
*/
[21] Fix | Delete
$( document ).on( 'click', '#nf-import-form-submit', function( e ) {
[22] Fix | Delete
// Make sure that our file field isn't empty.
[23] Fix | Delete
if ( '' == importFormFile.name ) return false;
[24] Fix | Delete
//Get status of trusted source checkbox
[25] Fix | Delete
importFormFile.extraChecksOff = document.querySelector('#nf_import_form_turn_off_extra_checks').checked;
[26] Fix | Delete
[27] Fix | Delete
// Settings object for our batch processor
[28] Fix | Delete
var settings = {
[29] Fix | Delete
batch_type: 'import_form',
[30] Fix | Delete
extraData: importFormFile,
[31] Fix | Delete
loadingText: 'Importing...',
[32] Fix | Delete
onCompleteCallback: function( response ) {
[33] Fix | Delete
// If we don't get back a form ID, then bail.
[34] Fix | Delete
if ( 'undefined' == typeof response.form_id ) return false;
[35] Fix | Delete
[36] Fix | Delete
jQuery( '#nf-import-file' ).val('');
[37] Fix | Delete
jQuery( '#nf-import-url' ).attr( 'href', nfAdmin.builderURL + response.form_id );
[38] Fix | Delete
var blockingErrors = false;
[39] Fix | Delete
// If we have errors...
[40] Fix | Delete
if ( 'undefined' != typeof response.errors ) {
[41] Fix | Delete
var errorOutput = '';
[42] Fix | Delete
// Record them.
[43] Fix | Delete
response.errors.forEach(
[44] Fix | Delete
function( error ) {
[45] Fix | Delete
// Block success if one was fatal.
[46] Fix | Delete
if ( 'fatal' == error.type ) {
[47] Fix | Delete
blockingErrors = true;
[48] Fix | Delete
}
[49] Fix | Delete
console.error( error.type + ': ' + error.code );
[50] Fix | Delete
errorOutput += '<p>' + error.message + '</p>';
[51] Fix | Delete
}
[52] Fix | Delete
);
[53] Fix | Delete
jQuery( '#row-nf-import-response-error td' ).html( errorOutput );
[54] Fix | Delete
jQuery( '#row-nf-import-response-error' ).show();
[55] Fix | Delete
}
[56] Fix | Delete
if ( ! blockingErrors ) {
[57] Fix | Delete
jQuery( '#row-nf-import-response' ).show();
[58] Fix | Delete
}
[59] Fix | Delete
}
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
/**
[63] Fix | Delete
* Instantiate our batch processor.
[64] Fix | Delete
*
[65] Fix | Delete
* This will open the modal and present the user with content and buttons.
[66] Fix | Delete
*/
[67] Fix | Delete
new NinjaBatchProcessor( settings );
[68] Fix | Delete
} );
[69] Fix | Delete
[70] Fix | Delete
$( document ).on( 'change', '#nf_import_fields', function( e ) {
[71] Fix | Delete
jQuery( '#nf_import_security' ).val(nfAdmin.batchNonce);
[72] Fix | Delete
});
[73] Fix | Delete
[74] Fix | Delete
/**
[75] Fix | Delete
* Selecting a file within an input field triggers a jQuery change event.
[76] Fix | Delete
*
[77] Fix | Delete
* When we select a form file to import, we need to do a few things:
[78] Fix | Delete
*
[79] Fix | Delete
* Disable the primary button of our batch processing modal.
[80] Fix | Delete
* Grab the file and make sure that it has a .nff extension.
[81] Fix | Delete
* Read the contents and base64 encode them using the HTML5 FileReader API.
[82] Fix | Delete
* Set the contents to our importFormFile variable.
[83] Fix | Delete
*
[84] Fix | Delete
* @since 3.4.0
[85] Fix | Delete
* @param object e Change Event
[86] Fix | Delete
* @return {[type]} [description]
[87] Fix | Delete
*/
[88] Fix | Delete
$( document ).on( 'change', '#nf-import-file', function( e ) {
[89] Fix | Delete
// Hide our success message.
[90] Fix | Delete
jQuery( '#row-nf-import-response' ).hide();
[91] Fix | Delete
jQuery( '#row-nf-import-response-error' ).hide();
[92] Fix | Delete
// Hide our extension type error.
[93] Fix | Delete
jQuery( '#row-nf-import-type-error' ).hide();
[94] Fix | Delete
[95] Fix | Delete
// Grab the file from the input.
[96] Fix | Delete
var file = e.target.files[0];
[97] Fix | Delete
// If our file var is empty, bail.
[98] Fix | Delete
if ( ! file ) {
[99] Fix | Delete
return false;
[100] Fix | Delete
}
[101] Fix | Delete
[102] Fix | Delete
// Use some Regex to get the extension
[103] Fix | Delete
var extension = file.name.match(/\.[0-9a-z]+$/i);
[104] Fix | Delete
[105] Fix | Delete
// If we don't have a .nff extension, show our type error and bail.
[106] Fix | Delete
if ( '.nff' !== extension[0] ) {
[107] Fix | Delete
jQuery( '#row-nf-import-type-error' ).show();
[108] Fix | Delete
importFormFile.name = '';
[109] Fix | Delete
importFormFile.content = '';
[110] Fix | Delete
return false;
[111] Fix | Delete
}
[112] Fix | Delete
[113] Fix | Delete
// Instantiate the HTML5 FileReader API.
[114] Fix | Delete
var reader = new FileReader();
[115] Fix | Delete
[116] Fix | Delete
/**
[117] Fix | Delete
* When the HTML5 API says that we've successfully loaded the file contents:
[118] Fix | Delete
* Set our importFormFile var.
[119] Fix | Delete
* Enable our batch processor primary button.
[120] Fix | Delete
* We use Javascript's addEventListener to update our var.
[121] Fix | Delete
*/
[122] Fix | Delete
reader.addEventListener( 'load', function () {
[123] Fix | Delete
importFormFile.name = file.name;
[124] Fix | Delete
importFormFile.content = reader.result;
[125] Fix | Delete
}, false);
[126] Fix | Delete
[127] Fix | Delete
// Use the readAsDataURL method of the FileReader API.
[128] Fix | Delete
reader.readAsDataURL( file );
[129] Fix | Delete
} );
[130] Fix | Delete
[131] Fix | Delete
var clickedElement;
[132] Fix | Delete
[133] Fix | Delete
$(document).off( 'mousedown' ).on( 'mousedown', function( e ) {
[134] Fix | Delete
clickedElement = e.target;
[135] Fix | Delete
});
[136] Fix | Delete
[137] Fix | Delete
$( '#nf_export_form_2' ).off( 'focus' ).on( 'focus', function () {
[138] Fix | Delete
//show the dropdown on focus of the input
[139] Fix | Delete
$( '.nf-form-dropdown' ).show();
[140] Fix | Delete
});
[141] Fix | Delete
[142] Fix | Delete
$( '#nf_export_form_2' ).off( 'keyup' ).on( 'keyup', function () {
[143] Fix | Delete
//show the dropdown if it isn't show
[144] Fix | Delete
$( '.nf-form-dropdown' ).show();
[145] Fix | Delete
// get the value of the input, which we filter on
[146] Fix | Delete
var filter = $( this ).val();
[147] Fix | Delete
if( '' === filter ) {
[148] Fix | Delete
//if the filter val is empty, show all form options
[149] Fix | Delete
$( '.nf-form-dropdown' ).find( 'li' ).show();
[150] Fix | Delete
} else {
[151] Fix | Delete
[152] Fix | Delete
$.each( $( '#nf_form_export_options span' ), function ( index, span ) {
[153] Fix | Delete
var tmpSpan = $( span );
[154] Fix | Delete
// test to see if span text contains the entered value
[155] Fix | Delete
if ( 0 <= tmpSpan.text().toLowerCase().indexOf( filter.toLowerCase() ) ) {
[156] Fix | Delete
// shows options that DO contain the text entered
[157] Fix | Delete
tmpSpan.parent().show();
[158] Fix | Delete
} else {
[159] Fix | Delete
// hides options the do not contain the text entered
[160] Fix | Delete
tmpSpan.parent().hide();
[161] Fix | Delete
}
[162] Fix | Delete
});
[163] Fix | Delete
}
[164] Fix | Delete
});
[165] Fix | Delete
[166] Fix | Delete
$( '#nf_export_form_2' ).off( 'blur' ).on( 'blur' , function( e ) {
[167] Fix | Delete
if( 'undefined' !== typeof clickedElement ) {
[168] Fix | Delete
if ( ! $( clickedElement ).hasClass( 'nf-form-option-item' ) ) {
[169] Fix | Delete
$( '#nf_export_form_2' ).val( '' );
[170] Fix | Delete
$( '.nf-form-dropdown' ).hide();
[171] Fix | Delete
}
[172] Fix | Delete
}
[173] Fix | Delete
});
[174] Fix | Delete
[175] Fix | Delete
$( '.nf-form-option' ).off( 'click' ).on( 'click', function() {
[176] Fix | Delete
// on click get the value of the input
[177] Fix | Delete
var val = $( this ).data( 'val' );
[178] Fix | Delete
// nf_export_form is now a hidden field instead of select element
[179] Fix | Delete
$( '#nf_export_form' ).val( val );
[180] Fix | Delete
// set the text of the input field
[181] Fix | Delete
$( '#nf_export_form_2' ).val( '' );
[182] Fix | Delete
// and hide the option.
[183] Fix | Delete
$( '.nf-form-dropdown' ).hide();
[184] Fix | Delete
});
[185] Fix | Delete
[186] Fix | Delete
});
[187] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function