Spaces:
Sleeping
Sleeping
Update static/js/ui.js
Browse files- static/js/ui.js +20 -10
static/js/ui.js
CHANGED
|
@@ -172,7 +172,6 @@ function closeAllSheets() {
|
|
| 172 |
});
|
| 173 |
document.getElementById('textInput').blur();
|
| 174 |
|
| 175 |
-
// توقف پلیر و ریست آیکونها
|
| 176 |
if(previewInterval) clearInterval(previewInterval);
|
| 177 |
v.pause();
|
| 178 |
|
|
@@ -201,35 +200,46 @@ function openSheet(type) {
|
|
| 201 |
const seg = state.segs[sIdx];
|
| 202 |
const word = seg.words[wIdx];
|
| 203 |
|
| 204 |
-
// تنظیم مقادیر اولیه زمان
|
| 205 |
tempStartTime = word.start;
|
| 206 |
tempEndTime = word.end;
|
| 207 |
|
| 208 |
-
// نمایش کلمه جاری
|
| 209 |
document.getElementById('timeSheetWord').innerText = word.word;
|
| 210 |
|
| 211 |
-
// نمایش کلمات قبل و بعد (برای Trimmer)
|
| 212 |
const prevBox = document.getElementById('prevWordPreview');
|
| 213 |
const nextBox = document.getElementById('nextWordPreview');
|
| 214 |
|
| 215 |
-
|
| 216 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 217 |
const prevSeg = state.segs[sIdx-1];
|
| 218 |
prevBox.innerText = prevSeg.words[prevSeg.words.length - 1].word;
|
|
|
|
| 219 |
} else {
|
| 220 |
prevBox.innerText = "-";
|
|
|
|
| 221 |
}
|
| 222 |
|
| 223 |
-
|
| 224 |
-
|
|
|
|
|
|
|
|
|
|
| 225 |
nextBox.innerText = state.segs[sIdx+1].words[0].word;
|
|
|
|
| 226 |
} else {
|
| 227 |
nextBox.innerText = "-";
|
|
|
|
| 228 |
}
|
| 229 |
|
| 230 |
-
// راهاندازی
|
| 231 |
if(typeof initTrimmerUI === 'function') {
|
| 232 |
-
initTrimmerUI(tempStartTime, tempEndTime);
|
| 233 |
}
|
| 234 |
|
| 235 |
} else if(type === 'delete') {
|
|
|
|
| 172 |
});
|
| 173 |
document.getElementById('textInput').blur();
|
| 174 |
|
|
|
|
| 175 |
if(previewInterval) clearInterval(previewInterval);
|
| 176 |
v.pause();
|
| 177 |
|
|
|
|
| 200 |
const seg = state.segs[sIdx];
|
| 201 |
const word = seg.words[wIdx];
|
| 202 |
|
|
|
|
| 203 |
tempStartTime = word.start;
|
| 204 |
tempEndTime = word.end;
|
| 205 |
|
|
|
|
| 206 |
document.getElementById('timeSheetWord').innerText = word.word;
|
| 207 |
|
|
|
|
| 208 |
const prevBox = document.getElementById('prevWordPreview');
|
| 209 |
const nextBox = document.getElementById('nextWordPreview');
|
| 210 |
|
| 211 |
+
// محاسبه محدوده مجاز (Boundary)
|
| 212 |
+
let minAllowed = 0;
|
| 213 |
+
let maxAllowed = v.duration || 1000;
|
| 214 |
+
|
| 215 |
+
// محاسبه کلمه قبل و حد پایین
|
| 216 |
+
if (wIdx > 0) {
|
| 217 |
+
prevBox.innerText = seg.words[wIdx - 1].word;
|
| 218 |
+
minAllowed = seg.words[wIdx - 1].end;
|
| 219 |
+
} else if (sIdx > 0 && state.segs[sIdx-1].words.length > 0) {
|
| 220 |
const prevSeg = state.segs[sIdx-1];
|
| 221 |
prevBox.innerText = prevSeg.words[prevSeg.words.length - 1].word;
|
| 222 |
+
minAllowed = prevSeg.words[prevSeg.words.length - 1].end;
|
| 223 |
} else {
|
| 224 |
prevBox.innerText = "-";
|
| 225 |
+
minAllowed = 0;
|
| 226 |
}
|
| 227 |
|
| 228 |
+
// محاسبه کلمه بعد و حد بالا
|
| 229 |
+
if (wIdx < seg.words.length - 1) {
|
| 230 |
+
nextBox.innerText = seg.words[wIdx + 1].word;
|
| 231 |
+
maxAllowed = seg.words[wIdx + 1].start;
|
| 232 |
+
} else if (sIdx < state.segs.length - 1 && state.segs[sIdx+1].words.length > 0) {
|
| 233 |
nextBox.innerText = state.segs[sIdx+1].words[0].word;
|
| 234 |
+
maxAllowed = state.segs[sIdx+1].words[0].start;
|
| 235 |
} else {
|
| 236 |
nextBox.innerText = "-";
|
| 237 |
+
maxAllowed = v.duration || tempEndTime + 5;
|
| 238 |
}
|
| 239 |
|
| 240 |
+
// راهاندازی Trimmer با محدودههای دقیق
|
| 241 |
if(typeof initTrimmerUI === 'function') {
|
| 242 |
+
initTrimmerUI(tempStartTime, tempEndTime, minAllowed, maxAllowed);
|
| 243 |
}
|
| 244 |
|
| 245 |
} else if(type === 'delete') {
|