PluginProbe
Solace Extra / trunk
Solace Extra vtrunk
1.7.1 1.7.0 1.6.2 1.6.1 1.6.0 1.5.3 trunk 1.0.8 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.7 1.1.8 1.1.9 1.2.1 1.2.2 1.3.0 1.3.1 1.3.2 1.3.3 1.5.0 1.5.1 All 26 releases
solace-extra / admin / js / import.js

import.js in Solace Extra trunk, at admin/js/import.js

732 lines 29.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function( $ ) {
2 'use strict';
3
4 // Get nonce
5 var nonce = ajax_object.nonce;
6
7 // Keep the redesigned segmented bar and circular indicator synchronized
8 // with the existing import percentage animation.
9 function syncProgressVisual() {
10 var percentText = $('section.progress-import .percent').first().text();
11 var percentage = Math.max(0, Math.min(100, parseInt(percentText, 10) || 0));
12 var circumference = 119.38;
13
14 $('section.progress-import .progress-overall').css('width', percentage + '%');
15 $('section.progress-import .loading-percent span').text(percentage + '%');
16 $('section.progress-import .loading-value').css(
17 'stroke-dashoffset',
18 circumference - (circumference * percentage / 100)
19 );
20 }
21
22 function setImportStatus(message) {
23 var $status = $('section.progress-import span.info-import');
24 $status.empty().append($('<i>', { 'aria-hidden': 'true' })).append(
25 document.createTextNode(message)
26 );
27 }
28
29 var percentElement = document.querySelector('section.progress-import .percent');
30 if (percentElement) {
31 new MutationObserver(syncProgressVisual).observe(percentElement, {
32 childList: true,
33 characterData: true,
34 subtree: true
35 });
36 syncProgressVisual();
37 }
38
39 // Function to get the value of a URL parameter by name
40 function getParameterByName(name, url) {
41 // If URL is not provided, use the current window's URL
42 if (!url) url = window.location.href;
43
44 // Escape special characters in the parameter name
45 name = name.replace(/[\[\]]/g, "\\$&");
46
47 // Create a regular expression to match the parameter in the URL
48 var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)");
49
50 // Execute the regular expression on the URL
51 var results = regex.exec(url);
52
53 // If no results are found, return an empty string
54 if (!results) return '';
55
56 // If the parameter is present but has no value, return an empty string
57 if (!results[2]) return '';
58
59 // Decode the URI component and return the parameter value
60 return decodeURIComponent(results[2].replace(/\+/g, " "));
61 }
62
63 // Update Full Progress Text
64 function updatePercent(percentage, bar) {
65 var progress = percentage / 3;
66 if ( bar === '.bar2') {
67 var formattedProgress = Math.floor(progress); // Round down to the nearest whole number
68 if ( formattedProgress <= 75 || formattedProgress > 75) {
69 formattedProgress = 75;
70 }
71 } else if ( bar === '.bar4') {
72 var formattedProgress = Math.floor(progress); // Round down to the nearest whole number
73 if ( formattedProgress >= 75 || formattedProgress <= 75) {
74 formattedProgress = 100;
75 }
76 } else {
77 // Default Bar1
78 var formattedProgress = Math.floor(progress); // Round down to the nearest whole number
79 if ( formattedProgress > 25) {
80 formattedProgress = 25;
81 }
82 }
83 $('section.progress-import .mycontainer .boxes .percent').text(formattedProgress + '%');
84 }
85
86 // Update Full Progress Width
87 function updateProgressFull(targetPercentage, dur, bar) {
88 var progress = 0;
89 var duration = dur;
90 var interval = 10;
91 var totalSteps = duration / interval;
92 var step = (targetPercentage / totalSteps);
93
94 // Variable to store the width style in a string
95 var getWidthBar = $('section.progress-import .mycontainer .boxes .boxes-bar ' + bar + ' .progress').attr('style');
96
97 if (typeof getWidthBar === 'undefined') {
98 getWidthBar = 'width: 0%';
99 }
100
101 // console.log(getWidthBar);
102
103 // Matching the numbers using regular expression (regex)
104 var widthNumber = getWidthBar.match(/\b\d+(?:\.\d+)?(?=%)\b/);
105
106 // If there's a match, taking the first number
107 progress = widthNumber ? Math.floor(parseFloat(widthNumber[0])) : 0;
108
109 var timer = setInterval(function() {
110 if (progress < targetPercentage) {
111 progress += step;
112 if ( progress > 100) {
113 progress = 100;
114 }
115
116 $('section.progress-import .mycontainer .boxes .boxes-bar ' + bar + ' .progress').css('width', progress + '%');
117 updatePercent(progress, bar);
118 } else {
119 clearInterval(timer);
120 }
121 }, interval);
122 }
123
124 // Function to animate progress text bars based on provided information
125 var stepTextIntervals = {};
126 let lastTimeTextActive = Date.now(); // Track the last time the tab was active
127
128 let solaceExtraStep4Interval;
129 let solaceExtraStep4Timeout;
130 function animateProgressText(barInfoArray, totalDuration) {
131 var interval = 10; // Interval time for each step in milliseconds
132 var totalSteps = totalDuration / interval;
133
134 var currentBarIndex = 0;
135 var startProgress = 0;
136 function setIntervalStart() {
137 // Iterate through barInfoArray to set intervals for each step
138 barInfoArray.forEach(function(barInfo, index) {
139 var step = barInfo.StagedStep;
140 // Set interval to update startProgress bars
141 stepTextIntervals[step] = setInterval(function () {
142 const now = Date.now(); // Get current time
143 const timeElapsed = now - lastTimeTextActive; // Calculate elapsed time since last active
144 lastTimeTextActive = now; // Update last active time
145
146 // Determine how many steps to advance based on elapsed time
147 const stepsToAdvance = Math.floor(timeElapsed / interval);
148
149 if (currentBarIndex < barInfoArray.length) {
150 var currentBarInfo = barInfoArray[currentBarIndex];
151
152 if (startProgress < currentBarInfo.targetPercentage) {
153 startProgress += currentBarInfo.step * stepsToAdvance;
154
155 if (startProgress > 100) {
156 startProgress = 100;
157 }
158
159 // Update the current startProgress bar
160 if ( currentBarInfo.StagedStep === 'step1' ) {
161 $(currentBarInfo.selector).text( Math.min( 100, Math.floor( startProgress / 4 ) ) + '%' );
162 } else if ( currentBarInfo.StagedStep === 'step2' ) {
163 $(currentBarInfo.selector).text( Math.min( 100, Math.floor( startProgress / 2 + 25) ) + '%' );
164 } else if ( currentBarInfo.StagedStep === 'step4' ) {
165 $(currentBarInfo.selector).text( Math.min( 100, Math.floor( startProgress / 4 + 75 ) ) + '%' );
166 }
167 } else {
168 // If the current startProgress bar has reached its target, move to the next one
169 currentBarIndex++;
170 startProgress = 0;
171 }
172 } else {
173 // All startProgress bars have completed, stop the interval
174 clearInterval(stepTextIntervals[step]);
175 }
176 }, interval);
177 });
178 }
179
180 if ( barInfoArray[currentBarIndex].StagedStep === 'step2' ) {
181 updateProgressFull(100, 500, '.bar1');
182 setTimeout(function() {
183 setIntervalStart();
184 }, 500);
185 } else if ( barInfoArray[currentBarIndex].StagedStep === 'step4' ) {
186 updateProgressFull(100, 500, '.bar2');
187 setTimeout(function() {
188 setIntervalStart();
189 }, 500);
190 } else {
191 setIntervalStart();
192 }
193 }
194
195 // Event listener to reset last active time when the tab becomes active again
196 document.addEventListener('visibilitychange', function() {
197 if (document.visibilityState === 'visible') {
198 lastTimeTextActive = Date.now(); // Reset last active time
199 }
200 });
201
202 // Function to animate progress bars based on provided information
203 var stepIntervals = {};
204 let lastTimeProgressActive = Date.now(); // Track the last time the tab was active
205 function animateProgress(barInfoArray, totalDuration) {
206 var interval = 10; // Interval time for each step in milliseconds
207 var totalSteps = totalDuration / interval;
208
209 var currentBarIndex = 0;
210 var progress = 0;
211
212 function setIntervalStart() {
213 // Iterate through barInfoArray to set intervals for each step
214 barInfoArray.forEach(function(barInfo, index) {
215 var step = barInfo.StagedStep;
216
217 // Set interval for current step
218 stepIntervals[step] = setInterval(function () {
219 const now = Date.now(); // Get current time
220 const timeElapsed = now - lastTimeProgressActive; // Calculate elapsed time since last active
221 lastTimeProgressActive = now; // Update last active time
222
223 // Determine how many steps to advance based on elapsed time
224 const stepsToAdvance = Math.floor(timeElapsed / interval);
225
226 if (currentBarIndex < barInfoArray.length) {
227 var currentBarInfo = barInfoArray[currentBarIndex];
228
229 if (progress < currentBarInfo.targetPercentage) {
230 progress += currentBarInfo.step * stepsToAdvance;
231
232 if (progress > 100) {
233 progress = 100;
234 }
235
236 // Update the current progress bar
237 $(currentBarInfo.selector).css('width', progress + '%');
238 } else {
239 // If the current progress bar has reached its target, move to the next one
240 currentBarIndex++;
241 progress = 0;
242 }
243 } else {
244 // All progress bars have completed, stop the interval
245 clearInterval(stepIntervals[step]);
246 }
247 }, interval);
248 });
249 }
250
251 // console.log(barInfoArray[currentBarIndex].StagedStep);
252
253 if ( barInfoArray[currentBarIndex].StagedStep === 'step2' ) {
254 updateProgressFull(100, 500, '.bar1');
255 setTimeout(function() {
256 setIntervalStart();
257 }, 500);
258 } else if ( barInfoArray[currentBarIndex].StagedStep === 'step4' ) {
259 updateProgressFull(100, 500, '.bar2');
260 setTimeout(function() {
261 setIntervalStart();
262 }, 500);
263 } else {
264 setIntervalStart();
265 }
266 }
267
268 // Event listener to reset last active time when the tab becomes active again
269 document.addEventListener('visibilitychange', function() {
270 if (document.visibilityState === 'visible') {
271 lastTimeProgressActive = Date.now(); // Reset last active time
272 }
273 });
274
275 var interval = 10; // Interval time for each step in milliseconds
276 var bar1 = 60;
277 var bar2 = 75;
278 var bar3 = 75;
279 var bar4 = 30;
280 // var bar1 = 8;
281 // var bar2 = 10;
282 // var bar3 = 10;
283 // var bar4 = 6;
284
285 var totalDuration = bar1 * 1000 + bar2 * 1000 + bar3 * 1000 + bar4 * 1000; // Total animation duration in milliseconds
286
287 // Update text did you know
288 update_info_did_you_know();
289 function update_info_did_you_know() {
290 // Make a GET request to the API endpoint
291 fetch(solaceDemoImport.demo_import_url + 'api/wp-json/wp/v2/info')
292 .then(response => {
293 // Check if the response is successful (status code 200-299)
294 if (!response.ok) {
295 throw new Error(`HTTP error! Status: ${response.status}`);
296 }
297 // Parse the JSON data from the response
298 return response.json();
299 })
300 .then(data => {
301 // Handle the successful response
302 var titles = data.map(function (item) {
303 return item.title.rendered;
304 });
305
306 // Shuffle the titles array (randomize the order)
307 titles.sort(function () {
308 return Math.random() - 0.5;
309 });
310
311 // Log the shuffled titles to the console
312 // console.log('Shuffled Titles:', titles);
313
314 var currentIndex = 0;
315
316 function updateText() {
317 // Get the HTML element
318 var descElement = document.querySelector('section.progress-import .mycontainer .boxes .box-did-you-know .box-desc span.desc');
319
320 // Check if the element exists
321 if (descElement) {
322 // Update the text with the current title
323 descElement.textContent = titles[currentIndex];
324
325 // Increment the index for the next title
326 currentIndex = (currentIndex + 1) % titles.length;
327 } else {
328 console.error('Element not found. Check your HTML structure or selector.');
329 }
330 }
331
332 // Initial update
333 updateText();
334
335 // Set interval to update text every 4 seconds
336 setInterval(updateText, 4000);
337
338 })
339 .catch(error => {
340 // Handle errors
341 console.error('Error fetching API:', error);
342 });
343 }
344
345 // Animations Import Step1
346 function solace_extra_import_step1() {
347 var step1Text = [
348 {
349 targetPercentage: 100,
350 step: 100 / (bar1 * 1000 / interval),
351 selector: '.progress-import .boxes .percent',
352 StagedStep: 'step1',
353 },
354 ];
355 var step1 = [
356 {
357 targetPercentage: 100,
358 step: 100 / (bar1 * 1000 / interval),
359 selector: '.bar1 .progress',
360 StagedStep: 'step1',
361 },
362 ];
363 animateProgressText(step1Text, totalDuration);
364 animateProgress(step1, totalDuration);
365 }
366
367 // Animations Import Step2 & Step3
368 function solace_extra_import_step2_and_step3() {
369 var step2Text = [
370 {
371 targetPercentage: 100,
372 step: 100 / ( (bar2 + bar3) * 1000 / interval),
373 selector: '.progress-import .boxes .percent',
374 StagedStep: 'step2',
375 },
376 ];
377 var step2 = [
378 {
379 targetPercentage: 100,
380 step: 100 / ( (bar2 + bar3 ) * 1000 / interval),
381 selector: '.bar2 .progress',
382 StagedStep: 'step2',
383 },
384 ];
385 animateProgressText(step2Text, totalDuration);
386 animateProgress(step2, totalDuration);
387 }
388
389 function solace_extra_import_step4() {
390 const maxTime = 120000;
391 const intervalTime = 1000;
392 const totalSteps = maxTime / intervalTime;
393
394 const initialProgress = 1;
395
396 const initialPercent = 75;
397
398 const progressIncrement = (100 - initialProgress) / totalSteps;
399 const percentIncrement = (100 - initialPercent) / totalSteps;
400
401 let currentProgress = initialProgress;
402 let currentPercent = initialPercent;
403
404 $('section.progress-import .mycontainer .boxes .boxes-bar .bar4 .progress').css({
405 'transition': 'width 1s ease'
406 });
407
408 $('section.progress-import .mycontainer .boxes .boxes-bar .bar4 .progress').attr(
409 'style',
410 `width: ${initialProgress}%;`
411 );
412
413 $('section.progress-import .mycontainer .boxes .box-step-import .percent').text(`${initialPercent}%`);
414
415 // console.log(`solace_extra_import_step4 started. Initial progress: ${initialProgress}%, initial label: ${initialPercent}%`);
416
417 solaceExtraStep4Interval = setInterval(() => {
418 if (currentProgress < 99 || currentPercent < 99) {
419 currentProgress = Math.min(currentProgress + progressIncrement, 100);
420 currentPercent = Math.min(currentPercent + percentIncrement, 100);
421
422 $('section.progress-import .mycontainer .boxes .boxes-bar .bar4 .progress').attr(
423 'style',
424 `width: ${currentProgress.toFixed(2)}%;`
425 );
426
427 $('section.progress-import .mycontainer .boxes .box-step-import .percent').text(
428 `${Math.floor(currentPercent)}%`
429 );
430
431 // console.log(`Progress bar: ${currentProgress.toFixed(2)}%, Label percent: ${Math.floor(currentPercent)}%`);
432 } else {
433 clearInterval(solaceExtraStep4Interval);
434 // console.log("solace_extra_import_step4 completed.");
435 }
436 }, intervalTime);
437
438 solaceExtraStep4Timeout = setTimeout(() => {
439 clearInterval(solaceExtraStep4Interval);
440 if (currentProgress < 99 || currentPercent < 99) {
441 $('section.progress-import .mycontainer .boxes .boxes-bar .bar4 .progress').attr('style', 'width: 99%;');
442 $('section.progress-import .mycontainer .boxes .box-step-import .percent').text('99%');
443 // console.log("Max time for solace_extra_import_step4 reached. Progress set to 99%.");
444 }
445 }, maxTime);
446 }
447
448
449
450 remove_data_import();
451 function remove_data_import() {
452 let prevDemo = '';
453 if ( localStorage.getItem('solaceRemoveDataDemo') ) {
454 prevDemo = localStorage.getItem('solaceRemoveDataDemo');
455 } else {
456 prevDemo = 'blank';
457 }
458
459 solace_extra_import_step1();
460
461 if ( localStorage.getItem('solaceRemoveImported') === "remove") {
462 $.ajax({
463 url: ajax_object.ajax_url,
464 type: 'POST',
465 data: {
466 action: 'action-delete-previously-imported',
467 nonce: nonce,
468 prevDemo: prevDemo,
469 },
470 success: function(response) {
471 setImportStatus('Preparing website installation...');
472 $('section.progress-import .mycontainer .boxes .step-import').text('Delete Previously Imported Sites...');
473 // Remove list data demo
474 localStorage.removeItem('solaceRemoveDataDemo');
475 activate_theme();
476 },
477 error: function(xhr, textStatus, errorThrown) {
478 console.log(errorThrown);
479 alert('Error Delete Previously Imported Sites: ' + errorThrown);
480 window.location = pluginUrl.admin_url + 'admin.php?page=dashboard-starter-templates&type=elementor';
481 }
482 });
483 } else {
484 activate_theme();
485 // activate_plugin();
486 }
487 }
488
489 function activate_theme() {
490 $.ajax({
491 url: ajax_object.ajax_url,
492 type: 'POST',
493 data: {
494 action: 'action-install-activate-theme',
495 nonce: nonce,
496 },
497 success: function(response) {
498 console.log(response);
499 // console.log ('Sukses Instal Activate Theme, Now Install & Activate Plugin');
500 activate_plugin();
501 },
502 error: function(xhr, textStatus, errorThrown) {
503 console.log(errorThrown);
504 alert('An error occurred during Theme activation: ' + errorThrown);
505 window.location = pluginUrl.admin_url + 'admin.php?page=dashboard-starter-templates&type=elementor';
506 }
507 });
508 }
509
510 function activate_plugin(){
511 $.ajax({
512 url: ajax_object.ajax_url,
513 type: 'POST',
514 data: {
515 action: 'action-install-activate-plugin',
516 nonce: nonce,
517 getDemo: getParameterByName('demo'),
518 },
519 success: function(response) {
520 clearInterval(stepTextIntervals['step1']);
521 clearInterval(stepIntervals['step1']);
522
523 setTimeout(function() {
524 console.log(response);
525 // console.log ('Sukses Instal Activate Plugin, Now Importing Elementor ZIP');
526 setImportStatus('Importing demo content...');
527 $('section.progress-import .mycontainer .boxes .step-import').text('Importing Content...');
528 import_zip();
529
530 }, 500);
531 },
532 error: function(xhr, textStatus, errorThrown) {
533 console.log(errorThrown);
534 alert('An error occurred during Plugin activation: ' + errorThrown);
535 window.location = pluginUrl.admin_url + 'admin.php?page=dashboard-starter-templates&type=elementor';
536 }
537 });
538 }
539
540 function import_zip() {
541 $('section.progress-import .mycontainer .boxes .box-step-import .percent').text('25%');
542 $('section.progress-import .mycontainer .boxes .boxes-bar .bar1 .progress').attr('style', 'width: 100%;');
543 // console.log("Progress bar for activate_plugin 100%.");
544
545 const maxTime = 360000;
546 const intervalTime = 1000;
547 const totalSteps = maxTime / intervalTime;
548
549 const labelIncrement = 50 / totalSteps;
550 const progressIncrement = 100 / totalSteps;
551
552 let currentLabel = 25;
553 let currentProgress = 0;
554 $('section.progress-import .mycontainer .boxes .boxes-bar .bar2 .progress').css({
555 'transition': 'width 1s ease'
556 });
557
558 $('section.progress-import .mycontainer .boxes .box-step-import .percent').text('25%');
559
560 const progressInterval = setInterval(() => {
561 if (currentProgress < 100) {
562 currentLabel = Math.min(currentLabel + labelIncrement, 100);
563 currentProgress = Math.min(currentProgress + progressIncrement, 100);
564
565 $('section.progress-import .mycontainer .boxes .boxes-bar .bar2 .progress').attr(
566 'style',
567 `width: ${currentProgress.toFixed(2)}%;`
568 );
569
570 $('section.progress-import .mycontainer .boxes .box-step-import .percent').text(
571 `${Math.floor(currentLabel)}%`
572 );
573
574 // console.log(`Progress: ${currentProgress.toFixed(2)}%, Label: ${Math.floor(currentLabel)}%`);
575 }
576 }, intervalTime);
577
578 $.ajax({
579 url: ajax_object.ajax_url,
580 type: 'POST',
581 data: {
582 action: 'action-import-zip',
583 nonce: nonce,
584 getDemoUrl: getParameterByName('url'),
585 getDemoName: getParameterByName('demo'),
586 prevDemo: localStorage.getItem('solaceRemoveDataDemo') || 'blank',
587 },
588 success: function (response) {
589 // console.log("Import ZIP AJAX call succeeded. Response:", response);
590
591 const checkStatusInterval = setInterval(() => {
592 $.ajax({
593 url: ajax_object.ajax_url,
594 type: 'POST',
595 data: {
596 action: 'check_import_status',
597 nonce: nonce
598 },
599 success: function (statusResponse) {
600 if (statusResponse.completed) {
601 console.log("Data import completed.");
602
603 clearInterval(progressInterval);
604 clearInterval(checkStatusInterval);
605
606 $('section.progress-import .mycontainer .boxes .boxes-bar .bar2 .progress').attr(
607 'style',
608 'width: 100%;'
609 );
610 $('section.progress-import .mycontainer .boxes .box-step-import .percent').text('75%');
611
612 proceedToNextStep();
613 }
614 },
615 error: function (xhr, textStatus, errorThrown) {
616 console.error('Error checking import status:', errorThrown);
617 }
618 });
619 }, 5000);
620
621 function proceedToNextStep() {
622 console.log(response);
623 // console.log('Sukses Importing Elementor ZIP, Now Importing Customizer');
624 setImportStatus('Importing customizer...');
625 solace_extra_import_step4();
626 import_menu();
627 }
628 },
629 error: function (xhr, textStatus, errorThrown) {
630 console.error("Error during import_zip:", errorThrown);
631 alert('An error occurred during Content import: ' + errorThrown);
632 window.location = pluginUrl.admin_url + 'admin.php?page=dashboard-starter-templates&type=elementor';
633 }
634 });
635
636 setTimeout(() => {
637 clearInterval(progressInterval);
638 if (currentProgress < 100) {
639 $('section.progress-import .mycontainer .boxes .boxes-bar .bar2 .progress').attr('style', 'width: 100%;');
640 $('section.progress-import .mycontainer .boxes .box-step-import .percent').text('75%');
641 }
642 // console.log("Max time " + maxTime + " for import_zip reached. Proceeding to next step...");
643 solace_extra_import_step4();
644 import_menu();
645 }, maxTime);
646 }
647
648
649 function import_menu() {
650 $('section.progress-import .mycontainer .boxes .box-step-import .percent').text('75%');
651 $('section.progress-import .mycontainer .boxes .boxes-bar .bar2 .progress').attr('style', 'width: 100%;');
652 // console.log("Progress bar for import_zip 100%.");
653
654 $.ajax({
655 url: ajax_object.ajax_url,
656 type: 'POST',
657 data: {
658 action: 'action_import_menu',
659 nonce: nonce,
660 getUrl: getParameterByName('url'),
661 getDemo: getParameterByName('demo'),
662 },
663 success: function (response) {
664 // console.log(response);
665 import_customizer();
666 },
667 // error: function (xhr, status, error) {
668 // console.error('Error importing menu', error);
669 // }
670 error: function(xhr, textStatus, errorThrown) {
671 console.log(errorThrown);
672 alert('An error occurred during menu import: ' + errorThrown);
673 window.location = pluginUrl.admin_url + 'admin.php?page=dashboard-starter-templates&type=elementor';
674 }
675 });
676 }
677
678 function import_customizer() {
679 $.ajax({
680 url: ajax_object.ajax_url,
681 type: 'post',
682 data: {
683 action: 'action-import-customizer',
684 nonce: nonce,
685 getUrl: getParameterByName('url'),
686 getDemo: getParameterByName('demo'),
687 },
688 success: function(response) {
689 console.log(response);
690 // console.log ('Sukses Instal Importing Customizer, NOW Importing Widget');
691 import_widgets();
692 },
693 error: function(xhr, textStatus, errorThrown) {
694 console.log(errorThrown);
695 alert('An error occurred during customizer import: ' + errorThrown);
696 window.location = pluginUrl.admin_url + 'admin.php?page=dashboard-starter-templates&type=elementor';
697 }
698 });
699 }
700
701 function import_widgets() {
702 $.ajax({
703 url: ajax_object.ajax_url,
704 type: 'post',
705 data: {
706 action: 'action-import-widgets',
707 nonce: nonce,
708 getUrl: getParameterByName('url'),
709 getDemo: getParameterByName('demo'),
710 },
711 success: function(response) {
712 $('section.progress-import .mycontainer .boxes .box-step-import .percent').text('100%');
713 $('section.progress-import .mycontainer .boxes .boxes-bar .bar4 .progress').attr('style', 'width: 100%;');
714 // console.log("Progress bar for import_zip 100%.");
715 console.log(response);
716 setImportStatus('Final touches...');
717 clearInterval(solaceExtraStep4Interval);
718 clearTimeout(solaceExtraStep4Timeout);
719
720 setTimeout(function() {
721 window.location = pluginUrl.admin_url + 'admin.php?page=dashboard-congratulations&timestamp=' + new Date().getTime();
722 }, 2000);
723 },
724 error: function(xhr, textStatus, errorThrown) {
725 console.log(errorThrown);
726 alert('An error occurred during widgets import: ' + errorThrown);
727 window.location = pluginUrl.admin_url + 'admin.php?page=dashboard-starter-templates&type=elementor';
728 }
729 });
730 }
731 })( jQuery );
732