(scripts, _tabs, addTabTitle = true)
| 379 | }; |
| 380 | |
| 381 | function sortScriptsByTab(scripts, _tabs, addTabTitle = true) { |
| 382 | let result = []; |
| 383 | |
| 384 | for (let tab of Object.values(_tabs)) { |
| 385 | let sorted = []; |
| 386 | |
| 387 | for (let script of tab.scripts) { |
| 388 | let found = scripts.findIndex((_) => _.id === script.id) >= 0; |
| 389 | if (found) sorted.push(script); |
| 390 | } |
| 391 | |
| 392 | if (sorted.length) { |
| 393 | addTabTitle && result.push(createTitle(tab.name.en, tab.name.vi)); |
| 394 | result.push(...sorted); |
| 395 | } |
| 396 | } |
| 397 | return result; |
| 398 | } |
| 399 | |
| 400 | const allScriptInTabs = [ |
| 401 | ...tabs.map((tab) => tab.scripts), |
no test coverage detected