PluginProbe
Welcart e-Commerce / 2.11.31
Welcart e-Commerce v2.11.31
2.12.4 2.12.3 2.11.35 2.12.2 2.12.1 2.11.34 2.11.33 2.11.32 2.11.31 2.11.30 1.3.16 1.3.17 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 All 292 releases
usc-e-shop / includes / importer / js / csv-importer.js

csv-importer.js in Welcart e-Commerce 2.11.31, at includes/importer/js/csv-importer.js

61 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 jQuery(document).ready(function ($) {
2 if ($('#progress-container').length > 0) {
3 window.onbeforeunload = function () {
4 return "インポート処理中です。";
5 };
6
7 function processChunk(offset) {
8 $.ajax({
9 url: wel_csv_importer_data.ajax_url,
10 method: 'POST',
11 data: {
12 action: 'process_csv_chunk',
13 type: window.wel_csv_importer_type,
14 import_id: window.wel_csv_importer_importId,
15 offset: offset,
16 _wpnonce: window.wel_csv_importer_nonce
17 },
18 success: function (res) {
19 if (res.success) {
20 $('#progress-bar').css('width', res.data.percent + '%');
21 $('#progress-text').text(res.data.percent + '%');
22 $('#processed-rows').text(res.data.next_offset);
23 $('#inserted-count').text(res.data.added); // 追加件数を更新
24 $('#updated-count').text(res.data.updated); // 更新件数を更新
25 $('#estimated-time').text(res.data.estimated_time);
26 $('#memory_usage').text(res.data.memory_usage);
27 if (res.data.complete) {
28 // 完了 => 離脱警告解除
29 window.onbeforeunload = null;
30
31 var adminUrl = wel_csv_importer_data.admin_url;
32 if (adminUrl.indexOf('?') === -1) {
33 adminUrl += '?';
34 } else {
35 adminUrl += '&';
36 }
37
38 var redirectUrl = adminUrl +
39 "page=welcart-csv-importer&step=result" +
40 "&type=" + encodeURIComponent((window.wel_csv_importer_type || '').trim()) +
41 "&import_id=" + encodeURIComponent((window.wel_csv_importer_importId || '').trim()) +
42 "&wc_nonce=" + encodeURIComponent((window.wel_csv_complete_nonce || '').trim());
43 window.location.href = redirectUrl;
44 } else {
45 processChunk(res.data.next_offset);
46 }
47 } else {
48 $('#import-result').html('<p style="color:red;">Error: ' + res.data.message + '</p>');
49 }
50 },
51 error: function (xhr, status, error) {
52 $('#import-result').html('<p style="color:red;">AJAXエラー: ' + error + '</p>');
53 }
54 });
55 }
56 // 初期オフセット
57 var initialOffset = wel_csv_importer_data.initial_offset || 0;
58 processChunk(initialOffset);
59 }
60 });
61