PageSourceSearch

https://fitnessgeek.ai/wp-content/cache/autoptimize/js/autoptimize…eeb62e80917773913bb019bbc6cc72.js?ver=1.0.0

js fitnessgeek.ai collected 2026-10-05 15:33:26 UTC 6,993 bytes, 60 lines download raw bytes

1jQuery(document).ready(function($){class FitzyWidget{constructor(element){this.widget=$(element);this.isLoading=false;this.currentContent=null;this.init();}
2init(){this.bindEvents();this.loadContent();}
3bindEvents(){this.widget.find('#fitzy-refresh').on('click',(e)=>{e.preventDefault();this.loadContent(true);});$(document).on('visibilitychange',()=>{if(!document.hidden&&this.shouldAutoRefresh()){this.loadContent();}});}
4shouldAutoRefresh(){if(!this.lastLoadTime)return true;const oneHour=60*60*1000;return(Date.now()-this.lastLoadTime)>oneHour;}
5loadContent(forceRefresh=false){if(this.isLoading&&!forceRefresh)return;this.isLoading=true;this.showLoading();const data={action:'get_fitzy_content',nonce:fitzy_ajax.nonce,force_refresh:forceRefresh?1:0};$.ajax({url:fitzy_ajax.ajax_url,type:'POST',data:data,timeout:10000,success:(response)=>{this.handleContentSuccess(response);},error:(xhr,status,error)=>{this.handleContentError(error);},complete:()=>{this.isLoading=false;this.lastLoadTime=Date.now();}});}
6handleContentSuccess(response){if(response.success&&response.data){this.currentContent=response.data;this.displayContent(response.data);this.saveContentToCache(response.data);}else{this.handleContentError(response.data||'Unknown error');}}
7handleContentError(error){console.error('Fitzy content load error:',error);const cachedContent=this.getContentFromCache();if(cachedContent){this.displayContent(cachedContent);this.showMessage('Using cached content (offline mode)','warning');}else{this.showFallbackContent();}}
8displayContent(content){this.hideLoading();const settings=this.getDisplaySettings();this.widget.find('#fitzy-day-number').text(content.day||'1');this.toggleSection('greeting',content.greeting,settings.show_greeting);this.toggleSection('affirmation',content.affirmation,settings.show_affirmation);this.toggleSection('tip',content.tip,settings.show_tip);this.toggleSection('encouragement',content.encouragement,settings.show_encouragement);this.widget.trigger('fitzy:content-loaded',[content]);}
9toggleSection(sectionName,text,shouldShow){const section=this.widget.find(`.fitzy-${sectionName}`);if(shouldShow==='true'&&text){section.find('.fitzy-text').text(text);section.fadeIn(300);}else{section.hide();}}
10getDisplaySettings(){return{show_greeting:this.widget.data('show-greeting')||'true',show_affirmation:this.widget.data('show-affirmation')||'true',show_tip:this.widget.data('show-tip')||'true',show_encouragement:this.widget.data('show-encouragement')||'true'};}
11showLoading(){this.widget.addClass('loading');this.widget.find('.fitzy-section').fadeOut(200);}
12hideLoading(){this.widget.removeClass('loading');}
13showFallbackContent(){this.hideLoading();const fallbackContent={greeting:"Hey there! I'm having trouble connecting right now.",affirmation:"You're amazing just as you are. Keep being awesome!",tip:"Remember to stay hydrated and take breaks throughout your day.",encouragement:"I believe in you, even when the wifi doesn't! 💪",day:1};this.displayContent(fallbackContent);this.showMessage('Connection issue - showing offline content','error');}
14showMessage(message,type='info'){const messageClass=`fitzy-message fitzy-message-${type}`;const messageHtml=`<div class="${messageClass}">${message}</div>`;this.widget.find('.fitzy-message').remove();this.widget.find('.fitzy-content').prepend(messageHtml);setTimeout(()=>{this.widget.find('.fitzy-message').fadeOut(300,function(){$(this).remove();});},5000);}
15saveContentToCache(content){if(typeof(Storage)!=="undefined"){const cacheData={content:content,timestamp:Date.now(),version:'1.0'};try{localStorage.setItem('fitzy_content_cache',JSON.stringify(cacheData));}catch(e){console.warn('Could not save Fitzy content to cache:',e);}}}
16getContentFromCache(){if(typeof(Storage)==="undefined")return null;try{const cached=localStorage.getItem('fitzy_content_cache');if(!cached)return null;const cacheData=JSON.parse(cached);const twentyFourHours=24*60*60*1000;if(Date.now()-cacheData.timestamp>twentyFourHours){localStorage.removeItem('fitzy_content_cache');return null;}
17return cacheData.content;}catch(e){console.warn('Could not read Fitzy content from cache:',e);localStorage.removeItem('fitzy_content_cache');return null;}}
18refresh(){this.loadContent(true);}
19getCurrentContent(){return this.currentContent;}
20updateTheme(themeName){this.widget.removeClass((index,className)=>{return(className.match(/(^|\s)fitzy-theme-\S+/g)||[]).join(' ');});this.widget.addClass(`fitzy-theme-${themeName}`);}}
21const messageStyles=`
22        .fitzy-message {
23            padding: 10px 15px;
24            border-radius: 10px;
25            margin-bottom: 15px;
26            font-size: 0.85em;
27            text-align: center;
28            animation: slideDown 0.3s ease-out;
29        }
30        
31        .fitzy-message-info {
32            background: rgba(52, 152, 219, 0.2);
33            border: 1px solid rgba(52, 152, 219, 0.3);
34            color: #3498db;
35        }
36        
37        .fitzy-message-warning {
38            background: rgba(243, 156, 18, 0.2);
39            border: 1px solid rgba(243, 156, 18, 0.3);
40            color: #f39c12;
41        }
42        
43        .fitzy-message-error {
44            background: rgba(231, 76, 60, 0.2);
45            border: 1px solid rgba(231, 76, 60, 0.3);
46            color: #e74c3c;
47        }
48        
49        @keyframes slideDown {
50            from {
51                opacity: 0;
52                transform: translateY(-10px);
53            }
54            to {
55                opacity: 1;
56                transform: translateY(0);
57            }
58        }
59    `;if(!document.getElementById('fitzy-message-styles')){const styleElement=document.createElement('style');styleElement.id='fitzy-message-styles';styleElement.textContent=messageStyles;document.head.appendChild(styleElement);}
60$('.fitzy-widget').each(function(){const widget=new FitzyWidget(this);$(this).data('fitzy-instance',widget);});window.Fitzy={refresh:function(widgetSelector='.fitzy-widget'){$(widgetSelector).each(function(){const instance=$(this).data('fitzy-instance');if(instance){instance.refresh();}});},updateTheme:function(themeName,widgetSelector='.fitzy-widget'){$(widgetSelector).each(function(){const instance=$(this).data('fitzy-instance');if(instance){instance.updateTheme(themeName);}});},getCurrentContent:function(widgetSelector='.fitzy-widget'){const widget=$(widgetSelector).first();const instance=widget.data('fitzy-instance');return instance?instance.getCurrentContent():null;}};$(document).on('keydown','.fitzy-widget',function(e){if(e.key==='Enter'||e.key===' '){const refreshBtn=$(this).find('#fitzy-refresh');if(refreshBtn.length&&refreshBtn.is(':focus')){e.preventDefault();refreshBtn.click();}}});setInterval(function(){const now=new Date();const hour=now.getHours();if(!document.hidden&&(hour===6||hour===12||hour===18)){const minute=now.getMinutes();if(minute===0){window.Fitzy.refresh();}}},60000);if(window.performance&&window.performance.mark){window.performance.mark('fitzy-script-loaded');}});

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.