MCPcopy
hub / github.com/ollm/OpenComic / getEbookConfig

Function getEbookConfig

scripts/reading.js:4379–4458  ·  view source on GitHub ↗
(configReadingEbook = false)

Source from the content-addressed store, hash-verified

4377var _ebook = false;
4378
4379async function getEbookConfig(configReadingEbook = false)
4380{
4381 configReadingEbook = configReadingEbook || _config.readingEbook;
4382
4383 let rect = template._contentRight().getBoundingClientRect();
4384
4385 if(rect.width == 0 || rect.height == 0)
4386 {
4387 for(let i = 0; i < 100; i++)
4388 {
4389 await app.sleep(20);
4390
4391 rect = template._contentRight().getBoundingClientRect();
4392
4393 if(rect.width != 0 && rect.height != 0)
4394 break;
4395 }
4396 }
4397
4398 let renderZone = {
4399 width: ((rect.width - (readingMargin().left * (doublePage.active() ? 3 : 2))) / (doublePage.active() ? 2 : 1)) - (readingViewIs('scroll') ? 12 : 0),
4400 height: (rect.height - (readingMargin().top * 2)),
4401 };
4402
4403 let width = 0;
4404 let height = 0;
4405
4406 let integratedMode = configReadingEbook.integrated;
4407 let ratio = configReadingEbook.ratio;
4408
4409 if(!integratedMode && ratio > 0.4)
4410 {
4411 if(renderZone.height / renderZone.width > ratio)
4412 {
4413 width = renderZone.width;
4414 height = renderZone.width * ratio;
4415 }
4416 else
4417 {
4418 width = renderZone.height / ratio;
4419 height = renderZone.height;
4420 }
4421 }
4422 else
4423 {
4424 width = renderZone.width;
4425 height = renderZone.height;
4426 }
4427
4428 let maxWidth = configReadingEbook.maxWidth;
4429 let minMargin = configReadingEbook.minMargin;
4430 let verticalMargin = (readingViewIs('scroll') && !doublePage.active()) ? 0 : configReadingEbook.verticalMargin;
4431
4432 let horizontalMargin = Math.round((width - maxWidth) / 2);
4433
4434 if(horizontalMargin < minMargin)
4435 horizontalMargin = minMargin;
4436

Callers 2

fastUpdateEbookPagesFunction · 0.85
generateEbookPagesFunction · 0.85

Calls 2

readingMarginFunction · 0.85
readingViewIsFunction · 0.85

Tested by

no test coverage detected