1function wisdm_reports_format_course_revenue_response( 2 currentRevenue, 3 pastRevenue 4) { 5 const revenueData = []; 6 const currentCourseIds = 7 typeof currentRevenue === 'object' && null != currentRevenue 8 ? Object.keys( currentRevenue ) 9 : []; 10 const pastCourseIds = 11 typeof pastRevenue === 'object' && null != pastRevenue 12 ? Object.keys( pastRevenue ) 13 : []; 14 const coursesToShow = currentCourseIds; 15 16 if ( pastCourseIds.length > 0 ) { 17 pastCourseIds.forEach( ( element ) => { 18 if ( ! coursesToShow.includes( element ) ) { 19 coursesToShow.push( element ); 20 } 21 } ); 22 } 23 24 if ( coursesToShow.length > 0 ) { 25 revenueData.titles = []; 26 revenueData.past_revenues = []; 27 revenueData.current_revenues = []; 28 coursesToShow.forEach( ( courseId ) => { 29 if ( undefined != currentRevenue[ courseId ] ) { 30 revenueData.titles.push( currentRevenue[ courseId ].title ); 31 revenueData.current_revenues.push( 32 currentRevenue[ courseId ].total 33 ); 34 revenueData.past_revenues.push( 35 undefined != pastRevenue[ courseId ] 36 ? pastRevenue[ courseId ].total 37 : 0 38 ); 39 } else if ( undefined != pastRevenue[ courseId ] ) { 40 revenueData.titles.push( pastRevenue[ courseId ].title ); 41 revenueData.past_revenues.push( pastRevenue[ courseId ].total ); 42 revenueData.current_revenues.push( 0 ); 43 } 44 } ); 45 } 46 47 return revenueData; 48} 49 50function wisdm_reports_change_block_visibility( 51 elementSelector, 52 visible = true, 53 parent_element = undefined 54) { 55 if ( undefined != parent_element ) { 56 elementSelector = jQuery( elementSelector ).closest( parent_element ); 57 } 58 59 if ( visible ) { 60 jQuery( elementSelector ).show(); 61 } else { 62 jQuery( elementSelector ).hide(); 63 } 64} 65 66// cspell:disable-next-line 67function wisdm_reports_get_ld_custom_lebel_if_avaiable( ld_entity, caseVersion = 'normal' ) { 68 const custom_label = ''; 69 70 if ( 71 undefined === ld_entity 72 || typeof ld_entity !== 'string' 73 ) { 74 return custom_label; 75 } 76 77 labelKey = ld_entity.toLowerCase(); 78 79 if ( caseVersion === 'lower' ) { 80 return wisdm_ld_reports_common_script_data.ld_custom_labels_lower[ 81 labelKey 82 ]; 83 } 84 85 return wisdm_ld_reports_common_script_data.ld_custom_labels[ 86 labelKey 87 ]; 88} 89 90function wrld_output_resize() { 91 jQuery( '.wrld-mw-1400' ).removeClass( 'wrld-xl' ); 92 jQuery( '.wrld-mw-1400' ).removeClass( 'wrld-lg' ); 93 jQuery( '.wrld-mw-1400' ).removeClass( 'wrld-m' ); 94 jQuery( '.wrld-mw-1400' ).removeClass( 'wrld-s' ); 95 jQuery( '.wrld-mw-1400' ).removeClass( 'wrld-xs' ); 96 const width = jQuery( '.wrld-mw-1400' ).width(); 97 98 if ( width > 1199 ) { 99 jQuery( '.wrld-mw-1400' ).addClass( 'wrld-xl' ); 100 } else if ( width > 992 ) { 101 jQuery( '.wrld-mw-1400' ).addClass( 'wrld-lg' ); 102 } else if ( width > 768 ) { 103 jQuery( '.wrld-mw-1400' ).addClass( 'wrld-m' ); 104 } else if ( width > 584 ) { 105 jQuery( '.wrld-mw-1400' ).addClass( 'wrld-s' ); 106 } else { 107 jQuery( '.wrld-mw-1400' ).addClass( 'wrld-xs' ); 108 } 109} 110 111document.addEventListener( 'DOMContentLoaded', function ( event ) { 112 if ( document.querySelectorAll( '.wrld-mw-1400' ).length > 0 ) { 113 const wrldResizeObserver = new ResizeObserver( 114 wrld_output_resize 115 ).observe( document.querySelectorAll( '.wrld-mw-1400' )[ 0 ] ); 116 const width = jQuery( '.wrld-mw-1400' ).width(); 117 jQuery( '.wrld-mw-1400' ).removeClass( 'wrld-xl' ); 118 jQuery( '.wrld-mw-1400' ).removeClass( 'wrld-lg' ); 119 jQuery( '.wrld-mw-1400' ).removeClass( 'wrld-m' ); 120 jQuery( '.wrld-mw-1400' ).removeClass( 'wrld-s' ); 121 jQuery( '.wrld-mw-1400' ).removeClass( 'wrld-xs' ); 122 if ( width > 1199 ) { 123 jQuery( '.wrld-mw-1400' ).addClass( 'wrld-xl' ); 124 } else if ( width > 992 ) { 125 jQuery( '.wrld-mw-1400' ).addClass( 'wrld-lg' ); 126 } else if ( width > 768 ) { 127 jQuery( '.wrld-mw-1400' ).addClass( 'wrld-m' ); 128 } else if ( width > 584 ) { 129 jQuery( '.wrld-mw-1400' ).addClass( 'wrld-s' ); 130 } else { 131 jQuery( '.wrld-mw-1400' ).addClass( 'wrld-xs' ); 132 } 133 } 134 135 if ( typeof wp === 'undefined' || typeof wp.data === 'undefined' ) { 136 return; 137 } 138 139 //Show notice on the edit page 140 if ( wisdm_ld_reports_common_script_data.page_configuration_status ) { 141 if ( document.getElementsByClassName( 'wrld-notice' ).length == 0 ) { 142 ( function ( wp ) { 143 wp.data.dispatch( 'core/notices' ).createNotice( 144 'success', // Can be one of: success, info, warning, error. 145 '<div class="wrld-notice"><span>' + 146 wisdm_ld_reports_common_script_data.notice_content 147 .header + 148 '</span><ul> <li>' + 149 wisdm_ld_reports_common_script_data.notice_content 150 .li_1 + 151 '</li> <li>' + 152 wisdm_ld_reports_common_script_data.notice_content 153 .li_2 + 154 '</li><li>' + 155 wisdm_ld_reports_common_script_data.notice_content 156 .li_3 + 157 '</li><ul></div>', 158 { 159 __unstableHTML: true, 160 isDismissible: true, // Whether the user can dismiss the notice. 161 } 162 ); 163 } )( window.wp ); 164 } 165 } 166 if ( 167 wisdm_ld_reports_common_script_data.page_student_configuration_status 168 ) { 169 if ( document.getElementsByClassName( 'wrld-notice' ).length == 0 ) { 170 ( function ( wp ) { 171 wp.data.dispatch( 'core/notices' ).createNotice( 172 'success', // Can be one of: success, info, warning, error. 173 '<div class="wrld-notice"><span>' + 174 wisdm_ld_reports_common_script_data 175 .notice_student_content.header + 176 '</span><ul> <li>' + 177 wisdm_ld_reports_common_script_data 178 .notice_student_content.li_1 + 179 '</li> <li>' + 180 wisdm_ld_reports_common_script_data 181 .notice_student_content.li_2 + 182 '</li><ul></div>', 183 { 184 __unstableHTML: true, 185 isDismissible: true, // Whether the user can dismiss the notice. 186 } 187 ); 188 } )( window.wp ); 189 } 190 } 191 192 if ( 193 typeof wp.data !== 'undefined' 194 && typeof wp.data.select( 'core/editor' ) !== 'undefined' 195 ) { 196 const { isSavingPost } = wp.data.select( 'core/editor' ); 197 198 let checked = true, 199 checked2 = true; // Start in a checked state. 200 wp.data.subscribe( () => { 201 if ( isSavingPost() ) { 202 checked = false;
203 } else if ( ! checked ) { 204 if ( 205 'publish' == 206 wp.data 207 .select( 'core/editor' ) 208 .getEditedPostAttribute( 'status' ) && 209 wisdm_ld_reports_common_script_data.dashboard_page_id == 210 wp.data 211 .select( 'core/editor' ) 212 .getEditedPostAttribute( 'id' ) && 213 ( wisdm_ld_reports_common_script_data.visited_dashboard == 214 false || 215 wisdm_ld_reports_common_script_data.visited_dashboard == 216 'free' ) 217 ) { 218 window.location.href = wp.data 219 .select( 'core/editor' ) 220 .getEditedPostAttribute( 'link' ); 221 } 222 checked = true; 223 } 224 } ); 225 226 wp.data.subscribe( () => { 227 if ( isSavingPost() ) { 228 checked2 = false; 229 } else if ( ! checked2 ) { 230 if ( 231 'publish' == 232 wp.data 233 .select( 'core/editor' ) 234 .getEditedPostAttribute( 'status' ) && 235 wisdm_ld_reports_common_script_data.student_page_id == 236 wp.data 237 .select( 'core/editor' ) 238 .getEditedPostAttribute( 'id' ) && 239 wisdm_ld_reports_common_script_data.visited_student_dashboard == 240 false 241 ) { 242 window.location.href = wp.data 243 .select( 'core/editor' ) 244 .getEditedPostAttribute( 'link' ); 245 } 246 checked2 = true; 247 } 248 } ); 249 } 250} );
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.