mirror of
https://github.com/coalaura/whiskr.git
synced 2025-12-02 20:22:52 +00:00
"new" tag
This commit is contained in:
@@ -103,6 +103,15 @@
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.dropdown .opt .new {
|
||||
font-size: 11px;
|
||||
padding-left: 4px;
|
||||
position: relative;
|
||||
top: -2px;
|
||||
color: var(--c-red);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.dropdown .label {
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
@@ -120,6 +129,10 @@
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
.dropdown .selected .new {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.dropdown .selected:not(.all-tags) .tags:has(.tag:nth-child(3)) {
|
||||
display: flex;
|
||||
height: 2px;
|
||||
|
||||
@@ -1677,6 +1677,8 @@
|
||||
}
|
||||
|
||||
// render models
|
||||
const newTime = Math.round(Date.now() / 1000) - 2 * 7 * 24 * 60 * 60;
|
||||
|
||||
fillSelect($model, data.models, (el, model) => {
|
||||
const separator = "─".repeat(24);
|
||||
|
||||
@@ -1684,7 +1686,7 @@
|
||||
model.name,
|
||||
separator,
|
||||
`Tags:\t\t${model.tags?.join(", ") || "-"}`,
|
||||
`Created:\t${formatTimestamp(model.created)}`,
|
||||
`Created:\t\t${formatTimestamp(model.created)}`,
|
||||
`Pricing/1M:\t${formatMoney(model.pricing.input)} In | ${formatMoney(model.pricing.output)} Out`,
|
||||
model.pricing.image ? `Images/1K:\t${formatMoney(model.pricing.image * 1000)} Out` : null,
|
||||
separator,
|
||||
@@ -1696,6 +1698,10 @@
|
||||
el.value = model.id;
|
||||
el.textContent = model.name;
|
||||
|
||||
if ((model.created || 0) >= newTime) {
|
||||
el.dataset.new = "yes";
|
||||
}
|
||||
|
||||
el.dataset.tags = (model.tags || []).join(",");
|
||||
|
||||
models[model.id] = model;
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
this.#search = "searchable" in el.dataset;
|
||||
|
||||
this.#_select.querySelectorAll("option").forEach(option => {
|
||||
const tags = option.dataset.tags?.trim();
|
||||
const tags = option.dataset.tags?.trim(),
|
||||
isNew = !!option.dataset.new;
|
||||
|
||||
this.#options.push({
|
||||
value: option.value,
|
||||
@@ -25,6 +26,7 @@
|
||||
|
||||
title: option.title || "",
|
||||
tags: tags ? tags.split(",") : [],
|
||||
new: isNew,
|
||||
|
||||
search: searchable(option.textContent),
|
||||
});
|
||||
@@ -102,6 +104,16 @@
|
||||
|
||||
_opt.appendChild(_label);
|
||||
|
||||
// new tag
|
||||
if (option.new) {
|
||||
const _new = make("sup", "new");
|
||||
|
||||
_new.textContent = "new";
|
||||
_new.title = "Less than 2 weeks old";
|
||||
|
||||
_label.appendChild(_new);
|
||||
}
|
||||
|
||||
// option tags (optional)
|
||||
const tags = option.tags;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user