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

Function calculateImagesDistribution

scripts/reading.js:76–182  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

74
75//Calculates the distribution of the images depending on the user's configuration
76function calculateImagesDistribution()
77{
78 imagesDistribution = [];
79 indexNum = 0;
80
81 if(doublePage.active())
82 {
83 var data = [];
84
85 if(_config.readingBlankPage && (!_config.readingDoNotApplyToHorizontals || (typeof imagesDataClip[1] !== 'undefined' && imagesDataClip[1].aspectRatio <= 1)))
86 data.push({index: false, folder: false, blank: true, width: 2});
87
88 for(let i = 1; i < (contentNum + 1); i++)
89 {
90 if(typeof imagesDataClip[i] !== 'undefined')
91 {
92 if(_config.readingDoNotApplyToHorizontals && imagesDataClip[i].aspectRatio > 1)
93 {
94 if(data.length > 0)
95 {
96 data.push({index: false, folder: false, blank: true, width: 2});
97 imagesDistribution.push(data);
98 data = [];
99 indexNum++;
100 }
101
102 data.push({index: i, folder: false, blank: false, width: 1});
103 imagesDataClip[i].position = imagesData[i].position = indexNum;
104 imagesDistribution.push(data);
105 indexNum++;
106 data = [];
107 }
108 else
109 {
110 if(_config.readingDoNotApplyToHorizontals && data.length == 0 && blankPage(i))
111 data.push({index: false, folder: false, blank: true, width: 2});
112
113 data.push({index: i, folder: false, blank: false, width: 2});
114 imagesDataClip[i].position = imagesData[i].position = indexNum;
115 }
116 }
117 else
118 {
119 data.push({index: i, folder: true, blank: false, width: 2});
120 foldersPosition[i] = indexNum;
121 }
122
123 if(data.length > 1)
124 {
125 imagesDistribution.push(data);
126 data = [];
127 indexNum++;
128 }
129
130 }
131
132 if(data.length > 0)
133 {

Callers 1

addHtmlImagesFunction · 0.85

Calls 1

blankPageFunction · 0.85

Tested by

no test coverage detected