GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Branch dev (b24bdb)
by Liuta
05:14
created

admin/js/xcloner-backup-class.js   F

Complexity

Total Complexity 68
Complexity/F 2.83

Size

Lines of Code 459
Function Count 24

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 0
eloc 256
c 1
b 1
f 0
nc 1
dl 0
loc 459
rs 2.96
wmc 68
mnd 2
bc 61
fnc 24
bpm 2.5416
cpm 2.8333
noi 23

20 Functions

Rating   Name   Duplication   Size   Complexity  
B xcloner-backup-class.js ➔ do_backup_encryption_callback 0 35 5
A xcloner-backup-class.js ➔ do_backup_encryption 0 13 2
A xcloner-backup-class.js ➔ do_backup_done 0 11 1
A xcloner-backup-class.js ➔ init_resume 0 5 1
A xcloner-backup-class.js ➔ set_cancel 0 7 2
A xcloner-backup-class.js ➔ constructor 0 10 1
A xcloner-backup-class.js ➔ get_cancel 0 3 1
A xcloner-backup-class.js ➔ start_backup 0 24 1
D xcloner-backup-class.js ➔ do_backup_database_callback 0 57 13
A xcloner-backup-class.js ➔ do_backup_files 0 18 2
A xcloner-backup-class.js ➔ do_backup_database 0 26 2
A xcloner-backup-class.js ➔ get_form_params 0 33 1
A xcloner-backup-class.js ➔ do_scan_filesystem 0 18 1
A xcloner-backup-class.js ➔ do_ajax 0 44 4
A xcloner-backup-class.js ➔ do_scan_filesystem_callback 0 29 5
A xcloner-backup-class.js ➔ do_save_schedule_callback 0 3 1
A xcloner-backup-class.js ➔ getSize 0 3 1
A xcloner-backup-class.js ➔ cancel_backup 0 8 1
F xcloner-backup-class.js ➔ do_backup_files_callback 0 74 14
A xcloner-backup-class.js ➔ restart_backup 0 15 2

How to fix   Complexity   

Complexity

Complex classes like admin/js/xcloner-backup-class.js often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

