MCPcopy
hub / github.com/sansan0/TrendRadar / resolveTimelineTarget

Function resolveTimelineTarget

docs/assets/script.js:4602–4625  ·  view source on GitHub ↗
(lines, presetName, periodKey)

Source from the content-addressed store, hash-verified

4600}
4601
4602function resolveTimelineTarget(lines, presetName, periodKey) {
4603 const section = resolveTimelineSection(lines, presetName);
4604 if (!section) return null;
4605
4606 const { sectionStart, sectionEnd, sectionIndent } = section;
4607 let targetStart = -1;
4608
4609 if (periodKey === 'default') {
4610 targetStart = findChildKey(lines, sectionStart, sectionEnd, sectionIndent, 'default');
4611 } else {
4612 const periodsLine = findChildKey(lines, sectionStart, sectionEnd, sectionIndent, 'periods');
4613 if (periodsLine < 0) return null;
4614 const periodsIndent = lines[periodsLine].search(/\S/);
4615 const periodsEnd = findBlockEnd(lines, periodsLine, periodsIndent, sectionEnd);
4616 targetStart = findChildKey(lines, periodsLine, periodsEnd, periodsIndent, periodKey);
4617 }
4618
4619 if (targetStart < 0) return null;
4620
4621 const targetIndent = lines[targetStart].search(/\S/);
4622 const targetEnd = findBlockEnd(lines, targetStart, targetIndent, sectionEnd);
4623
4624 return { sectionStart, sectionEnd, sectionIndent, targetStart, targetEnd, targetIndent };
4625}
4626
4627function applyTimelineEditorChanges(editor, lines) {
4628 editor.value = lines.join('\n');

Callers 1

removeTimelineFieldFunction · 0.85

Calls 3

resolveTimelineSectionFunction · 0.85
findChildKeyFunction · 0.85
findBlockEndFunction · 0.85

Tested by

no test coverage detected