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.../themes/Divi/core/admin/js
File: portability.js
( function( $ ) {
[0] Fix | Delete
[1] Fix | Delete
"use strict";
[2] Fix | Delete
[3] Fix | Delete
// Extend etCorePortability since it is declared by localization.
[4] Fix | Delete
window.etCore.portability = $.extend( etCorePortability, {
[5] Fix | Delete
[6] Fix | Delete
cancelled: false,
[7] Fix | Delete
[8] Fix | Delete
boot: function( $instance ) {
[9] Fix | Delete
var $this = this;
[10] Fix | Delete
var $customizeHeader = $( '#customize-header-actions' );
[11] Fix | Delete
var $customizePortability = $( '.et-core-customize-controls-close' );
[12] Fix | Delete
[13] Fix | Delete
// Moved portability button into customizer header
[14] Fix | Delete
if ( $customizeHeader.length && $customizePortability.length ) {
[15] Fix | Delete
$customizeHeader.append( $customizePortability );
[16] Fix | Delete
}
[17] Fix | Delete
[18] Fix | Delete
$( '[data-et-core-portability]' ).each( function() {
[19] Fix | Delete
$this.listen( $( this ) );
[20] Fix | Delete
} );
[21] Fix | Delete
[22] Fix | Delete
// Release unecessary cache.
[23] Fix | Delete
etCorePortability = null;
[24] Fix | Delete
},
[25] Fix | Delete
[26] Fix | Delete
listen: function( $el ) {
[27] Fix | Delete
var $this = this;
[28] Fix | Delete
[29] Fix | Delete
$el.find( '[data-et-core-portability-export]' ).click( function( e ) {
[30] Fix | Delete
e.preventDefault();
[31] Fix | Delete
[32] Fix | Delete
if ( ! $this.actionsDisabled() ) {
[33] Fix | Delete
$this.disableActions();
[34] Fix | Delete
$this.export();
[35] Fix | Delete
}
[36] Fix | Delete
} );
[37] Fix | Delete
[38] Fix | Delete
[39] Fix | Delete
$el.find( '.et-core-portability-export-form input[type="text"]' ).on( 'keydown', function( e ) {
[40] Fix | Delete
if ( 13 === e.keyCode ) {
[41] Fix | Delete
e.preventDefault();
[42] Fix | Delete
$el.find( '[data-et-core-portability-export]' ).click();
[43] Fix | Delete
}
[44] Fix | Delete
} );
[45] Fix | Delete
[46] Fix | Delete
// Portability populate import.
[47] Fix | Delete
$el.find( '.et-core-portability-import-form input[type="file"]' ).on( 'change', function( e ) {
[48] Fix | Delete
$this.populateImport( $( this ).get( 0 ).files[0] );
[49] Fix | Delete
} );
[50] Fix | Delete
[51] Fix | Delete
$el.find( '.et-core-portability-import' ).click( function( e ) {
[52] Fix | Delete
e.preventDefault();
[53] Fix | Delete
[54] Fix | Delete
if ( ! $this.actionsDisabled() ) {
[55] Fix | Delete
$this.disableActions();
[56] Fix | Delete
$this.import();
[57] Fix | Delete
}
[58] Fix | Delete
} );
[59] Fix | Delete
[60] Fix | Delete
// Trigger file window.
[61] Fix | Delete
$el.find( '.et-core-portability-import-form button' ).click( function( e ) {
[62] Fix | Delete
e.preventDefault();
[63] Fix | Delete
$this.instance( 'input[type="file"]' ).trigger( 'click' );
[64] Fix | Delete
} );
[65] Fix | Delete
[66] Fix | Delete
// Cancel request.
[67] Fix | Delete
$el.find( '[data-et-core-portability-cancel]' ).click( function( e ) {
[68] Fix | Delete
e.preventDefault();
[69] Fix | Delete
$this.cancel();
[70] Fix | Delete
} );
[71] Fix | Delete
},
[72] Fix | Delete
[73] Fix | Delete
validateImportFile: function( file, noOutput ) {
[74] Fix | Delete
if ( undefined !== file && 'undefined' != typeof file.name && 'undefined' != typeof file.type && 'json' == file.name.split( '.' ).slice( -1 )[0] ) {
[75] Fix | Delete
[76] Fix | Delete
return true;
[77] Fix | Delete
}
[78] Fix | Delete
[79] Fix | Delete
if ( ! noOutput ) {
[80] Fix | Delete
etCore.modalContent( '<p>' + this.text.invalideFile + '</p>', false, 3000, '#et-core-portability-import' );
[81] Fix | Delete
}
[82] Fix | Delete
[83] Fix | Delete
this.enableActions();
[84] Fix | Delete
[85] Fix | Delete
return false;
[86] Fix | Delete
},
[87] Fix | Delete
[88] Fix | Delete
populateImport: function( file ) {
[89] Fix | Delete
if ( ! this.validateImportFile( file ) ) {
[90] Fix | Delete
return;
[91] Fix | Delete
}
[92] Fix | Delete
[93] Fix | Delete
$( '.et-core-portability-import-placeholder' ).text( file.name );
[94] Fix | Delete
},
[95] Fix | Delete
[96] Fix | Delete
import: function() {
[97] Fix | Delete
var $this = this;
[98] Fix | Delete
var file = $this.instance('input[type="file"]').get(0).files[0];
[99] Fix | Delete
[100] Fix | Delete
if (undefined === window.FormData) {
[101] Fix | Delete
etCore.modalContent('<p>' + this.text.browserSupport + '</p>', false, 3000, '#et-core-portability-import');
[102] Fix | Delete
[103] Fix | Delete
$this.enableActions();
[104] Fix | Delete
[105] Fix | Delete
return;
[106] Fix | Delete
}
[107] Fix | Delete
[108] Fix | Delete
if (!$this.validateImportFile(file)) {
[109] Fix | Delete
return;
[110] Fix | Delete
}
[111] Fix | Delete
[112] Fix | Delete
$this.addProgressBar( $this.text.importing );
[113] Fix | Delete
[114] Fix | Delete
// Export Backup if set.
[115] Fix | Delete
if ( $this.instance( '[name="et-core-portability-import-backup"]' ).is( ':checked' ) && ! noBackup ) {
[116] Fix | Delete
$this.export( true );
[117] Fix | Delete
[118] Fix | Delete
$( $this ).on( 'exported', function() {
[119] Fix | Delete
$this.import( true );
[120] Fix | Delete
} );
[121] Fix | Delete
[122] Fix | Delete
return;
[123] Fix | Delete
}
[124] Fix | Delete
[125] Fix | Delete
var includeGlobalPresets = $this.instance('[name="et-core-portability-import-include-global-presets"]').is(':checked');
[126] Fix | Delete
[127] Fix | Delete
$this.ajaxAction( {
[128] Fix | Delete
action: 'et_core_portability_import',
[129] Fix | Delete
file: file,
[130] Fix | Delete
include_global_presets: includeGlobalPresets,
[131] Fix | Delete
nonce: $this.nonces.import
[132] Fix | Delete
}, function( response ) {
[133] Fix | Delete
etCore.modalContent( '<div class="et-core-loader et-core-loader-success"></div>', false, 3000, '#et-core-portability-import' );
[134] Fix | Delete
$this.toggleCancel();
[135] Fix | Delete
[136] Fix | Delete
$( document ).delay( 3000 ).queue( function() {
[137] Fix | Delete
etCore.modalContent( '<div class="et-core-loader"></div>', false, false, '#et-core-portability-import' );
[138] Fix | Delete
[139] Fix | Delete
$( this ).dequeue().delay( 2000 ).queue( function() {
[140] Fix | Delete
// Save post content for individual content.
[141] Fix | Delete
if ( 'undefined' !== typeof response.data.postContent ) {
[142] Fix | Delete
var save = $( '#save-action #save-post' );
[143] Fix | Delete
[144] Fix | Delete
if ( save.length === 0 ) {
[145] Fix | Delete
save = $( '#publishing-action input[type="submit"]' );
[146] Fix | Delete
}
[147] Fix | Delete
[148] Fix | Delete
if ( 'undefined' !== typeof window.tinyMCE && window.tinyMCE.get( 'content' ) && ! window.tinyMCE.get( 'content' ).isHidden() ) {
[149] Fix | Delete
var editor = window.tinyMCE.get( 'content' );
[150] Fix | Delete
[151] Fix | Delete
editor.setContent( $.trim( response.data.postContent ), { format: 'html' } );
[152] Fix | Delete
} else {
[153] Fix | Delete
$( '#content' ).val( $.trim( response.data.postContent ) );
[154] Fix | Delete
}
[155] Fix | Delete
[156] Fix | Delete
save.trigger( 'click' );
[157] Fix | Delete
[158] Fix | Delete
window.onbeforeunload = function() {
[159] Fix | Delete
$( 'body' ).fadeOut( 500 );
[160] Fix | Delete
}
[161] Fix | Delete
} else {
[162] Fix | Delete
$( 'body' ).fadeOut( 500, function() {
[163] Fix | Delete
// Remove confirmation popup before relocation.
[164] Fix | Delete
$( window ).unbind( 'beforeunload' );
[165] Fix | Delete
[166] Fix | Delete
window.location = window.location.href.replace(/reset\=true\&|\&reset\=true/,'');
[167] Fix | Delete
} )
[168] Fix | Delete
}
[169] Fix | Delete
} );
[170] Fix | Delete
} );
[171] Fix | Delete
}, true );
[172] Fix | Delete
},
[173] Fix | Delete
[174] Fix | Delete
export: function( backup ) {
[175] Fix | Delete
var $this = this,
[176] Fix | Delete
progressBarMessages = backup ? $this.text.backuping : $this.text.exporting;
[177] Fix | Delete
[178] Fix | Delete
$this.save( function() {
[179] Fix | Delete
var posts = {},
[180] Fix | Delete
content = false;
[181] Fix | Delete
[182] Fix | Delete
// Include selected posts.
[183] Fix | Delete
if ( $this.instance( '[name="et-core-portability-posts"]' ).is( ':checked' ) ) {
[184] Fix | Delete
$( '#posts-filter [name="post[]"]:checked:enabled' ).each( function() {
[185] Fix | Delete
posts[this.id] = this.value;
[186] Fix | Delete
} );
[187] Fix | Delete
[188] Fix | Delete
// do not proceed and display error message if no Items selected
[189] Fix | Delete
if ( $.isEmptyObject( posts ) ) {
[190] Fix | Delete
etCore.modalContent( '<div class="et-core-loader et-core-loader-fail"></div><h3>' + $this.text.noItemsSelected + '</h3>', false, true, '#' + $this.instance( '.ui-tabs-panel:visible' ).attr( 'id' ) );
[191] Fix | Delete
[192] Fix | Delete
$this.enableActions();
[193] Fix | Delete
[194] Fix | Delete
return;
[195] Fix | Delete
}
[196] Fix | Delete
}
[197] Fix | Delete
[198] Fix | Delete
$this.addProgressBar( progressBarMessages );
[199] Fix | Delete
[200] Fix | Delete
// Get post layout.
[201] Fix | Delete
if ( 'undefined' !== typeof window.tinyMCE && window.tinyMCE.get( 'content' ) && ! window.tinyMCE.get( 'content' ).isHidden() ) {
[202] Fix | Delete
content = window.tinyMCE.get( 'content' ).getContent();
[203] Fix | Delete
} else if ( $( 'textarea#content' ).length > 0 ) {
[204] Fix | Delete
content = $( 'textarea#content' ).val();
[205] Fix | Delete
}
[206] Fix | Delete
[207] Fix | Delete
if ( false !== content ) {
[208] Fix | Delete
content = content.replace( /^([^\[]*){1}/, '' );
[209] Fix | Delete
content = content.replace( /([^\]]*)$/, '' );
[210] Fix | Delete
}
[211] Fix | Delete
[212] Fix | Delete
$this.ajaxAction( {
[213] Fix | Delete
action: 'et_core_portability_export',
[214] Fix | Delete
content: content,
[215] Fix | Delete
selection: $.isEmptyObject( posts ) ? false : JSON.stringify( posts ),
[216] Fix | Delete
nonce: $this.nonces.export
[217] Fix | Delete
}, function( response ) {
[218] Fix | Delete
var time = ' ' + new Date().toJSON().replace( 'T', ' ' ).replace( ':', 'h' ).substring( 0, 16 ),
[219] Fix | Delete
downloadURL = $this.instance( '[data-et-core-portability-export]' ).data( 'et-core-portability-export' ),
[220] Fix | Delete
query = {
[221] Fix | Delete
'timestamp': response.data.timestamp,
[222] Fix | Delete
'name': encodeURIComponent( $this.instance( '.et-core-portability-export-form input' ).val() + ( backup ? time : '' ) ),
[223] Fix | Delete
};
[224] Fix | Delete
[225] Fix | Delete
$.each( query, function( key, value ) {
[226] Fix | Delete
if ( value ) {
[227] Fix | Delete
downloadURL = downloadURL + '&' + key + '=' + value;
[228] Fix | Delete
}
[229] Fix | Delete
} );
[230] Fix | Delete
[231] Fix | Delete
// Remove confirmation popup before relocation.
[232] Fix | Delete
$( window ).unbind( 'beforeunload' );
[233] Fix | Delete
[234] Fix | Delete
window.location.assign( encodeURI( downloadURL ) );
[235] Fix | Delete
[236] Fix | Delete
if ( ! backup ) {
[237] Fix | Delete
etCore.modalContent( '<div class="et-core-loader et-core-loader-success"></div>', false, 3000, '#et-core-portability-export' );
[238] Fix | Delete
$this.toggleCancel();
[239] Fix | Delete
}
[240] Fix | Delete
[241] Fix | Delete
$( $this ).trigger( 'exported' );
[242] Fix | Delete
} );
[243] Fix | Delete
} );
[244] Fix | Delete
},
[245] Fix | Delete
[246] Fix | Delete
exportFB: function( exportUrl, postId, content, fileName, importFile, page, timestamp, progress = 0, estimation = 1 ) {
[247] Fix | Delete
var $this = this;
[248] Fix | Delete
[249] Fix | Delete
// Trigger event which updates VB-UI's progress bar
[250] Fix | Delete
window.et_fb_export_progress = progress;
[251] Fix | Delete
window.et_fb_export_estimation = estimation;
[252] Fix | Delete
[253] Fix | Delete
var exportEvent = document.createEvent('Event');
[254] Fix | Delete
exportEvent.initEvent('et_fb_layout_export_in_progress', true, true);
[255] Fix | Delete
window.dispatchEvent(exportEvent);
[256] Fix | Delete
[257] Fix | Delete
page = typeof page === 'undefined' ? 1 : page;
[258] Fix | Delete
[259] Fix | Delete
$.ajax( {
[260] Fix | Delete
type: 'POST',
[261] Fix | Delete
url: etCore.ajaxurl,
[262] Fix | Delete
dataType: 'json',
[263] Fix | Delete
data: {
[264] Fix | Delete
action: 'et_core_portability_export',
[265] Fix | Delete
content: content.shortcode,
[266] Fix | Delete
global_presets: content.global_presets,
[267] Fix | Delete
timestamp: timestamp !== undefined ? timestamp : 0,
[268] Fix | Delete
nonce: $this.nonces.export,
[269] Fix | Delete
post: postId,
[270] Fix | Delete
context: 'et_builder',
[271] Fix | Delete
page: page,
[272] Fix | Delete
},
[273] Fix | Delete
success: function( response ) {
[274] Fix | Delete
var errorEvent = document.createEvent( 'Event' );
[275] Fix | Delete
[276] Fix | Delete
errorEvent.initEvent( 'et_fb_layout_export_error', true, true );
[277] Fix | Delete
[278] Fix | Delete
// The error is unknown but most of the time it would be cased by the server max size being exceeded.
[279] Fix | Delete
if ( 'string' === typeof response && '0' === response ) {
[280] Fix | Delete
window.et_fb_export_layout_message = $this.text.maxSizeExceeded;
[281] Fix | Delete
window.dispatchEvent( errorEvent );
[282] Fix | Delete
[283] Fix | Delete
return;
[284] Fix | Delete
}
[285] Fix | Delete
// Memory size set on server is exhausted.
[286] Fix | Delete
else if ( 'string' === typeof response && response.toLowerCase().indexOf( 'memory size' ) >= 0 ) {
[287] Fix | Delete
window.et_fb_export_layout_message = $this.text.memoryExhausted;
[288] Fix | Delete
window.dispatchEvent( errorEvent );
[289] Fix | Delete
return;
[290] Fix | Delete
}
[291] Fix | Delete
// Paginate.
[292] Fix | Delete
else if ( 'undefined' !== typeof response.page ) {
[293] Fix | Delete
if ( $this.cancelled ) {
[294] Fix | Delete
return;
[295] Fix | Delete
}
[296] Fix | Delete
[297] Fix | Delete
// Update progress bar
[298] Fix | Delete
var updatedProgress = Math.ceil((response.page * 100) / response.total_pages);
[299] Fix | Delete
var updatedEstimation = Math.ceil(((response.total_pages - response.page) * 6) / 60);
[300] Fix | Delete
[301] Fix | Delete
// If progress param isn't empty, updated progress should continue from it
[302] Fix | Delete
// because before exportFB(), shortcode should've been prepared via another
[303] Fix | Delete
// ajax request first
[304] Fix | Delete
if (0 < progress) {
[305] Fix | Delete
const remainingProgress = (100 - progress) / 100;
[306] Fix | Delete
updatedProgress = (updatedProgress * remainingProgress) + progress;
[307] Fix | Delete
}
[308] Fix | Delete
[309] Fix | Delete
// Update global variables
[310] Fix | Delete
window.et_fb_export_progress = updatedProgress;
[311] Fix | Delete
window.et_fb_export_estimation = updatedEstimation;
[312] Fix | Delete
[313] Fix | Delete
// Dispatch event to trigger UI update
[314] Fix | Delete
window.dispatchEvent(exportEvent);
[315] Fix | Delete
[316] Fix | Delete
return $this.exportFB(
[317] Fix | Delete
exportUrl,
[318] Fix | Delete
postId,
[319] Fix | Delete
content,
[320] Fix | Delete
fileName,
[321] Fix | Delete
importFile,
[322] Fix | Delete
(page + 1),
[323] Fix | Delete
response.timestamp,
[324] Fix | Delete
updatedProgress,
[325] Fix | Delete
updatedEstimation
[326] Fix | Delete
);
[327] Fix | Delete
} else if ( 'undefined' !== typeof response.data && 'undefined' !== typeof response.data.message ) {
[328] Fix | Delete
window.et_fb_export_layout_message = $this.text[response.data.message];
[329] Fix | Delete
window.dispatchEvent( errorEvent );
[330] Fix | Delete
return;
[331] Fix | Delete
}
[332] Fix | Delete
[333] Fix | Delete
var time = ' ' + new Date().toJSON().replace( 'T', ' ' ).replace( ':', 'h' ).substring( 0, 16 ),
[334] Fix | Delete
downloadURL = exportUrl,
[335] Fix | Delete
query = {
[336] Fix | Delete
'timestamp': response.data.timestamp,
[337] Fix | Delete
'name': '' !== fileName ? fileName : encodeURIComponent( time ),
[338] Fix | Delete
};
[339] Fix | Delete
[340] Fix | Delete
$.each( query, function( key, value ) {
[341] Fix | Delete
if ( value ) {
[342] Fix | Delete
downloadURL = downloadURL + '&' + key + '=' + value;
[343] Fix | Delete
}
[344] Fix | Delete
} );
[345] Fix | Delete
[346] Fix | Delete
// Remove confirmation popup before relocation.
[347] Fix | Delete
$( window ).unbind( 'beforeunload' );
[348] Fix | Delete
[349] Fix | Delete
// Update progress bar's global variables
[350] Fix | Delete
window.et_fb_export_progress = 100;
[351] Fix | Delete
window.et_fb_export_estimation = 0;
[352] Fix | Delete
[353] Fix | Delete
// Dispatch event to trigger UI update
[354] Fix | Delete
window.dispatchEvent(exportEvent);
[355] Fix | Delete
window.location.assign( encodeURI( downloadURL ) );
[356] Fix | Delete
[357] Fix | Delete
// perform import if needed
[358] Fix | Delete
if ( typeof importFile !== 'undefined' ) {
[359] Fix | Delete
$this.importFB( importFile, postId );
[360] Fix | Delete
} else {
[361] Fix | Delete
var event = document.createEvent( 'Event' );
[362] Fix | Delete
[363] Fix | Delete
event.initEvent( 'et_fb_layout_export_finished', true, true );
[364] Fix | Delete
[365] Fix | Delete
// trigger event to communicate with FB
[366] Fix | Delete
window.dispatchEvent( event );
[367] Fix | Delete
}
[368] Fix | Delete
}
[369] Fix | Delete
} );
[370] Fix | Delete
},
[371] Fix | Delete
[372] Fix | Delete
importFB: function(file, postId, options) {
[373] Fix | Delete
var $this = this;
[374] Fix | Delete
var errorEvent = document.createEvent( 'Event' );
[375] Fix | Delete
[376] Fix | Delete
window.et_fb_import_progress = 0;
[377] Fix | Delete
window.et_fb_import_estimation = 1;
[378] Fix | Delete
[379] Fix | Delete
errorEvent.initEvent( 'et_fb_layout_import_error', true, true );
[380] Fix | Delete
[381] Fix | Delete
if ( undefined === window.FormData ) {
[382] Fix | Delete
window.et_fb_import_layout_message = this.text.browserSupport;
[383] Fix | Delete
window.dispatchEvent( errorEvent );
[384] Fix | Delete
return;
[385] Fix | Delete
}
[386] Fix | Delete
[387] Fix | Delete
if ( ! $this.validateImportFile( file, true ) ) {
[388] Fix | Delete
window.et_fb_import_layout_message = this.text.invalideFile;
[389] Fix | Delete
window.dispatchEvent( errorEvent );
[390] Fix | Delete
return;
[391] Fix | Delete
}
[392] Fix | Delete
[393] Fix | Delete
if ('undefined' === typeof options) {
[394] Fix | Delete
options = {};
[395] Fix | Delete
}
[396] Fix | Delete
[397] Fix | Delete
options = $.extend({
[398] Fix | Delete
replace: false
[399] Fix | Delete
}, options);
[400] Fix | Delete
[401] Fix | Delete
var fileSize = Math.ceil( ( file.size / ( 1024 * 1024 ) ).toFixed( 2 ) ),
[402] Fix | Delete
formData = new FormData(),
[403] Fix | Delete
requestData = {
[404] Fix | Delete
action: 'et_core_portability_import',
[405] Fix | Delete
include_global_presets: options.includeGlobalPresets,
[406] Fix | Delete
file: file,
[407] Fix | Delete
content: false,
[408] Fix | Delete
timestamp: 0,
[409] Fix | Delete
nonce: $this.nonces.import,
[410] Fix | Delete
post: postId,
[411] Fix | Delete
replace: options.replace ? '1' : '0',
[412] Fix | Delete
context: 'et_builder'
[413] Fix | Delete
};
[414] Fix | Delete
[415] Fix | Delete
/**
[416] Fix | Delete
* Max size set on server is exceeded.
[417] Fix | Delete
*
[418] Fix | Delete
* 0 indicating "unlimited" according to php specs
[419] Fix | Delete
* https://www.php.net/manual/en/ini.core.php#ini.post-max-size
[420] Fix | Delete
**/
[421] Fix | Delete
if (
[422] Fix | Delete
( 0 > $this.postMaxSize && fileSize >= $this.postMaxSize )
[423] Fix | Delete
|| ( 0 > $this.uploadMaxSize && fileSize >= $this.uploadMaxSize )
[424] Fix | Delete
) {
[425] Fix | Delete
window.et_fb_import_layout_message = this.text.maxSizeExceeded;
[426] Fix | Delete
window.dispatchEvent( errorEvent );
[427] Fix | Delete
return;
[428] Fix | Delete
}
[429] Fix | Delete
[430] Fix | Delete
$.each( requestData, function( name, value ) {
[431] Fix | Delete
formData.append( name, value);
[432] Fix | Delete
} );
[433] Fix | Delete
[434] Fix | Delete
var importFBAjax = function( importData ) {
[435] Fix | Delete
$.ajax( {
[436] Fix | Delete
type: 'POST',
[437] Fix | Delete
url: etCore.ajaxurl,
[438] Fix | Delete
processData: false,
[439] Fix | Delete
contentType: false,
[440] Fix | Delete
data: formData,
[441] Fix | Delete
success: function( response ) {
[442] Fix | Delete
var event = document.createEvent( 'Event' );
[443] Fix | Delete
[444] Fix | Delete
event.initEvent( 'et_fb_layout_import_in_progress', true, true );
[445] Fix | Delete
[446] Fix | Delete
// Handle known error
[447] Fix | Delete
if ( ! response.success && 'undefined' !== typeof response.data && 'undefined' !== typeof response.data.message && 'undefined' !== typeof $this.text[ response.data.message ] ) {
[448] Fix | Delete
window.et_fb_import_layout_message = $this.text[ response.data.message ];
[449] Fix | Delete
window.dispatchEvent( errorEvent );
[450] Fix | Delete
}
[451] Fix | Delete
// The error is unknown but most of the time it would be cased by the server max size being exceeded.
[452] Fix | Delete
else if ( 'string' === typeof response && ('0' === response || '' === response) ) {
[453] Fix | Delete
window.et_fb_import_layout_message = $this.text.maxSizeExceeded;
[454] Fix | Delete
window.dispatchEvent( errorEvent );
[455] Fix | Delete
[456] Fix | Delete
return;
[457] Fix | Delete
}
[458] Fix | Delete
// Memory size set on server is exhausted.
[459] Fix | Delete
else if ( 'string' === typeof response && response.toLowerCase().indexOf( 'memory size' ) >= 0 ) {
[460] Fix | Delete
window.et_fb_import_layout_message = $this.text.memoryExhausted;
[461] Fix | Delete
window.dispatchEvent( errorEvent );
[462] Fix | Delete
[463] Fix | Delete
return;
[464] Fix | Delete
}
[465] Fix | Delete
// Pagination
[466] Fix | Delete
else if ( 'undefined' !== typeof response.page && 'undefined' !== typeof response.total_pages ) {
[467] Fix | Delete
// Update progress bar
[468] Fix | Delete
var progress = Math.ceil( ( response.page * 100 ) / response.total_pages );
[469] Fix | Delete
var estimation = Math.ceil( ( ( response.total_pages - response.page ) * 6 ) / 60 );
[470] Fix | Delete
[471] Fix | Delete
window.et_fb_import_progress = progress;
[472] Fix | Delete
window.et_fb_import_estimation = estimation;
[473] Fix | Delete
[474] Fix | Delete
// Import data
[475] Fix | Delete
var nextImportData = importData;
[476] Fix | Delete
nextImportData.append( 'page', ( parseInt(response.page) + 1 ) );
[477] Fix | Delete
nextImportData.append( 'timestamp', response.timestamp );
[478] Fix | Delete
nextImportData.append( 'file', null );
[479] Fix | Delete
[480] Fix | Delete
importFBAjax( nextImportData );
[481] Fix | Delete
[482] Fix | Delete
// trigger event to communicate with FB
[483] Fix | Delete
window.dispatchEvent( event );
[484] Fix | Delete
} else {
[485] Fix | Delete
// Update progress bar
[486] Fix | Delete
window.et_fb_import_progress = 100;
[487] Fix | Delete
window.et_fb_import_estimation = 0;
[488] Fix | Delete
[489] Fix | Delete
// trigger event to communicate with FB
[490] Fix | Delete
window.dispatchEvent( event );
[491] Fix | Delete
[492] Fix | Delete
// Allow some time for animations to animate
[493] Fix | Delete
setTimeout( function() {
[494] Fix | Delete
var event = document.createEvent( 'Event' );
[495] Fix | Delete
[496] Fix | Delete
event.initEvent( 'et_fb_layout_import_finished', true, true );
[497] Fix | Delete
[498] Fix | Delete
// save the data into global variable for later use in FB
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function