1var _glf_setInterval = setInterval( function () { 2 let openingData = jQuery( "#glf-opening-data" ); 3 if( openingData.length > 0 ){ 4 //clearInterval( _glf_setInterval ); 5 window.opening_types = JSON.parse( openingData.find( ".types" ).text() ); 6 window.openingHours = JSON.parse( openingData.find( ".hours" ).text() ); 7 window.openingCountryCode = openingData.find( ".country" ).text(); 8 window.openingDays = JSON.parse( openingData.find( ".days" ).text() ); 9 openingData.remove(); 10 window.runOpeningHours(); 11 } 12 }, 13 300 ); 14function runOpeningHours(){ 15 let opening_hours = processOpeningHours( window.openingHours ); 16 const elements = jQuery( '.glf-widget-opening-hours .content' ); 17 for (const element of elements) { 18 if (element.innerText === '') { 19 element.innerHTML = opening_hours; 20 } 21 } 22} 23 24function processOpeningHours( openingHoursData ) { 25 let html = '', 26 h_tag = 'h2'; 27 if( openingHoursData && ( typeof openingHoursData === 'object' ) ) { 28 jQuery.each( openingHoursData, function ( key, openingHoursArr ) { 29 html += '<' + h_tag + ' class="glf-open-type ' + key + '">'; 30 html += ( key in opening_types ) ? opening_types[key] : key; 31 html += '</' + h_tag + '>'; 32 33 if( openingHoursArr && Array.isArray( openingHoursArr ) && openingHoursArr.length ) { 34 openingHoursArr.forEach( ( elem ) => { 35 html += '<div class="glf-opening-entry">' + 36 '<div class="glf-week-days">' + getDaysString( numberToDaysOfWeek( elem.day_of_week ) ) + '</div>' + 37 '<div>' + getTimeString( elem.begin_minute, openingCountryCode ) + ' - ' + getTimeString( elem.end_minute, openingCountryCode ) + '</div>' + 38 '</div>'; 39 } ); 40 } 41 42 h_tag = 'h3'; 43 } ); 44 } 45 46 return html; 47} 48 49function getDaysString( daysArr ) { 50 let result, iStart, iEnd; 51 52 daysArr.forEach( ( key ) => { 53 if( typeof iStart === 'undefined' ) { 54 iStart = key; 55 iEnd = key; 56 } else { 57 if( key === iEnd + 1 ) { 58 iEnd = key; 59 } else { 60 result = result ? result + ', ' : ''; 61 if( iStart === iEnd ) { 62 result += openingDays[iStart]; 63 } else { 64 result += openingDays[iStart] + ' - ' + openingDays[iEnd]; 65 } 66 iStart = key; 67 iEnd = key; 68 } 69 } 70 } ); 71 72 result = result ? result + ', ' : ''; 73 if( iStart === iEnd ) { 74 result += openingDays[iStart]; 75 } else { 76 result += openingDays[iStart] + ' - ' + openingDays[iEnd]; 77 } 78 79 return result; 80} 81 82function getTimeString( minutes, countryCode ) { 83 let h = Math.floor( minutes / 60 ), 84 m = minutes % 60, 85 isPm = h >= 12 && h < 24, 86 is12h = [ 'US', 'DO', 'UK', 'PH', 'CA', 'AU', 'NZ', 'IN', 'EG', 'SA', 'CO', 'PK', 'MY', 'PG', 'SG', 'ZA', 'VN', 'PR' ].includes( countryCode ); 87 88 h = is12h ? ( h % 12 === 0 ? 12 : h % 12 ) : h % 24; 89 90 return padLeft( h ) + ':' + padLeft( m ) + ( is12h ? ( isPm ? ' PM' : ' AM' ) : '' ); 91} 92 93function numberToDaysOfWeek( nr ) { 94 const result = []; 95 96 [ 0, 1, 2, 3, 4, 5, 6 ].forEach( key => { 97 if( nr & Math.pow( 2, key ) ) { 98 result.push( key ); 99 } 100 } ); 101 return result; 102} 103 104function padLeft( time ) { 105 return ( '00' ).substring( time.toString().length ) + time; 106}
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.