+21
-7
Index.html
+21
-7
Index.html
···
73
73
74
74
// Get option and ensure it's one of the valid options
75
75
let option = params.get('option') || 'likes';
76
-
if (option && !['likes', 'reposts', 'both'].includes(option)) {
77
-
console.warn('Invalid option parameter. Must be "likes", "reposts", or "both".');
76
+
if (option && !['likes', 'reposts', 'both', 'or'].includes(option)) {
77
+
console.warn('Invalid option parameter. Must be "likes", "reposts", "both", or "or".');
78
78
option = 'likes';
79
79
}
80
80
···
115
115
likes_only: true,
116
116
reposts_only: false,
117
117
likes_and_reposts: false,
118
+
likes_or_reposts: false,
118
119
119
120
error: '',
120
121
loading: false,
···
141
142
this.likes_only = params.option === 'likes';
142
143
this.reposts_only = params.option === 'reposts';
143
144
this.likes_and_reposts = params.option === 'both';
145
+
this.likes_or_reposts = params.option === 'or';
144
146
}
145
147
146
148
// Automatically run the giveaway if post_url is provided
···
157
159
this.likes_only = targetId === 'likes';
158
160
this.reposts_only = targetId === 'reposts_only';
159
161
this.likes_and_reposts = targetId === 'likes_and_reposts';
162
+
this.likes_or_reposts = targetId === 'likes_or_reposts';
160
163
},
161
164
async runGiveaway() {
162
165
this.error = '';
···
171
174
return;
172
175
}
173
176
174
-
if (!this.likes_only && !this.reposts_only && !this.likes_and_reposts) {
177
+
if (!this.likes_only && !this.reposts_only && !this.likes_and_reposts && !this.likes_or_reposts) {
175
178
this.error = 'Well, you have to pick some way for them to win';
176
179
return;
177
180
}
···
207
210
208
211
// Determine which collections to fetch based on user selection
209
212
const collections = [];
210
-
if (this.likes_only || this.likes_and_reposts) {
213
+
if (this.likes_only || this.likes_and_reposts || this.likes_or_reposts) {
211
214
collections.push(likesCollection);
212
215
}
213
-
if (this.reposts_only || this.likes_and_reposts) {
216
+
if (this.reposts_only || this.likes_and_reposts || this.likes_or_reposts) {
214
217
collections.push(repostsCollection);
215
218
}
216
219
···
267
270
const repostsDids = results.filter(x => x.collection === repostsCollection).map(x => x.did);
268
271
uniqueDids = likesDids.filter(did => repostsDids.includes(did));
269
272
}
273
+
if (this.likes_or_reposts) {
274
+
uniqueDids = [...new Set(results.map(x => x.did))];
275
+
}
270
276
271
277
this.participants = uniqueDids.length;
272
278
// Select winners
···
359
365
id="likes_and_reposts"
360
366
type="checkbox"
361
367
class="checkbox"/>
362
-
Likes & Reposts
368
+
Both Likes & Reposts
369
+
</label>
370
+
371
+
<label class="label">
372
+
<input x-model="likes_or_reposts" x-on:change="validateCheckBoxes($event)"
373
+
id="likes_or_reposts"
374
+
type="checkbox"
375
+
class="checkbox"/>
376
+
Likes OR Reposts
363
377
</label>
364
378
365
379
</fieldset>
···
397
411
<ul class="list-disc pl-5 mb-2">
398
412
<li><code>post_url</code>: URL of the Bluesky post</li>
399
413
<li><code>winner_count</code>: Number of winners (default: 1)</li>
400
-
<li><code>option</code>: 'likes', 'reposts', or 'both' (default: 'likes')</li>
414
+
<li><code>option</code>: 'likes', 'reposts', 'both', or 'or' (default: 'likes')</li>
401
415
</ul>
402
416
403
417
</div>