1
1
// global vars
2
- var hooks = [ ] ;
3
- var call_stack = [ ] ;
4
- var non_fatal_errors = '' ;
5
- var migration_error = false ;
6
- var connection_data ;
7
- var next_step_in_migration ;
2
+ var wpmdb = wpmdb || { } ;
3
+ wpmdb . common = {
4
+ hooks : [ ] ,
5
+ call_stack : [ ] ,
6
+ non_fatal_errors : '' ,
7
+ migration_error : false
8
+ } ;
9
+ wpmdb . functions = { } ;
8
10
9
11
/**
10
12
* Toggle proper translated strings based on migration type selected.
@@ -32,25 +34,25 @@ function wpmdb_migration_type() {
32
34
}
33
35
34
36
function wpmdb_call_next_hook ( ) {
35
- if ( ! call_stack . length ) {
36
- call_stack = hooks ;
37
+ if ( ! wpmdb . common . call_stack . length ) {
38
+ wpmdb . common . call_stack = wpmdb . common . hooks ;
37
39
}
38
40
39
- var func = call_stack [ 0 ] ;
40
- call_stack . shift ( ) ;
41
- window [ func ] ( ) ; // Uses the string from the array to call the function of the same name
41
+ var func = wpmdb . common . call_stack [ 0 ] ;
42
+ wpmdb . common . call_stack . shift ( ) ;
43
+ func . call ( this ) ;
42
44
}
43
45
44
46
function wpmdb_add_commas ( number_string ) {
45
47
number_string += '' ;
46
- var x = number_string . split ( '.' ) ;
47
- var x1 = x [ 0 ] ;
48
- var x2 = x . length > 1 ? '.' + x [ 1 ] : '' ;
48
+ var number_parts = number_string . split ( '.' ) ;
49
+ var integer = number_parts [ 0 ] ;
50
+ var decimal = 1 < number_parts . length ? '.' + number_parts [ 1 ] : '' ;
49
51
var rgx = / ( \d + ) ( \d { 3 } ) / ;
50
- while ( rgx . test ( x1 ) ) {
51
- x1 = x1 . replace ( rgx , '$1' + ',' + '$2' ) ;
52
+ while ( rgx . test ( integer ) ) {
53
+ integer = integer . replace ( rgx , '$1' + ',' + '$2' ) ;
52
54
}
53
- return x1 + x2 ;
55
+ return integer + decimal ;
54
56
}
55
57
56
58
function wpmdb_parse_json ( maybe_json ) {
@@ -59,7 +61,8 @@ function wpmdb_parse_json( maybe_json ) {
59
61
json_object = jQuery . parseJSON ( maybe_json ) ;
60
62
}
61
63
catch ( e ) {
62
- // we simply return false here because the json data itself will never just contain a value of "false"
64
+
65
+ // We simply return false here because the json data itself will never just contain a value of "false"
63
66
return false ;
64
67
}
65
68
return json_object ;
@@ -91,12 +94,12 @@ function wpmdbGetAjaxErrors( title, code, text, jqXHR ) {
91
94
}
92
95
93
96
// Only add local connection issue if php errors (#144) or jqXHR has been provided
94
- if ( jsonErrors || jqXHR !== undefined ) {
97
+ if ( jsonErrors || 'undefined' !== jqXHR ) {
95
98
html += '<strong>' + title + '</strong>' + ' — ' ;
96
99
}
97
100
98
101
// Only add extra error details if not php errors (#144) and jqXHR has been provided
99
- if ( ! jsonErrors && jqXHR !== undefined ) {
102
+ if ( ! jsonErrors && 'undefined' !== jqXHR ) {
100
103
html += wpmdb_strings . status + ': ' + jqXHR . status + ' ' + jqXHR . statusText ;
101
104
html += '<br /><br />' + wpmdb_strings . response + ':<br />' ;
102
105
}
@@ -113,5 +116,7 @@ function wpmdbGetAjaxErrors( title, code, text, jqXHR ) {
113
116
}
114
117
115
118
( function ( $ ) {
119
+
116
120
// jQuery code here
121
+
117
122
} ) ( jQuery ) ;
0 commit comments