1
class Xcloner_Backup {
2
3
    constructor() {
4
        this.cancel = 0;
5
        this.params;
0 ignored issues
show
introduced by
The result of the property access to this.params is not used.
Loading history...
6
        this.generate_hash = false;
7
        this.last_dumpfile = "";
8
        this.last_backup_file = ""
9
        this.backup_part = 0
10
        this.backup_size_total = 0;
11
        this.resume = new Object();
12
    }
13
14
    get_form_params() {
15
        var table_params = []
16
        var files_params = []
17
        var extra = []
0 ignored issues
show
Unused Code introduced by
The variable extra seems to be never used. Consider removing it.
Loading history...
18
19
        jQuery.each(jQuery("#jstree_database_container").jstree("get_checked", true), function () {
20
21
            var object = new Object();
22
            object.id = this.id
23
            object.parent = this.parent
24
25
            var index = table_params.length;
26
            table_params[index] = object
27
        });
28
29
        jQuery.each(jQuery("#jstree_files_container").jstree("get_checked", true), function () {
30
            //console.log(this.id+"-"+this.parent);
31
32
            var object = new Object();
33
            object.id = this.id
34
            object.parent = this.parent
35
36
            var index = files_params.length;
37
            files_params[index] = object
38
        });
39
40
        var $return = new Object();
41
        $return.table_params = table_params;
42
        $return.files_params = files_params;
43
        $return.backup_params = jQuery('#generate_backup_form').serializeArray();
44
45
        return $return;
46
    }
47
48
    do_backup_database_callback(elem, action, json) {
49
        if (json.extra)
50
            this.params.extra = json.extra;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
51
52
        if (json.extra.stats) {
53
            if (json.extra.stats.tables_count !== undefined) {
54
                jQuery(elem).find(".table-counter").text(parseInt(json.extra.stats.tables_count));
55
            }
56
57
            if (json.extra.stats.database_count !== undefined) {
58
                jQuery(elem).find(".database-counter").text(parseInt(json.extra.stats.database_count));
59
            }
60
61
            if (json.extra.stats.total_records !== undefined) {
62
                jQuery(elem).find(".total-records").text(parseInt(json.extra.stats.total_records));
63
            }
64
        }
65
66
        if (json.extra.tableName) {
67
            jQuery(elem).find(".last-logged-table").text(json.extra.databaseName + "." + json.extra.tableName + " (" + json.extra.processedRecords + " records)");
68
        }
69
70
        if (json.extra.processedRecords !== undefined && !json.extra.startAtRecord && !json.extra.endDump) {
71
            var records = parseInt(jQuery(elem).find(".total-records").attr('data-processed')) + parseInt(json.extra.processedRecords);
72
73
            var percent = 100 * parseInt(records) / parseInt(jQuery(elem).find(".total-records").text());
74
            jQuery(elem).find('.progress .determinate').css('width', percent + '%');
75
76
            jQuery(elem).find(".total-records").attr('data-processed', records);
77
            jQuery(elem).find(".status-body ul.logged-tables").prepend(jQuery("<li>").text(json.extra.databaseName + "." + json.extra.tableName + " (" + json.extra.processedRecords + " records)"));
78
        }
79
80
        if (json.extra.dumpfile !== undefined) {
81
            var db_text = (json.extra.dumpfile + " (" + this.getSize(json.extra.dumpsize, 1024) + " KB)");
82
83
            if (!jQuery(this.last_dumpfile).hasClass(json.extra.dumpfile)) {
84
                this.last_dumpfile = (jQuery("<li>").addClass(json.extra.dumpfile).html(db_text)).prependTo("ul.logged-databases");
85
            }
86
            else {
87
                jQuery(this.last_dumpfile).html(db_text)
88
            }
89
90
        }
91
92
        if (!json.finished /*&& !this.cancel*/) {
93
94
            this.do_ajax(elem, action);
95
            return false;
96
        }
97
98
99
        jQuery(elem).find(".last-logged-table").text('done');
100
        jQuery(elem).find('.progress .determinate').css('width', '100%');
101
102
        this.do_backup_files();
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
103
104
    }
105
106
    do_backup_database() {
107
        if (!jQuery('#jstree_database_container').length) {
108
            this.do_backup_files();
109
            return;
110
        }
111
112
        /*if(this.cancel)
113
            return false;*/
114
115
        var elem = "#generate_backup ul.backup-status li.database-backup";
116
        jQuery(elem).show();
117
        jQuery(elem + ' .status-body').show();
118
119
        jQuery(elem).find(".total-records").text(0);
120
        jQuery(elem).find(".total-records").attr('data-processed', 0);
121
        jQuery(elem).find(".table-counter").text(0);
122
        jQuery(elem).find(".database-counter").text(0);
123
        jQuery(elem).find(".logged-databases").html("");
124
        jQuery(elem).find(".logged-tables").html("");
125
126
        this.last_dumpfile = 0;
127
128
        jQuery(elem).find('.progress .determinate').css('width', '0%');
129
130
        this.do_ajax(elem, 'backup_database', 1);
131
    }
132
133
    do_scan_filesystem_callback(elem, action, json) {
134
135
        if (json.total_files_num) {
136
            jQuery(".file-system .file-counter").text(parseInt(json.total_files_num) + parseInt(jQuery(".file-system .file-counter").text()));
137
        }
138
139
        if (json.total_files_size) {
140
            var size = parseFloat(json.total_files_size) + parseFloat(jQuery(".file-system .file-size-total").text())
141
            jQuery(".file-system .file-size-total").text(size.toFixed(2));
142
        }
143
144
        if (json.last_logged_file) {
145
            jQuery(".file-system .last-logged-file").text(json.last_logged_file);
146
        }
147
148
        if (!json.finished /*&& !this.cancel*/) {
149
150
            this.do_ajax(elem, action);
151
            return false;
152
        }
153
154
        //finished
155
        jQuery(elem).find('.progress .indeterminate').removeClass('indeterminate').addClass('determinate').css('width', '100%');
156
        jQuery(".file-system .last-logged-file").text('done');
157
158
        //this.do_backup_database();
159
        this.do_backup_database();
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
160
161
    }
162
163
    do_scan_filesystem() {
164
        /*if(this.cancel)
165
            return false;*/
166
167
        var elem = "#generate_backup ul.backup-status li.file-system";
168
        jQuery(elem).show();
169
        jQuery(elem + ' .status-body').show();
170
        jQuery(elem).find('.collapsible-header').trigger('click');
171
172
        jQuery(".file-system .file-counter").text(0);
173
        jQuery(".file-system .last-logged-file").text("");
174
        jQuery(".file-system .file-size-total").text(0);
175
        jQuery('.file-system .progress div').removeClass('determinate').addClass('indeterminate').css('width', '0%');
176
177
178
        this.do_ajax(elem, 'scan_filesystem', 1);
179
180
    }
181
182
    do_backup_files_callback(elem, action, json) {
183
        /*if(this.cancel)
184
            return false;*/
185
186
        if (json.extra) {
187
            this.params.extra = json.extra;
188
        }
189
190
        if (json.extra) {
191
            if (json.extra.start_at_line !== undefined) {
192
                jQuery(elem).find(".file-counter").text(parseInt(json.extra.start_at_line));
193
            }
194
195
            if (json.extra.start_at_line !== undefined) {
196
                //var prev_backup_size = parseInt(jQuery(elem).find(".file-size-total").attr('data-processed'));
197
                jQuery(elem).find(".file-size-total").text(this.getSize(this.backup_size_total + parseInt(json.extra.backup_size)));
198
                //var backup_size = parseInt(json.extra.backup_size);
199
            }
200
201
        }
202
203
        if (json.extra.processed_file) {
204
            if (json.extra.start_at_byte !== undefined && json.extra.start_at_byte) {
205
                var processed_size = json.extra.start_at_byte;
206
            }
207
            else {
208
                var processed_size = json.extra.processed_file_size;
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable processed_size already seems to be declared on line 205. Consider using another variable name or omitting the var keyword.

This check looks for variables that are declared in multiple lines. There may be several reasons for this.

In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.

If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.

Loading history...
209
            }
210
211
            jQuery(elem).find(".last-logged-file").text(json.extra.processed_file + " (" + this.getSize(processed_size, 1024) + " KB)");
212
        }
213
214
        if (json.extra.processed_file !== undefined) {
215
216
            var backup_text = json.extra.backup_archive_name_full + " (" + this.getSize(json.extra.backup_size) + ") MB";
217
218
            if (this.backup_part != json.extra.backup_part) {
219
                this.backup_part = json.extra.backup_part;
220
                this.backup_size_total = this.backup_size_total + json.extra.backup_size;
221
            }
222
223
            if (!jQuery(this.last_backup_file).hasClass(json.extra.backup_archive_name)) {
224
                this.last_backup_file = (jQuery("<li>").addClass(json.extra.backup_archive_name).html(backup_text)).prependTo(jQuery(elem).find(".status-body .backup-name"));
225
            }
226
227
            jQuery(this.last_backup_file).html(backup_text)
228
229
        }
230
231
232
        if (json.extra.lines_total) {
233
            var percent = 100 * parseInt(json.extra.start_at_line) / parseInt(json.extra.lines_total);
234
            jQuery(elem).find('.progress .determinate').css('width', percent + '%');
235
        }
236
237
        if (!json.finished /*&& !this.cancel*/) {
238
239
            this.do_ajax(elem, action);
240
            return false;
241
        }
242
243
        jQuery(elem).find(".last-logged-file").text('done');
244
        jQuery(".backup-done .cloud-upload").attr("href", "#" + json.extra.backup_parent);
245
        jQuery(".backup-done .download").attr("href", "#" + json.extra.backup_parent);
246
        jQuery(".backup-done .list-backup-content").attr("href", "#" + json.extra.backup_parent);
247
248
        if( jQuery('#backup_options #backup_encrypt').is(':checked')) {
249
            this.do_backup_encryption();
250
            return;
0 ignored issues
show
Comprehensibility Best Practice introduced by
Are you sure this return statement is not missing an argument? If this is intended, consider adding an explicit undefined like return undefined;.
Loading history...
251
        }
252
253
        //this.restart_backup();
254
        this.do_backup_done()
255
    }
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
256
257
    do_backup_files() {
258
        if (this.cancel)
259
            return false;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
260
261
        var elem = "#generate_backup ul.backup-status li.files-backup";
262
        jQuery(elem).show();
263
        jQuery(elem + ' .status-body').show();
264
        jQuery(elem).find('.collapsible-header').trigger('click');
265
266
        jQuery(elem).find(".file-size-total").text(0);
267
        jQuery(elem).find(".file-size-total").attr('data-processed', 0);
268
        jQuery(elem).find(".file-counter").text(0);
269
        jQuery(elem).find(".last-logged-file").text("");
270
271
        jQuery(elem).find('.progress .determinate').css('width', '0%');
272
273
        this.do_ajax(elem, 'backup_files', 1);
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
274
    }
275
276
    do_backup_encryption_callback(elem, action, response) {
277
278
        if (response.extra) {
279
            this.params.extra = response.extra;
280
        }
281
282
        jQuery(".backup-encryption .last-logged-file").text('encrypting ' + response.processing_file+' ...');
283
284
        if (response.total_size !== undefined) {
285
            jQuery(".backup-encryption .progress > div").removeClass('indeterminate').addClass("determinate");
286
            var percent = parseInt(response.start * 100) / parseInt(response.total_size)
287
            jQuery(".backup-encryption .progress .determinate").css('width', parseInt(percent) + "%")
288
        }
289
290
        if (response.error) {
291
            jQuery(".backup-encryption .status-body").show();
292
            jQuery(".backup-encryption .status-body").addClass("error").prepend(response.message+" ")
293
            jQuery(".backup-encryption .progress > div").addClass("determinate").removeClass("indeterminate").css('width', "100%")
294
            return;
0 ignored issues
show
Comprehensibility Best Practice introduced by
Are you sure this return statement is not missing an argument? If this is intended, consider adding an explicit undefined like return undefined;.
Loading history...
295
        }
296
297
        if (!response.finished /*&& !this.cancel*/) {
298
299
            this.do_ajax(elem, action);
300
            return false;
301
        }
302
303
        //finished
304
        jQuery(elem).find('.progress > div').css('width', '100%');
305
        jQuery(".backup-encryption .last-logged-file").text('done');
306
307
        //this.do_backup_database();
308
        this.do_backup_done()
309
310
    }
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
311
312
    do_backup_encryption() {
313
        if (this.cancel)
314
            return false;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
315
316
        var elem = "#generate_backup ul.backup-status li.backup-encryption";
317
        jQuery(elem).show();
318
        jQuery(elem + ' .status-body').show();
319
        jQuery(elem).find('.collapsible-header').trigger('click');
320
321
        jQuery(elem).find('.progress .determinate').css('width', '0%');
322
323
        this.do_ajax(elem, 'backup_encryption', 1);
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
324
    }
325
326
    do_backup_done() {
327
        var elem = "#generate_backup ul.backup-status li.backup-done";
328
        jQuery(elem).show();
329
        jQuery(elem + ' .status-body').show();
330
        jQuery(elem).find('.collapsible-header').trigger('click');
331
332
        this.set_cancel(false)
333
        jQuery('#generate_backup .action-buttons a').hide();
334
        jQuery('#generate_backup .action-buttons .start').css('display', 'inline-block');
335
336
    }
337
338
    do_save_schedule_callback(elem, action, json) {
0 ignored issues
show
Unused Code introduced by
The parameter json is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
Unused Code introduced by
The parameter action is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
Unused Code introduced by
The parameter elem is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
339
        jQuery("#schedule_backup_success").show();
340
    }
341
342
    cancel_backup() {
343
        this.set_cancel(true)
344
        jQuery('#generate_backup .action-buttons a').hide();
345
        jQuery('#generate_backup .action-buttons .start').css('display', 'inline-block');
346
        jQuery('#generate_backup .action-buttons .restart').css('display', 'inline-block');
347
348
        //this.restart_backup();
349
    }
350
351
    restart_backup() {
352
        this.set_cancel(false);
353
354
        jQuery('#generate_backup .action-buttons a').hide();
355
        jQuery('#generate_backup .action-buttons .cancel').css('display', 'inline-block');
356
357
        if (this.resume.action) {
358
            //console.log(this.resume.action)
359
            this.do_ajax(this.resume.elem, this.resume.action, this.resume.params);
360
            this.resume = new Object();
361
            return;
362
        }
363
364
        this.start_backup()
365
    }
366
367
    start_backup() {
368
369
        this.resume = new Object()
370
        this.set_cancel(false);
371
        jQuery('#generate_backup .action-buttons a').hide();
372
        jQuery('#generate_backup .action-buttons .cancel').css('display', 'inline-block');
373
374
375
        this.generate_hash = true;
376
        //this.cancel =  false;
377
        this.backup_size_total = 0;
378
        this.last_backup_file = "";
379
        this.backup_part = 0;
380
        jQuery('#generate_backup ul.backup-name li').remove();
381
382
        jQuery('#generate_backup ul.backup-status > li').hide();
383
        jQuery('#generate_backup .backup-status').show();
384
385
        this.params = this.get_form_params();
386
387
388
        this.do_scan_filesystem();
389
390
    }
391
392
    set_cancel(status) {
393
        if (status) {
0 ignored issues
show
Comprehensibility Documentation Best Practice introduced by
This code block is empty. Consider removing it or adding a comment to explain.
Loading history...
394
            //document.dispatchEvent(new CustomEvent("xcloner_restore_update_progress", {detail: {percent: 0, class: 'determinate' }}));
395
            //jQuery("#generate_backup .collapsible-header.active .progress > div").add
396
        }
397
        this.cancel = status
398
    }
399
400
    get_cancel(status) {
0 ignored issues
show
Unused Code introduced by
The parameter status is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
401
        return this.cancel
402
    }
403
404
    init_resume(elem, action, init) {
405
        this.resume.elem = elem
406
        this.resume.action = action
407
        this.resume.init = init
408
    }
409
410
    /** global: ajaxurl */
411
    do_ajax(elem, action, init = 0) {
412
        var hash = '';
413
        if (this.params.hash !== undefined)
414
            hash = this.params.hash;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
415
        else if (this.generate_hash)
416
            hash = 'generate_hash';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
417
418
419
        if (this.cancel == true) {
0 ignored issues
show
Best Practice introduced by
Comparing this.cancel to true using the == operator is not safe. Consider using === instead.
Loading history...
420
            this.init_resume(elem, action, init);
421
            return;
422
        }
423
424
        var callback = 'do_' + action + '_callback';
425
        var data = JSON.stringify(this.params);
426
        var $this = this;
427
428
        jQuery.ajax({
429
            url: ajaxurl,
0 ignored issues
show
Bug introduced by
The variable ajaxurl seems to be never declared. If this is a global, consider adding a /** global: ajaxurl */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
430
            dataType: 'json',
431
            type: 'POST',
432
            data: {'action': action, 'data': data, 'init': init, 'hash': hash, 'API_ID': ID()},
433
            error: function (err) {
434
                show_ajax_error("Communication Error", "", err)
435
                $this.init_resume(elem, action, init);
436
                //console.log(err);
437
            }
438
        }).done(function (json) {
439
            if (json.hash) {
440
                $this.params.hash = json.hash;
441
                //console.log(json.hash);
442
            }
443
            if (json.error !== undefined) {
444
                show_ajax_error("Communication Error", "", json.error_message);
445
                $this.init_resume(elem, action, init);
446
                return;
447
            }
448
449
            $this.resume = new Object();
450
451
            $this[callback](elem, action, json)
452
453
        });
454
    }
455
456
    getSize(bytes, conv = 1024 * 1024) {
457
        return (bytes / conv).toFixed(2);
458
    }
459
}
460