Jake Vanderwerf
2026-01-04 22e1bb3fcc3b3db1c0f5c2e6a4aecaf408c307a5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
// LoadingState.js - Manages loading overlay and animations
class LoadingState {
    constructor(container, options = {}) {
        this.container = container;
        this.options = {
            loadingMessages: {},
            contentTypes: [],
            taxonomies: [],
            cycleInterval: 2000, // Time between loading message changes
            ...options
        };
 
        this.messageElement = this.container.querySelector('.loading-message');
        this.dotsElement = this.container.querySelector('.loading-dots');
        this.active = false;
        this.quipInterval = null;
        this.currentIndex = 0;
 
        // Initialize quips based on content types and taxonomies
        this.quips = this.initializeQuips();
    }
 
    /**
     * Initialize quips for loading messages
     */
    initializeQuips() {
        // Default quips for different content types
        const defaultQuips = {
            artist: [
                "Seeking ink masters",
                "Finding your next artist",
                "Gathering the talent",
                "Meeting the makers",
                "Summoning art wizards",
                "Finding ink slingers",
                "Priming the inkernet",
                "Loading talent pool",
                "Herding needle ninjas",
                "Rallying rad artists"
            ],
            tattoo: [
                "Converting ink to pixels",
                "Curating fresh ink",
                "Making tattoos internet-famous",
                "Processing perfection",
                "Finding forever art",
                "Making masterpieces mobile",
                "Finding fresh flash",
            ],
            shop: [
                "Mapping the scene",
                "Finding your next spot",
                "Checking shop vibes",
                "Scanning studio space",
                "Locating ink havens",
                "Loading local legends",
                "Finding fresh digs",
            ],
            artwork: [
                "Gathering masterpieces",
                "Curating creativity",
                "Finding fine art",
                "Collecting canvas magic",
                "Processing paintings",
                "Loading creative chaos",
            ],
            piercing: [
                "Finding fresh mods",
                "Piercing through the data",
                "Seeking sparkly things",
                "Processing piercings",
                "Curating cool mods",
                "Seeking shiny stuffs",
                "Loading mod magic",
                "Processing pretty pieces",
                "Scanning sparkly stuff"
            ],
            style: [
                "Sorting styles",
                "Categorizing cool",
                "Finding your vibe",
                "Processing aesthetics",
                "Matching moods",
                "Style scanning",
                "Finding your flavour"
            ],
            theme: [
                "Theming things up",
                "Categorizing content",
                "Sorting subjects",
                "Finding your flavor",
                "Organizing ideas",
            ],
            city: [
                "Looking around corners",
                "Checking the map",
                "Checking it twice",
                "Pushing past obstacles"
            ],
            type: [
                "Searching for artists",
            ]
        };
 
        // Map pstyle, artstyle, etc. to their base types for quips
        const typeMapping = {
            'pstyle': 'style',
            'artstyle': 'style',
            'arttheme': 'theme',
            'artmedium': 'style',
            'artform': 'style',
            'placement': 'style',
            'colour': 'style'
        };
 
        // Gather all quips based on content types and taxonomies
        const allQuips = [];
 
        // Add content type quips
        this.options.contentTypes.forEach(type => {
            if (defaultQuips[type]) {
                defaultQuips[type].forEach(quip => {
                    allQuips.push({
                        icon: type,
                        quip: quip
                    });
                });
            }
        });
 
        // Add taxonomy quips
        this.options.taxonomies.forEach(taxonomy => {
            const baseType = typeMapping[taxonomy] || taxonomy;
            if (defaultQuips[baseType]) {
                defaultQuips[baseType].forEach(quip => {
                    allQuips.push({
                        icon: taxonomy,
                        quip: quip
                    });
                });
            }
        });
 
        // Shuffle the quips array
        return this.shuffleArray(allQuips);
    }
 
    /**
     * Show the loading overlay
     */
    show() {
        this.container.classList.add('active');
        this.active = true;
        this.startQuipCycle();
        document.body.classList.add('loading');
    }
 
    /**
     * Hide the loading overlay
     */
    hide() {
        this.container.classList.remove('active');
        this.active = false;
        this.stopQuipCycle();
        document.body.classList.remove('loading');
    }
 
    /**
     * Start cycling through loading messages
     */
    startQuipCycle() {
        if (this.quipInterval) {
            clearInterval(this.quipInterval);
        }
 
        if (!this.quips.length) return;
 
        // Set initial message
        this.updateMessage(this.quips[0]);
        this.container.classList.remove('changing');
 
        this.quipInterval = setInterval(() => {
            this.container.classList.add('changing');
 
            setTimeout(() => {
                this.currentIndex = (this.currentIndex + 1) % this.quips.length;
                this.updateMessage(this.quips[this.currentIndex]);
 
                setTimeout(() => {
                    this.container.classList.remove('changing');
                }, 50);
            }, 350);
        }, this.options.cycleInterval);
    }
 
    /**
     * Stop cycling through loading messages
     */
    stopQuipCycle() {
        if (this.quipInterval) {
            clearInterval(this.quipInterval);
            this.quipInterval = null;
        }
    }
 
    /**
     * Update the loading message
     */
    updateMessage(quipData) {
        if (!this.messageElement) return;
 
        const icon = window.feedSettings?.icons?.[quipData.icon] || '';
        this.messageElement.innerHTML = `${icon}<p>${quipData.quip}</p>`;
    }
 
    /**
     * Set a custom loading message
     */
    setMessage(message, icon = null) {
        if (!this.messageElement) return;
 
        this.stopQuipCycle();
 
        const iconHtml = icon ? window.feedSettings?.icons?.[icon] || '' : '';
        this.messageElement.innerHTML = `${iconHtml}<p>${message}</p>`;
    }
 
    /**
     * Shuffle an array (Fisher-Yates algorithm)
     */
    shuffleArray(array) {
        const newArray = [...array];
        for (let i = newArray.length - 1; i > 0; i--) {
            const j = Math.floor(Math.random() * (i + 1));
            [newArray[i], newArray[j]] = [newArray[j], newArray[i]];
        }
        return newArray;
    }
}
 
export default LoadingState;