| 1 |
"use strict"; |
| 2 |
/** |
| 3 |
* ===================================================================================================================== |
| 4 |
* includes/__js/wpbc/wpbc.js |
| 5 |
* ===================================================================================================================== |
| 6 |
*/ |
| 7 |
|
| 8 |
/** |
| 9 |
* Deep Clone of object or array |
| 10 |
* |
| 11 |
* @param obj |
| 12 |
* @returns {any} |
| 13 |
*/ |
| 14 |
function wpbc_clone_obj( obj ){ |
| 15 |
|
| 16 |
return JSON.parse( JSON.stringify( obj ) ); |
| 17 |
} |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
/** |
| 22 |
* Main _wpbc JS object |
| 23 |
*/ |
| 24 |
|
| 25 |
var _wpbc = (function ( obj, $) { |
| 26 |
|
| 27 |
// Secure parameters for Ajax ------------------------------------------------------------------------------------ |
| 28 |
var p_secure = obj.security_obj = obj.security_obj || { |
| 29 |
user_id: 0, |
| 30 |
nonce : '', |
| 31 |
locale : '' |
| 32 |
}; |
| 33 |
obj.set_secure_param = function ( param_key, param_val ) { |
| 34 |
p_secure[ param_key ] = param_val; |
| 35 |
}; |
| 36 |
|
| 37 |
obj.get_secure_param = function ( param_key ) { |
| 38 |
return p_secure[ param_key ]; |
| 39 |
}; |
| 40 |
|
| 41 |
|
| 42 |
// Calendars ---------------------------------------------------------------------------------------------------- |
| 43 |
var p_calendars = obj.calendars_obj = obj.calendars_obj || { |
| 44 |
// sort : "booking_id", |
| 45 |
// sort_type : "DESC", |
| 46 |
// page_num : 1, |
| 47 |
// page_items_count: 10, |
| 48 |
// create_date : "", |
| 49 |
// keyword : "", |
| 50 |
// source : "" |
| 51 |
}; |
| 52 |
|
| 53 |
/** |
| 54 |
* Check if calendar for specific booking resource defined :: true | false |
| 55 |
* |
| 56 |
* @param {string|int} resource_id |
| 57 |
* @returns {boolean} |
| 58 |
*/ |
| 59 |
obj.calendar__is_defined = function ( resource_id ) { |
| 60 |
|
| 61 |
return ('undefined' !== typeof( p_calendars[ 'calendar_' + resource_id ] ) ); |
| 62 |
}; |
| 63 |
|
| 64 |
/** |
| 65 |
* Create Calendar initializing |
| 66 |
* |
| 67 |
* @param {string|int} resource_id |
| 68 |
*/ |
| 69 |
obj.calendar__init = function ( resource_id ) { |
| 70 |
|
| 71 |
p_calendars[ 'calendar_' + resource_id ] = {}; |
| 72 |
p_calendars[ 'calendar_' + resource_id ][ 'id' ] = resource_id; |
| 73 |
p_calendars[ 'calendar_' + resource_id ][ 'pending_days_selectable' ] = false; |
| 74 |
|
| 75 |
}; |
| 76 |
|
| 77 |
/** |
| 78 |
* Check if the type of this property is INT |
| 79 |
* @param property_name |
| 80 |
* @returns {boolean} |
| 81 |
*/ |
| 82 |
obj.calendar__is_prop_int = function ( property_name ) { // FixIn: 9.9.0.29. |
| 83 |
|
| 84 |
var p_calendar_int_properties = ['dynamic__days_min', 'dynamic__days_max', 'fixed__days_num']; |
| 85 |
|
| 86 |
var is_include = p_calendar_int_properties.includes( property_name ); |
| 87 |
|
| 88 |
return is_include; |
| 89 |
}; |
| 90 |
|
| 91 |
|
| 92 |
/** |
| 93 |
* Set params for all calendars |
| 94 |
* |
| 95 |
* @param {object} calendars_obj Object { calendar_1: {} } |
| 96 |
* calendar_3: {}, ... } |
| 97 |
*/ |
| 98 |
obj.calendars_all__set = function ( calendars_obj ) { |
| 99 |
p_calendars = calendars_obj; |
| 100 |
}; |
| 101 |
|
| 102 |
/** |
| 103 |
* Get bookings in all calendars |
| 104 |
* |
| 105 |
* @returns {object|{}} |
| 106 |
*/ |
| 107 |
obj.calendars_all__get = function () { |
| 108 |
return p_calendars; |
| 109 |
}; |
| 110 |
|
| 111 |
/** |
| 112 |
* Get calendar object :: { id: 1, … } |
| 113 |
* |
| 114 |
* @param {string|int} resource_id '2' |
| 115 |
* @returns {object|boolean} { id: 2 ,… } |
| 116 |
*/ |
| 117 |
obj.calendar__get_parameters = function ( resource_id ) { |
| 118 |
|
| 119 |
if ( obj.calendar__is_defined( resource_id ) ){ |
| 120 |
|
| 121 |
return p_calendars[ 'calendar_' + resource_id ]; |
| 122 |
} else { |
| 123 |
return false; |
| 124 |
} |
| 125 |
}; |
| 126 |
|
| 127 |
/** |
| 128 |
* Set calendar object :: { dates: Object { "2023-07-21": {…}, "2023-07-22": {…}, "2023-07-23": {…}, … } |
| 129 |
* |
| 130 |
* if calendar object not defined, then it's will be defined and ID set |
| 131 |
* if calendar exist, then system set as new or overwrite only properties from calendar_property_obj parameter, but other properties will be existed and not overwrite, like 'id' |
| 132 |
* |
| 133 |
* @param {string|int} resource_id '2' |
| 134 |
* @param {object} calendar_property_obj { dates: Object { "2023-07-21": {…}, "2023-07-22": {…}, "2023-07-23": {…}, … } } |
| 135 |
* @param {boolean} is_complete_overwrite if 'true' (default: 'false'), then only overwrite or add new properties in calendar_property_obj |
| 136 |
* @returns {*} |
| 137 |
* |
| 138 |
* Examples: |
| 139 |
* |
| 140 |
* Common usage in PHP: |
| 141 |
* echo " _wpbc.calendar__set( " .intval( $resource_id ) . ", { 'dates': " . wp_json_encode( $availability_per_days_arr ) . " } );"; |
| 142 |
*/ |
| 143 |
obj.calendar__set_parameters = function ( resource_id, calendar_property_obj, is_complete_overwrite = false ) { |
| 144 |
|
| 145 |
if ( (!obj.calendar__is_defined( resource_id )) || (true === is_complete_overwrite) ){ |
| 146 |
obj.calendar__init( resource_id ); |
| 147 |
} |
| 148 |
|
| 149 |
for ( var prop_name in calendar_property_obj ){ |
| 150 |
|
| 151 |
p_calendars[ 'calendar_' + resource_id ][ prop_name ] = calendar_property_obj[ prop_name ]; |
| 152 |
} |
| 153 |
|
| 154 |
return p_calendars[ 'calendar_' + resource_id ]; |
| 155 |
}; |
| 156 |
|
| 157 |
/** |
| 158 |
* Set property to calendar |
| 159 |
* @param resource_id "1" |
| 160 |
* @param prop_name name of property |
| 161 |
* @param prop_value value of property |
| 162 |
* @returns {*} calendar object |
| 163 |
*/ |
| 164 |
obj.calendar__set_param_value = function ( resource_id, prop_name, prop_value ) { |
| 165 |
|
| 166 |
if ( (!obj.calendar__is_defined( resource_id )) ){ |
| 167 |
obj.calendar__init( resource_id ); |
| 168 |
} |
| 169 |
|
| 170 |
p_calendars[ 'calendar_' + resource_id ][ prop_name ] = prop_value; |
| 171 |
|
| 172 |
return p_calendars[ 'calendar_' + resource_id ]; |
| 173 |
}; |
| 174 |
|
| 175 |
/** |
| 176 |
* Get calendar property value :: mixed | null |
| 177 |
* |
| 178 |
* @param {string|int} resource_id '1' |
| 179 |
* @param {string} prop_name 'selection_mode' |
| 180 |
* @returns {*|null} mixed | null |
| 181 |
*/ |
| 182 |
obj.calendar__get_param_value = function( resource_id, prop_name ){ |
| 183 |
|
| 184 |
if ( |
| 185 |
( obj.calendar__is_defined( resource_id ) ) |
| 186 |
&& ( 'undefined' !== typeof ( p_calendars[ 'calendar_' + resource_id ][ prop_name ] ) ) |
| 187 |
){ |
| 188 |
// FixIn: 9.9.0.29. |
| 189 |
if ( obj.calendar__is_prop_int( prop_name ) ){ |
| 190 |
p_calendars[ 'calendar_' + resource_id ][ prop_name ] = parseInt( p_calendars[ 'calendar_' + resource_id ][ prop_name ] ); |
| 191 |
} |
| 192 |
return p_calendars[ 'calendar_' + resource_id ][ prop_name ]; |
| 193 |
} |
| 194 |
|
| 195 |
return null; // If some property not defined, then null; |
| 196 |
}; |
| 197 |
// ----------------------------------------------------------------------------------------------------------------- |
| 198 |
|
| 199 |
|
| 200 |
// Bookings ---------------------------------------------------------------------------------------------------- |
| 201 |
var p_bookings = obj.bookings_obj = obj.bookings_obj || { |
| 202 |
// calendar_1: Object { |
| 203 |
// id: 1 |
| 204 |
// , dates: Object { "2023-07-21": {…}, "2023-07-22": {…}, "2023-07-23": {…}, … |
| 205 |
// } |
| 206 |
}; |
| 207 |
|
| 208 |
/** |
| 209 |
* Check if bookings for specific booking resource defined :: true | false |
| 210 |
* |
| 211 |
* @param {string|int} resource_id |
| 212 |
* @returns {boolean} |
| 213 |
*/ |
| 214 |
obj.bookings_in_calendar__is_defined = function ( resource_id ) { |
| 215 |
|
| 216 |
return ('undefined' !== typeof( p_bookings[ 'calendar_' + resource_id ] ) ); |
| 217 |
}; |
| 218 |
|
| 219 |
/** |
| 220 |
* Get bookings calendar object :: { id: 1 , dates: Object { "2023-07-21": {…}, "2023-07-22": {…}, "2023-07-23": {…}, … } |
| 221 |
* |
| 222 |
* @param {string|int} resource_id '2' |
| 223 |
* @returns {object|boolean} { id: 2 , dates: Object { "2023-07-21": {…}, "2023-07-22": {…}, "2023-07-23": {…}, … } |
| 224 |
*/ |
| 225 |
obj.bookings_in_calendar__get = function( resource_id ){ |
| 226 |
|
| 227 |
if ( obj.bookings_in_calendar__is_defined( resource_id ) ){ |
| 228 |
|
| 229 |
return p_bookings[ 'calendar_' + resource_id ]; |
| 230 |
} else { |
| 231 |
return false; |
| 232 |
} |
| 233 |
}; |
| 234 |
|
| 235 |
/** |
| 236 |
* Set bookings calendar object :: { dates: Object { "2023-07-21": {…}, "2023-07-22": {…}, "2023-07-23": {…}, … } |
| 237 |
* |
| 238 |
* if calendar object not defined, then it's will be defined and ID set |
| 239 |
* if calendar exist, then system set as new or overwrite only properties from calendar_obj parameter, but other properties will be existed and not overwrite, like 'id' |
| 240 |
* |
| 241 |
* @param {string|int} resource_id '2' |
| 242 |
* @param {object} calendar_obj { dates: Object { "2023-07-21": {…}, "2023-07-22": {…}, "2023-07-23": {…}, … } } |
| 243 |
* @returns {*} |
| 244 |
* |
| 245 |
* Examples: |
| 246 |
* |
| 247 |
* Common usage in PHP: |
| 248 |
* echo " _wpbc.bookings_in_calendar__set( " .intval( $resource_id ) . ", { 'dates': " . wp_json_encode( $availability_per_days_arr ) . " } );"; |
| 249 |
*/ |
| 250 |
obj.bookings_in_calendar__set = function( resource_id, calendar_obj ){ |
| 251 |
|
| 252 |
if ( ! obj.bookings_in_calendar__is_defined( resource_id ) ){ |
| 253 |
p_bookings[ 'calendar_' + resource_id ] = {}; |
| 254 |
p_bookings[ 'calendar_' + resource_id ][ 'id' ] = resource_id; |
| 255 |
} |
| 256 |
|
| 257 |
for ( var prop_name in calendar_obj ){ |
| 258 |
|
| 259 |
p_bookings[ 'calendar_' + resource_id ][ prop_name ] = calendar_obj[ prop_name ]; |
| 260 |
} |
| 261 |
|
| 262 |
return p_bookings[ 'calendar_' + resource_id ]; |
| 263 |
}; |
| 264 |
|
| 265 |
// Dates |
| 266 |
|
| 267 |
/** |
| 268 |
* Get bookings data for ALL Dates in calendar :: false | { "2023-07-22": {…}, "2023-07-23": {…}, … } |
| 269 |
* |
| 270 |
* @param {string|int} resource_id '1' |
| 271 |
* @returns {object|boolean} false | Object { |
| 272 |
"2023-07-24": Object { ['summary']['status_for_day']: "available", day_availability: 1, max_capacity: 1, … } |
| 273 |
"2023-07-26": Object { ['summary']['status_for_day']: "full_day_booking", ['summary']['status_for_bookings']: "pending", day_availability: 0, … } |
| 274 |
"2023-07-29": Object { ['summary']['status_for_day']: "resource_availability", day_availability: 0, max_capacity: 1, … } |
| 275 |
"2023-07-30": {…}, "2023-07-31": {…}, … |
| 276 |
} |
| 277 |
*/ |
| 278 |
obj.bookings_in_calendar__get_dates = function( resource_id){ |
| 279 |
|
| 280 |
if ( |
| 281 |
( obj.bookings_in_calendar__is_defined( resource_id ) ) |
| 282 |
&& ( 'undefined' !== typeof ( p_bookings[ 'calendar_' + resource_id ][ 'dates' ] ) ) |
| 283 |
){ |
| 284 |
return p_bookings[ 'calendar_' + resource_id ][ 'dates' ]; |
| 285 |
} |
| 286 |
|
| 287 |
return false; // If some property not defined, then false; |
| 288 |
}; |
| 289 |
|
| 290 |
/** |
| 291 |
* Set bookings dates in calendar object :: { "2023-07-21": {…}, "2023-07-22": {…}, "2023-07-23": {…}, … } |
| 292 |
* |
| 293 |
* if calendar object not defined, then it's will be defined and 'id', 'dates' set |
| 294 |
* if calendar exist, then system add a new or overwrite only dates from dates_obj parameter, |
| 295 |
* but other dates not from parameter dates_obj will be existed and not overwrite. |
| 296 |
* |
| 297 |
* @param {string|int} resource_id '2' |
| 298 |
* @param {object} dates_obj { "2023-07-21": {…}, "2023-07-22": {…}, "2023-07-23": {…}, … } |
| 299 |
* @param {boolean} is_complete_overwrite if false, then only overwrite or add dates from dates_obj |
| 300 |
* @returns {*} |
| 301 |
* |
| 302 |
* Examples: |
| 303 |
* _wpbc.bookings_in_calendar__set_dates( resource_id, { "2023-07-21": {…}, "2023-07-22": {…}, … } ); <- overwrite ALL dates |
| 304 |
* _wpbc.bookings_in_calendar__set_dates( resource_id, { "2023-07-22": {…} }, false ); <- add or overwrite only "2023-07-22": {} |
| 305 |
* |
| 306 |
* Common usage in PHP: |
| 307 |
* echo " _wpbc.bookings_in_calendar__set_dates( " . intval( $resource_id ) . ", " . wp_json_encode( $availability_per_days_arr ) . " ); "; |
| 308 |
*/ |
| 309 |
obj.bookings_in_calendar__set_dates = function( resource_id, dates_obj , is_complete_overwrite = true ){ |
| 310 |
|
| 311 |
if ( !obj.bookings_in_calendar__is_defined( resource_id ) ){ |
| 312 |
obj.bookings_in_calendar__set( resource_id, { 'dates': {} } ); |
| 313 |
} |
| 314 |
|
| 315 |
if ( 'undefined' === typeof (p_bookings[ 'calendar_' + resource_id ][ 'dates' ]) ){ |
| 316 |
p_bookings[ 'calendar_' + resource_id ][ 'dates' ] = {} |
| 317 |
} |
| 318 |
|
| 319 |
if (is_complete_overwrite){ |
| 320 |
|
| 321 |
// Complete overwrite all booking dates |
| 322 |
p_bookings[ 'calendar_' + resource_id ][ 'dates' ] = dates_obj; |
| 323 |
} else { |
| 324 |
|
| 325 |
// Add only new or overwrite exist booking dates from parameter. Booking dates not from parameter will be without chnanges |
| 326 |
for ( var prop_name in dates_obj ){ |
| 327 |
|
| 328 |
p_bookings[ 'calendar_' + resource_id ]['dates'][ prop_name ] = dates_obj[ prop_name ]; |
| 329 |
} |
| 330 |
} |
| 331 |
|
| 332 |
return p_bookings[ 'calendar_' + resource_id ]; |
| 333 |
}; |
| 334 |
|
| 335 |
|
| 336 |
/** |
| 337 |
* Get bookings data for specific date in calendar :: false | { day_availability: 1, ... } |
| 338 |
* |
| 339 |
* @param {string|int} resource_id '1' |
| 340 |
* @param {string} sql_class_day '2023-07-21' |
| 341 |
* @returns {object|boolean} false | { |
| 342 |
day_availability: 4 |
| 343 |
max_capacity: 4 // >= Business Large |
| 344 |
2: Object { is_day_unavailable: false, _day_status: "available" } |
| 345 |
10: Object { is_day_unavailable: false, _day_status: "available" } // >= Business Large ... |
| 346 |
11: Object { is_day_unavailable: false, _day_status: "available" } |
| 347 |
12: Object { is_day_unavailable: false, _day_status: "available" } |
| 348 |
} |
| 349 |
*/ |
| 350 |
obj.bookings_in_calendar__get_for_date = function( resource_id, sql_class_day ){ |
| 351 |
|
| 352 |
if ( |
| 353 |
( obj.bookings_in_calendar__is_defined( resource_id ) ) |
| 354 |
&& ( 'undefined' !== typeof ( p_bookings[ 'calendar_' + resource_id ][ 'dates' ] ) ) |
| 355 |
&& ( 'undefined' !== typeof ( p_bookings[ 'calendar_' + resource_id ][ 'dates' ][ sql_class_day ] ) ) |
| 356 |
){ |
| 357 |
return p_bookings[ 'calendar_' + resource_id ][ 'dates' ][ sql_class_day ]; |
| 358 |
} |
| 359 |
|
| 360 |
return false; // If some property not defined, then false; |
| 361 |
}; |
| 362 |
|
| 363 |
|
| 364 |
// Any PARAMS in bookings |
| 365 |
|
| 366 |
/** |
| 367 |
* Set property to booking |
| 368 |
* @param resource_id "1" |
| 369 |
* @param prop_name name of property |
| 370 |
* @param prop_value value of property |
| 371 |
* @returns {*} booking object |
| 372 |
*/ |
| 373 |
obj.booking__set_param_value = function ( resource_id, prop_name, prop_value ) { |
| 374 |
|
| 375 |
if ( ! obj.bookings_in_calendar__is_defined( resource_id ) ){ |
| 376 |
p_bookings[ 'calendar_' + resource_id ] = {}; |
| 377 |
p_bookings[ 'calendar_' + resource_id ][ 'id' ] = resource_id; |
| 378 |
} |
| 379 |
|
| 380 |
p_bookings[ 'calendar_' + resource_id ][ prop_name ] = prop_value; |
| 381 |
|
| 382 |
return p_bookings[ 'calendar_' + resource_id ]; |
| 383 |
}; |
| 384 |
|
| 385 |
/** |
| 386 |
* Get booking property value :: mixed | null |
| 387 |
* |
| 388 |
* @param {string|int} resource_id '1' |
| 389 |
* @param {string} prop_name 'selection_mode' |
| 390 |
* @returns {*|null} mixed | null |
| 391 |
*/ |
| 392 |
obj.booking__get_param_value = function( resource_id, prop_name ){ |
| 393 |
|
| 394 |
if ( |
| 395 |
( obj.bookings_in_calendar__is_defined( resource_id ) ) |
| 396 |
&& ( 'undefined' !== typeof ( p_bookings[ 'calendar_' + resource_id ][ prop_name ] ) ) |
| 397 |
){ |
| 398 |
return p_bookings[ 'calendar_' + resource_id ][ prop_name ]; |
| 399 |
} |
| 400 |
|
| 401 |
return null; // If some property not defined, then null; |
| 402 |
}; |
| 403 |
|
| 404 |
|
| 405 |
|
| 406 |
|
| 407 |
/** |
| 408 |
* Set bookings for all calendars |
| 409 |
* |
| 410 |
* @param {object} calendars_obj Object { calendar_1: { id: 1, dates: Object { "2023-07-22": {…}, "2023-07-23": {…}, "2023-07-24": {…}, … } } |
| 411 |
* calendar_3: {}, ... } |
| 412 |
*/ |
| 413 |
obj.bookings_in_calendars__set_all = function ( calendars_obj ) { |
| 414 |
p_bookings = calendars_obj; |
| 415 |
}; |
| 416 |
|
| 417 |
/** |
| 418 |
* Get bookings in all calendars |
| 419 |
* |
| 420 |
* @returns {object|{}} |
| 421 |
*/ |
| 422 |
obj.bookings_in_calendars__get_all = function () { |
| 423 |
return p_bookings; |
| 424 |
}; |
| 425 |
// ----------------------------------------------------------------------------------------------------------------- |
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
// Seasons ---------------------------------------------------------------------------------------------------- |
| 431 |
var p_seasons = obj.seasons_obj = obj.seasons_obj || { |
| 432 |
// calendar_1: Object { |
| 433 |
// id: 1 |
| 434 |
// , dates: Object { "2023-07-21": {…}, "2023-07-22": {…}, "2023-07-23": {…}, … |
| 435 |
// } |
| 436 |
}; |
| 437 |
|
| 438 |
/** |
| 439 |
* Add season names for dates in calendar object :: { "2023-07-21": [ 'wpbc_season_september_2023', 'wpbc_season_september_2024' ], "2023-07-22": [...], ... } |
| 440 |
* |
| 441 |
* |
| 442 |
* @param {string|int} resource_id '2' |
| 443 |
* @param {object} dates_obj { "2023-07-21": {…}, "2023-07-22": {…}, "2023-07-23": {…}, … } |
| 444 |
* @param {boolean} is_complete_overwrite if false, then only add dates from dates_obj |
| 445 |
* @returns {*} |
| 446 |
* |
| 447 |
* Examples: |
| 448 |
* _wpbc.seasons__set( resource_id, { "2023-07-21": [ 'wpbc_season_september_2023', 'wpbc_season_september_2024' ], "2023-07-22": [...], ... } ); |
| 449 |
*/ |
| 450 |
obj.seasons__set = function( resource_id, dates_obj , is_complete_overwrite = false ){ |
| 451 |
|
| 452 |
if ( 'undefined' === typeof (p_seasons[ 'calendar_' + resource_id ]) ){ |
| 453 |
p_seasons[ 'calendar_' + resource_id ] = {}; |
| 454 |
} |
| 455 |
|
| 456 |
if ( is_complete_overwrite ){ |
| 457 |
|
| 458 |
// Complete overwrite all season dates |
| 459 |
p_seasons[ 'calendar_' + resource_id ] = dates_obj; |
| 460 |
|
| 461 |
} else { |
| 462 |
|
| 463 |
// Add only new or overwrite exist booking dates from parameter. Booking dates not from parameter will be without chnanges |
| 464 |
for ( var prop_name in dates_obj ){ |
| 465 |
|
| 466 |
if ( 'undefined' === typeof (p_seasons[ 'calendar_' + resource_id ][ prop_name ]) ){ |
| 467 |
p_seasons[ 'calendar_' + resource_id ][ prop_name ] = []; |
| 468 |
} |
| 469 |
for ( var season_name_key in dates_obj[ prop_name ] ){ |
| 470 |
p_seasons[ 'calendar_' + resource_id ][ prop_name ].push( dates_obj[ prop_name ][ season_name_key ] ); |
| 471 |
} |
| 472 |
} |
| 473 |
} |
| 474 |
|
| 475 |
return p_seasons[ 'calendar_' + resource_id ]; |
| 476 |
}; |
| 477 |
|
| 478 |
|
| 479 |
/** |
| 480 |
* Get bookings data for specific date in calendar :: [] | [ 'wpbc_season_september_2023', 'wpbc_season_september_2024' ] |
| 481 |
* |
| 482 |
* @param {string|int} resource_id '1' |
| 483 |
* @param {string} sql_class_day '2023-07-21' |
| 484 |
* @returns {object|boolean} [] | [ 'wpbc_season_september_2023', 'wpbc_season_september_2024' ] |
| 485 |
*/ |
| 486 |
obj.seasons__get_for_date = function( resource_id, sql_class_day ){ |
| 487 |
|
| 488 |
if ( |
| 489 |
( 'undefined' !== typeof ( p_seasons[ 'calendar_' + resource_id ] ) ) |
| 490 |
&& ( 'undefined' !== typeof ( p_seasons[ 'calendar_' + resource_id ][ sql_class_day ] ) ) |
| 491 |
){ |
| 492 |
return p_seasons[ 'calendar_' + resource_id ][ sql_class_day ]; |
| 493 |
} |
| 494 |
|
| 495 |
return []; // If not defined, then []; |
| 496 |
}; |
| 497 |
|
| 498 |
|
| 499 |
// Other parameters ------------------------------------------------------------------------------------ |
| 500 |
var p_other = obj.other_obj = obj.other_obj || { }; |
| 501 |
|
| 502 |
obj.set_other_param = function ( param_key, param_val ) { |
| 503 |
p_other[ param_key ] = param_val; |
| 504 |
}; |
| 505 |
|
| 506 |
obj.get_other_param = function ( param_key ) { |
| 507 |
return p_other[ param_key ]; |
| 508 |
}; |
| 509 |
|
| 510 |
/** |
| 511 |
* Get all other params |
| 512 |
* |
| 513 |
* @returns {object|{}} |
| 514 |
*/ |
| 515 |
obj.get_other_param__all = function () { |
| 516 |
return p_other; |
| 517 |
}; |
| 518 |
|
| 519 |
// Messages ------------------------------------------------------------------------------------ |
| 520 |
var p_messages = obj.messages_obj = obj.messages_obj || { }; |
| 521 |
|
| 522 |
obj.set_message = function ( param_key, param_val ) { |
| 523 |
p_messages[ param_key ] = param_val; |
| 524 |
}; |
| 525 |
|
| 526 |
obj.get_message = function ( param_key ) { |
| 527 |
return p_messages[ param_key ]; |
| 528 |
}; |
| 529 |
|
| 530 |
/** |
| 531 |
* Get all other params |
| 532 |
* |
| 533 |
* @returns {object|{}} |
| 534 |
*/ |
| 535 |
obj.get_messages__all = function () { |
| 536 |
return p_messages; |
| 537 |
}; |
| 538 |
|
| 539 |
// ----------------------------------------------------------------------------------------------------------------- |
| 540 |
|
| 541 |
return obj; |
| 542 |
|
| 543 |
}( _wpbc || {}, jQuery )); |
| 544 |
|