apps/legacy/static/legacy/js/pages/settings-selectors.js (Line 36:7 - Line 43:17), apps/legacy/static/legacy/js/pages/settings-sources.js (Line 70:2 - Line 76:15)
;
var fragment = document.createDocumentFragment();
for (var i = 0; i < sources.length; i++) {
var source = sources[i];
var clone = template.content.cloneNode(true);
var item = clone.querySelector('.selector-item'
apps/legacy/static/legacy/js/pages/settings-selectors.js (Line 139:13 - Line 147:19), apps/legacy/static/legacy/js/pages/settings-selectors.js (Line 116:13 - Line 124:21)
// Reload sources to get updated status
var sourcesTab = Cookie.pages.settings.registerTab && Cookie.pages.settings;
if (sourcesTab && sourcesTab.tabs && sourcesTab.tabs.sources && sourcesTab.tabs.sources.loadSources) {
sourcesTab.tabs.sources.loadSources();
}
});
}
function handleEditSelector
apps/legacy/static/legacy/js/pages/settings-selectors.js (Line 157:25 - Line 163:8), apps/legacy/static/legacy/js/pages/settings-selectors.js (Line 147:19 - Line 153:9)
(e) {
var target = e.delegateTarget || e.currentTarget;
var sourceId = target.getAttribute('data-source-id');
var inputRow = selectorsList.querySelector('.selector-input-row[data-source-id="' + sourceId + '"]');
var editRow = selectorsList.querySelector('.selector-edit-row[data-source-id="' + sourceId + '"]');
editRow
apps/legacy/static/legacy/js/pages/settings-general.js (Line 50:25 - Line 59:2), apps/legacy/static/legacy/js/pages/settings-selectors.js (Line 106:24 - Line 116:40)
apps/legacy/static/legacy/js/pages/play.js (Line 411:20 - Line 470:8), apps/legacy/static/legacy/js/pages/play.js (Line 350:17 - Line 410:8)
(e) {
var btn = e.currentTarget;
var duration = parseInt(btn.getAttribute('data-duration'), 10);
var label = btn.getAttribute('data-label');
var instruction = instructions[currentStep] || '';
// If AI is available, try to get an AI-generated name
if (typeof AI_AVAILABLE !== 'undefined' && AI_AVAILABLE && instruction) {
// Disable button while loading
btn.disabled = true;
btn.classList.add('loading');
// Convert seconds to minutes for the API
var durationMinutes = Math.ceil(duration / 60);
// Call AI API using XMLHttpRequest (ES5 compatible)
var xhr = new XMLHttpRequest();
xhr.open('POST', '/api/ai/timer-name', true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
btn.disabled = false;
btn.classList.remove('loading');
if (xhr.status === 200) {
try {
var response = JSON.parse(xhr.responseText);
if (response.label) {
addTimer(response.label, duration);
return;
}
} catch (parseError) {
// JSON parse error, fall through to default
}
}
// AI failed, use default label
addTimer(label, duration);
}
};
xhr.onerror = function() {
btn.disabled = false;
btn.classList.remove('loading');
addTimer(label, duration);
};
xhr.send(JSON.stringify({
step_text: instruction,
duration_minutes: durationMinutes
}));
} else {
// No AI available, use default label
addTimer(label, duration);
}
}
/**
* Add a new timer
*/
apps/legacy/static/legacy/js/pages/play.js (Line 598:5 - Line 606:5), apps/legacy/static/legacy/js/pages/search.js (Line 555:5 - Line 563:7)
return {
init: init
};
})();
// Auto-init on page load
(function() {
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', Cookie.pages.play
apps/legacy/static/legacy/js/pages/home.js (Line 352:2 - Line 364:5), apps/legacy/static/legacy/js/pages/search.js (Line 551:66 - Line 563:7)
apps/legacy/static/legacy/js/pages/favorites.js (Line 31:5 - Line 38:15), apps/legacy/static/legacy/js/pages/home.js (Line 275:5 - Line 281:4)
function handleFavoriteClick(e) {
e.preventDefault();
e.stopPropagation();
var btn = e.currentTarget;
var recipeId = btn.getAttribute('data-recipe-id');
removeFavorite
apps/legacy/static/legacy/js/pages/favorites.js (Line 38:4 - Line 51:31), apps/legacy/static/legacy/js/pages/home.js (Line 308:2 - Line 320:4)
);
}
/**
* Remove recipe from favorites
*/
function removeFavorite(recipeId, btn) {
Cookie.ajax.delete('/api/favorites/' + recipeId + '/', function(err) {
if (err) {
Cookie.toast.error('Failed to remove from favorites');
return;
}
// Animate and remove the card
apps/legacy/static/legacy/js/pages/favorites.js (Line 52:13 - Line 56:5), apps/legacy/static/legacy/js/pages/home.js (Line 329:13 - Line 333:11)
var card = btn.closest('.recipe-card');
if (card) {
card.style.opacity = '0';
card.style.transform = 'scale(0.9)';
card
apps/legacy/static/legacy/js/pages/favorites.js (Line 86:13 - Line 98:10), apps/legacy/static/legacy/js/pages/home.js (Line 352:13 - Line 563:7)
apps/legacy/static/legacy/js/pages/detail-tips.js (Line 121:15 - Line 130:7), apps/legacy/static/legacy/js/pages/detail-tips.js (Line 54:23 - Line 62:3)
);
if (tipsContent) {
tipsContent.classList.add('hidden');
}
if (tipsLoading) {
tipsLoading.classList.remove('hidden');
}
Cookie
apps/legacy/static/legacy/js/pages/detail-scaling.js (Line 138:27 - Line 147:4), apps/legacy/static/legacy/js/pages/detail-scaling.js (Line 119:26 - Line 128:27)
);
for (var j = 0; j < originalTexts.length; j++) {
originalTexts[j].classList.remove('hidden');
}
for (var k = 0; k < scaledTexts.length; k++) {
scaledTexts[k].classList.add('hidden');
}
var
apps/legacy/static/legacy/js/pages/detail-scaling.js (Line 239:2 - Line 243:3), apps/legacy/static/legacy/js/pages/detail-scaling.js (Line 210:9 - Line 215:2)
;
var el = document.querySelector('[data-time-type="' + type + '"]');
if (el) {
var valueEl = el.querySelector('.time-value');
if (valueEl &&
apps/legacy/static/legacy/js/pages/detail-remix.js (Line 107:23 - Line 112:3), apps/legacy/static/legacy/js/pages/detail-remix.js (Line 83:21 - Line 88:21)
() {
var state = Cookie.pages.detail.getState();
var suggestionsContainer = document.getElementById('remix-suggestions');
if (!suggestionsContainer) return;
if
apps/legacy/static/legacy/js/pages/detail-remix.js (Line 188:21 - Line 192:7), apps/legacy/static/legacy/js/pages/detail-remix.js (Line 173:23 - Line 177:59)
() {
var state = Cookie.pages.detail.getState();
var customInput = document.getElementById('remix-custom-input');
if (customInput && customInput.value.trim()) {
return
apps/legacy/static/legacy/js/pages/detail-remix.js (Line 274:25 - Line 282:7), apps/legacy/static/legacy/js/pages/detail-remix.js (Line 94:29 - Line 102:6)
);
if (Cookie.aiError.shouldHideFeatures(err)) {
closeRemixModal();
Cookie.aiError.hideAIFeatures();
}
return;
}
Cookie
apps/legacy/static/legacy/js/pages/detail-favorites.js (Line 29:2 - Line 35:4), apps/legacy/static/legacy/js/pages/home.js (Line 296:2 - Line 302:35)
}, function(err) {
if (err) {
Cookie.toast.error('Failed to add to favorites');
return;
}
btn.classList.add('active');
var
apps/legacy/static/legacy/js/pages/detail-favorites.js (Line 47:2 - Line 53:4), apps/legacy/static/legacy/js/pages/home.js (Line 315:2 - Line 321:36)
recipeId + '/', function(err) {
if (err) {
Cookie.toast.error('Failed to remove from favorites');
return;
}
btn.classList.remove('active');
var
apps/legacy/static/legacy/js/pages/collections.js (Line 139:2 - Line 150:12), apps/legacy/static/legacy/js/pages/profile-selector.js (Line 222:7 - Line 563:7)
apps/legacy/static/legacy/js/time-detect.js (Line 63:7 - Line 89:8), apps/legacy/static/legacy/js/timer.js (Line 363:15 - Line 383:14)
(seconds) {
if (seconds >= 3600) {
var hrs = Math.floor(seconds / 3600);
var mins = Math.floor((seconds % 3600) / 60);
if (mins > 0) {
return hrs + 'h ' + mins + 'm';
}
return hrs + 'h';
}
var minutes = Math.floor(seconds / 60);
var secs = seconds % 60;
if (minutes === 0) {
return secs + ' sec';
}
if (secs === 0) {
return minutes + ' min';
}
return minutes + 'm ' + secs + 's';
}
/**
* Check if text contains any time mentions
* @param {string} text - Text to check
* @returns {boolean} - True if time mentions found
*/
apps/legacy/static/legacy/js/polyfills.js (Line 55:56 - Line 68:2), apps/legacy/static/legacy/js/polyfills.js (Line 31:51 - Line 44:6)
);
}
if (typeof predicate !== 'function') {
throw new TypeError('predicate must be a function');
}
var list = Object(this);
var length = list.length >>> 0;
var thisArg = arguments[1];
var value;
for (var i = 0; i < length; i++) {
value = list[i];
if (predicate.call(thisArg, value, i, list)) {
return i
apps/legacy/static/legacy/js/ajax.js (Line 22:8 - Line 27:3), apps/legacy/static/legacy/js/pages/play.js (Line 367:21 - Line 372:4)
, true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
if