Categories: Featured News

THSB Newsletter Sign-Up!

 

Stay connected to everything happening across the Texas high school baseball landscape by signing up for the Texas High School Baseball newsletter. Each week you’ll receive the latest statewide rankings, team and player features, Hitter and Pitcher of the Week selections, playoff updates, and important news from every classification across Texas. Whether you’re a coach, player, parent, or fan, our newsletter keeps you informed with the stories, stats, and highlights that make Texas High School Baseball special.

function getCountryUnicodeFlag(countryCode) { return countryCode.toUpperCase().replace(/./g, (char) => String.fromCodePoint(char.charCodeAt(0) + 127397)) };

// HTML sanitization function to prevent XSS function sanitizeHtml(str) { if (typeof str !== 'string') return ''; return str .replace(/&/g, '&') .replace(//g, '>') .replace(/"/g, '"') .replace(/'/g, ''') .replace(/\//g, '/'); }

// URL sanitization function to prevent javascript: and data: URLs function sanitizeUrl(url) { if (typeof url !== 'string') return ''; const trimmedUrl = url.trim().toLowerCase(); if (trimmedUrl.startsWith('javascript:') || trimmedUrl.startsWith('data:') || trimmedUrl.startsWith('vbscript:')) { return '#'; } return url; }

const getBrowserLanguage = () => { if (!window?.navigator?.language?.split('-')[1]) { return window?.navigator?.language?.toUpperCase(); } return window?.navigator?.language?.split('-')[1]; };

function getDefaultCountryProgram(defaultCountryCode, smsProgramData) { if (!smsProgramData || smsProgramData.length === 0) { return null; }

const browserLanguage = getBrowserLanguage();

if (browserLanguage) { const foundProgram = smsProgramData.find( (program) => program?.countryCode === browserLanguage, ); if (foundProgram) { return foundProgram; } }

if (defaultCountryCode) { const foundProgram = smsProgramData.find( (program) => program?.countryCode === defaultCountryCode, ); if (foundProgram) { return foundProgram; } }

return smsProgramData[0]; }

function updateSmsLegalText(countryCode, fieldName) { if (!countryCode || !fieldName) { return; }

const programs = window?.MC?.smsPhoneData?.programs; if (!programs || !Array.isArray(programs)) { return; }

const program = programs.find(program => program?.countryCode === countryCode); if (!program || !program.requiredTemplate) { return; }

const legalTextElement = document.querySelector('#legal-text-' + fieldName); if (!legalTextElement) { return; }

// Remove HTML tags and clean up the text const divRegex = new RegExp('?[div][^>]*>', 'gi'); const fullAnchorRegex = new RegExp('', 'g'); const anchorRegex = new RegExp('(.*?)');

const template = program.requiredTemplate.replace(divRegex, '');

legalTextElement.textContent = ''; const parts = template.split(/(.*?)/g); parts.forEach(function(part) { if (!part) { return; } const anchorMatch = part.match(/(.*?)/); if (anchorMatch) { const linkElement = document.createElement('a'); linkElement.href = sanitizeUrl(anchorMatch[1]); linkElement.target = sanitizeHtml(anchorMatch[2]); linkElement.textContent = sanitizeHtml(anchorMatch[3]); legalTextElement.appendChild(linkElement); } else { legalTextElement.appendChild(document.createTextNode(part)); } });

}

function generateDropdownOptions(smsProgramData) { if (!smsProgramData || smsProgramData.length === 0) { return ''; }

return smsProgramData.map(program => { const flag = getCountryUnicodeFlag(program.countryCode); const countryName = getCountryName(program.countryCode); const callingCode = program.countryCallingCode || ''; // Sanitize all values to prevent XSS const sanitizedCountryCode = sanitizeHtml(program.countryCode || ''); const sanitizedCountryName = sanitizeHtml(countryName || ''); const sanitizedCallingCode = sanitizeHtml(callingCode || ''); return ''; }).join(''); }

function getCountryName(countryCode) { if (window.MC?.smsPhoneData?.smsProgramDataCountryNames && Array.isArray(window.MC.smsPhoneData.smsProgramDataCountryNames)) { for (let i = 0; i

admin

Share
Published by
admin

Recent Posts