Skip to content

Commit

Permalink
v1.4.9.1
Browse files Browse the repository at this point in the history
[*] fixed the issue where TOC overlaps with the main content when using ultrawide monitors
  • Loading branch information
henryxrl committed Dec 18, 2023
1 parent 8e2abc2 commit b832d49
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 26 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@

火狐插件:

1. [易笺正常版 (v1.4.9)](https://addons.mozilla.org/zh-CN/firefox/addon/yijian/)
1. [易笺正常版 (v1.4.9.1)](https://addons.mozilla.org/zh-CN/firefox/addon/yijian/)

2. [易笺无界面版 (v1.2.8)](https://addons.mozilla.org/zh-CN/firefox/addon/yijian_nogui/)
2. [易笺无界面版 (v1.2.8.1)](https://addons.mozilla.org/zh-CN/firefox/addon/yijian_nogui/)

Chrome插件:

1. [易笺正常版 (v1.4.9)](https://chrome.google.com/webstore/detail/%E6%98%93%E7%AC%BA/dbanahlbopbjpgdkecmclbbonhpohcaf?hl=en&authuser=0)
1. [易笺正常版 (v1.4.9.1)](https://chrome.google.com/webstore/detail/%E6%98%93%E7%AC%BA/dbanahlbopbjpgdkecmclbbonhpohcaf?hl=en&authuser=0)

2. [易笺无界面版 (v1.2.8)](https://chrome.google.com/webstore/detail/%E6%98%93%E7%AC%BA%EF%BC%88%E6%97%A0%E7%95%8C%E9%9D%A2%E7%89%88%EF%BC%89/mifnkjlmnnaamfgmhmjdjiplaaladjlo?hl=en&authuser=0)
2. [易笺无界面版 (v1.2.8.1)](https://chrome.google.com/webstore/detail/%E6%98%93%E7%AC%BA%EF%BC%88%E6%97%A0%E7%95%8C%E9%9D%A2%E7%89%88%EF%BC%89/mifnkjlmnnaamfgmhmjdjiplaaladjlo?hl=en&authuser=0)

---

Expand Down
8 changes: 4 additions & 4 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ Support for customized settings such as font size, line height, theme colors and

Firefox:

1. [Regular (v1.4.9)](https://addons.mozilla.org/en-US/firefox/addon/yijian/)
1. [Regular (v1.4.9.1)](https://addons.mozilla.org/en-US/firefox/addon/yijian/)

2. [No-UI (v1.2.8)](https://addons.mozilla.org/en-US/firefox/addon/yijian_nogui/)
2. [No-UI (v1.2.8.1)](https://addons.mozilla.org/en-US/firefox/addon/yijian_nogui/)

Chrome:

1. [Regular (v1.4.9)](https://chrome.google.com/webstore/detail/%E6%98%93%E7%AC%BA/dbanahlbopbjpgdkecmclbbonhpohcaf?hl=en&authuser=0)
1. [Regular (v1.4.9.1)](https://chrome.google.com/webstore/detail/%E6%98%93%E7%AC%BA/dbanahlbopbjpgdkecmclbbonhpohcaf?hl=en&authuser=0)

2. [No-UI (v1.2.8)](https://chrome.google.com/webstore/detail/%E6%98%93%E7%AC%BA%EF%BC%88%E6%97%A0%E7%95%8C%E9%9D%A2%E7%89%88%EF%BC%89/mifnkjlmnnaamfgmhmjdjiplaaladjlo?hl=en&authuser=0)
2. [No-UI (v1.2.8.1)](https://chrome.google.com/webstore/detail/%E6%98%93%E7%AC%BA%EF%BC%88%E6%97%A0%E7%95%8C%E9%9D%A2%E7%89%88%EF%BC%89/mifnkjlmnnaamfgmhmjdjiplaaladjlo?hl=en&authuser=0)

---

Expand Down
2 changes: 1 addition & 1 deletion manifests/Chrome/regular/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "易笺",
"description": "txt(小说)阅读器:支持秒开本地的所有txt文件,自动排版,自动分页,自动生成目录,记录阅读进度。",
"version": "1.4.9",
"version": "1.4.9.1",
"background": {
"service_worker": "scripts_extension/Chrome/regular/activate.js"
},
Expand Down
2 changes: 1 addition & 1 deletion manifests/Firefox/regular/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "易笺",
"description": "txt(小说)阅读器:支持秒开本地的所有txt文件,自动排版,自动分页,自动生成目录,记录阅读进度。",
"version": "1.4.9",
"version": "1.4.9.1",
"background": {
"scripts": [
"scripts_extension/Firefox/regular/activate.js"
Expand Down
28 changes: 24 additions & 4 deletions scripts/ui_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@ function setMainContentUI() {
}, 1000);

// UI calculations
// var maxWidth = sh(100)/9*16;
const maxWidth = sh(100)*2;
const maxWidth = sh(100) / 9 * 16;
// const maxWidth = sh(100) * 2;
style.ui_maxWidth = `${maxWidth}px`;

// windowWith = windowLeftRightMargin + tocWidth + gapWidth + contentWidth + windowLeftRightMargin;
style.ui_contentMarginLeft = (100 - parseInt(style.ui_contentWidth) - parseInt(style.ui_windowLeftRightMargin)).toString();
// console.log("IN SETMAINCONTENTUI: style.ui_contentMarginLeft: " + style.ui_contentMarginLeft);
style.ui_tocWidth = (100 - parseInt(style.ui_contentWidth) - parseInt(style.ui_windowLeftRightMargin) * 2 - parseInt(style.ui_gapWidth)).toString();

const tocWidthPercent = 100 - parseInt(style.ui_contentWidth) - parseInt(style.ui_windowLeftRightMargin) * 2 - parseInt(style.ui_gapWidth);
const tocWidth = vw(100) <= maxWidth ? tocWidthPercent : tocWidthPercent * maxWidth / vw(100);
style.ui_tocWidth = tocWidth.toString();

const paginationLeftPercent = parseInt(style.ui_contentWidth) / 2 + parseInt(style.ui_contentMarginLeft);
const paginationLeft = vw(100) <= maxWidth ? paginationLeftPercent : (paginationLeftPercent * maxWidth / 100 + (vw(100) - maxWidth) / 2) / vw(100) * 100;
Expand All @@ -54,6 +58,8 @@ function setMainContentUI() {
tocContainer.style.marginRight = '0px';
tocContainer.style.marginBottom = '0px';
tocContainer.style.marginLeft = style.ui_windowLeftRightMargin + '%';

tocContainer.style.left = `calc(${contentContainer.getBoundingClientRect().x}px - ${tocContainer.getBoundingClientRect().width}px - ${style.ui_gapWidth}% - ${style.ui_windowLeftRightMargin}%)`;
}

// Pagination
Expand All @@ -69,15 +75,30 @@ function setMainContentUI() {
progressContainer.style.marginBottom = '2.5em';
progressContainer.style.marginLeft = style.ui_windowLeftRightMargin + '%';
progressContainer.style.top = '75%';

progressContainer.style.left = `calc(${contentContainer.getBoundingClientRect().x}px - ${tocContainer.getBoundingClientRect().width}px - ${style.ui_gapWidth}% - ${style.ui_windowLeftRightMargin}%)`;
}
}

function updateTOCUI(isIncreasing) {
const maxWidth = parseFloat(style.ui_maxWidth);
const tocWidthPercent = 100 - parseInt(style.ui_contentWidth) - parseInt(style.ui_windowLeftRightMargin) * 2 - parseInt(style.ui_gapWidth);
const tocWidth = vw(100) <= maxWidth ? tocWidthPercent : tocWidthPercent * maxWidth / vw(100);
style.ui_tocWidth = tocWidth.toString();

if (isVariableDefined(tocContainer)) {
tocContainer.style.width = style.ui_tocWidth + '%';
tocContainer.style.height = style.ui_tocHeight + '%';
if (tocContainer.scrollHeight > (window.innerHeight * 0.5)) {
tocContainer.style.height = '50%';
}

tocContainer.style.left = `calc(${contentContainer.getBoundingClientRect().x}px - ${tocContainer.getBoundingClientRect().width}px - ${style.ui_gapWidth}% - ${style.ui_windowLeftRightMargin}%)`;
}

if (isVariableDefined(progressContainer)) {
progressContainer.style.width = style.ui_tocWidth + '%';
progressContainer.style.left = `calc(${contentContainer.getBoundingClientRect().x}px - ${tocContainer.getBoundingClientRect().width}px - ${style.ui_gapWidth}% - ${style.ui_windowLeftRightMargin}%)`;
}

if (isVariableDefined(paginationContainer)) {
Expand All @@ -95,7 +116,6 @@ function updateTOCUI(isIncreasing) {
}
}

const maxWidth = parseFloat(style.ui_maxWidth);
const paginationLeftPercent = parseInt(style.ui_contentWidth) / 2 + parseInt(style.ui_contentMarginLeft);
const paginationLeft = vw(100) <= maxWidth ? paginationLeftPercent : (paginationLeftPercent * maxWidth / 100 + (vw(100) - maxWidth) / 2) / vw(100) * 100;
style.ui_paginationCenter = paginationLeft.toString();
Expand Down
2 changes: 1 addition & 1 deletion scripts_extension/Chrome/no-ui/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "易笺(无界面版)",
"description": "txt(小说)阅读器:支持本地和云端的所有txt文件,自动排版,自动分页,自动生成目录,记录阅读进度。",
"version": "1.2.8",
"version": "1.2.8.1",
"permissions": [],
"content_scripts": [
{
Expand Down
30 changes: 25 additions & 5 deletions scripts_extension/Chrome/no-ui/scripts/ui_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@ function setMainContentUI() {
}

// UI calculations
// var maxWidth = sh(100)/9*16;
const maxWidth = sh(100)*2;
const maxWidth = sh(100) / 9 * 16;
// const maxWidth = sh(100) * 2;
style.ui_maxWidth = `${maxWidth}px`;

// windowWith = windowLeftRightMargin + tocWidth + gapWidth + contentWidth + windowLeftRightMargin;
style.ui_contentMarginLeft = (100 - parseInt(style.ui_contentWidth) - parseInt(style.ui_windowLeftRightMargin)).toString();
// console.log("IN SETMAINCONTENTUI: style.ui_contentMarginLeft: " + style.ui_contentMarginLeft);
style.ui_tocWidth = (100 - parseInt(style.ui_contentWidth) - parseInt(style.ui_windowLeftRightMargin) * 2 - parseInt(style.ui_gapWidth)).toString();


const tocWidthPercent = 100 - parseInt(style.ui_contentWidth) - parseInt(style.ui_windowLeftRightMargin) * 2 - parseInt(style.ui_gapWidth);
const tocWidth = vw(100) <= maxWidth ? tocWidthPercent : tocWidthPercent * maxWidth / vw(100);
style.ui_tocWidth = tocWidth.toString();

const paginationLeftPercent = parseInt(style.ui_contentWidth) / 2 + parseInt(style.ui_contentMarginLeft);
const paginationLeft = vw(100) <= maxWidth ? paginationLeftPercent : (paginationLeftPercent * maxWidth / 100 + (vw(100) - maxWidth) / 2) / vw(100) * 100;
style.ui_paginationCenter = paginationLeft.toString();
Expand All @@ -47,6 +51,8 @@ function setMainContentUI() {
tocContainer.style.marginRight = '0px';
tocContainer.style.marginBottom = '0px';
tocContainer.style.marginLeft = style.ui_windowLeftRightMargin + '%';

tocContainer.style.left = `calc(${contentContainer.getBoundingClientRect().x}px - ${tocContainer.getBoundingClientRect().width}px - ${style.ui_gapWidth}% - ${style.ui_windowLeftRightMargin}%)`;
}

// Pagination
Expand All @@ -62,15 +68,30 @@ function setMainContentUI() {
progressContainer.style.marginBottom = '2.5em';
progressContainer.style.marginLeft = style.ui_windowLeftRightMargin + '%';
progressContainer.style.top = '75%';

progressContainer.style.left = `calc(${contentContainer.getBoundingClientRect().x}px - ${tocContainer.getBoundingClientRect().width}px - ${style.ui_gapWidth}% - ${style.ui_windowLeftRightMargin}%)`;
}
}

function updateTOCUI(isIncreasing) {
const maxWidth = parseFloat(style.ui_maxWidth);
const tocWidthPercent = 100 - parseInt(style.ui_contentWidth) - parseInt(style.ui_windowLeftRightMargin) * 2 - parseInt(style.ui_gapWidth);
const tocWidth = vw(100) <= maxWidth ? tocWidthPercent : tocWidthPercent * maxWidth / vw(100);
style.ui_tocWidth = tocWidth.toString();

if (isVariableDefined(tocContainer)) {
tocContainer.style.width = style.ui_tocWidth + '%';
tocContainer.style.height = style.ui_tocHeight + '%';
if (tocContainer.scrollHeight > (window.innerHeight * 0.5)) {
tocContainer.style.height = '50%';
}

tocContainer.style.left = `calc(${contentContainer.getBoundingClientRect().x}px - ${tocContainer.getBoundingClientRect().width}px - ${style.ui_gapWidth}% - ${style.ui_windowLeftRightMargin}%)`;
}

if (isVariableDefined(progressContainer)) {
progressContainer.style.width = style.ui_tocWidth + '%';
progressContainer.style.left = `calc(${contentContainer.getBoundingClientRect().x}px - ${tocContainer.getBoundingClientRect().width}px - ${style.ui_gapWidth}% - ${style.ui_windowLeftRightMargin}%)`;
}

if (isVariableDefined(paginationContainer)) {
Expand All @@ -88,7 +109,6 @@ function updateTOCUI(isIncreasing) {
}
}

const maxWidth = parseFloat(style.ui_maxWidth);
const paginationLeftPercent = parseInt(style.ui_contentWidth) / 2 + parseInt(style.ui_contentMarginLeft);
const paginationLeft = vw(100) <= maxWidth ? paginationLeftPercent : (paginationLeftPercent * maxWidth / 100 + (vw(100) - maxWidth) / 2) / vw(100) * 100;
style.ui_paginationCenter = paginationLeft.toString();
Expand Down
2 changes: 1 addition & 1 deletion scripts_extension/Firefox/no-ui/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "易笺(无界面版)",
"description": "txt(小说)阅读器:支持本地和云端的所有txt文件,自动排版,自动分页,自动生成目录,记录阅读进度。",
"version": "1.2.8",
"version": "1.2.8.1",
"permissions": [],
"content_scripts": [
{
Expand Down
30 changes: 25 additions & 5 deletions scripts_extension/Firefox/no-ui/scripts/ui_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@ function setMainContentUI() {
}

// UI calculations
// var maxWidth = sh(100)/9*16;
const maxWidth = sh(100)*2;
const maxWidth = sh(100) / 9 * 16;
// const maxWidth = sh(100) * 2;
style.ui_maxWidth = `${maxWidth}px`;

// windowWith = windowLeftRightMargin + tocWidth + gapWidth + contentWidth + windowLeftRightMargin;
style.ui_contentMarginLeft = (100 - parseInt(style.ui_contentWidth) - parseInt(style.ui_windowLeftRightMargin)).toString();
// console.log("IN SETMAINCONTENTUI: style.ui_contentMarginLeft: " + style.ui_contentMarginLeft);
style.ui_tocWidth = (100 - parseInt(style.ui_contentWidth) - parseInt(style.ui_windowLeftRightMargin) * 2 - parseInt(style.ui_gapWidth)).toString();


const tocWidthPercent = 100 - parseInt(style.ui_contentWidth) - parseInt(style.ui_windowLeftRightMargin) * 2 - parseInt(style.ui_gapWidth);
const tocWidth = vw(100) <= maxWidth ? tocWidthPercent : tocWidthPercent * maxWidth / vw(100);
style.ui_tocWidth = tocWidth.toString();

const paginationLeftPercent = parseInt(style.ui_contentWidth) / 2 + parseInt(style.ui_contentMarginLeft);
const paginationLeft = vw(100) <= maxWidth ? paginationLeftPercent : (paginationLeftPercent * maxWidth / 100 + (vw(100) - maxWidth) / 2) / vw(100) * 100;
style.ui_paginationCenter = paginationLeft.toString();
Expand All @@ -47,6 +51,8 @@ function setMainContentUI() {
tocContainer.style.marginRight = '0px';
tocContainer.style.marginBottom = '0px';
tocContainer.style.marginLeft = style.ui_windowLeftRightMargin + '%';

tocContainer.style.left = `calc(${contentContainer.getBoundingClientRect().x}px - ${tocContainer.getBoundingClientRect().width}px - ${style.ui_gapWidth}% - ${style.ui_windowLeftRightMargin}%)`;
}

// Pagination
Expand All @@ -62,15 +68,30 @@ function setMainContentUI() {
progressContainer.style.marginBottom = '2.5em';
progressContainer.style.marginLeft = style.ui_windowLeftRightMargin + '%';
progressContainer.style.top = '75%';

progressContainer.style.left = `calc(${contentContainer.getBoundingClientRect().x}px - ${tocContainer.getBoundingClientRect().width}px - ${style.ui_gapWidth}% - ${style.ui_windowLeftRightMargin}%)`;
}
}

function updateTOCUI(isIncreasing) {
const maxWidth = parseFloat(style.ui_maxWidth);
const tocWidthPercent = 100 - parseInt(style.ui_contentWidth) - parseInt(style.ui_windowLeftRightMargin) * 2 - parseInt(style.ui_gapWidth);
const tocWidth = vw(100) <= maxWidth ? tocWidthPercent : tocWidthPercent * maxWidth / vw(100);
style.ui_tocWidth = tocWidth.toString();

if (isVariableDefined(tocContainer)) {
tocContainer.style.width = style.ui_tocWidth + '%';
tocContainer.style.height = style.ui_tocHeight + '%';
if (tocContainer.scrollHeight > (window.innerHeight * 0.5)) {
tocContainer.style.height = '50%';
}

tocContainer.style.left = `calc(${contentContainer.getBoundingClientRect().x}px - ${tocContainer.getBoundingClientRect().width}px - ${style.ui_gapWidth}% - ${style.ui_windowLeftRightMargin}%)`;
}

if (isVariableDefined(progressContainer)) {
progressContainer.style.width = style.ui_tocWidth + '%';
progressContainer.style.left = `calc(${contentContainer.getBoundingClientRect().x}px - ${tocContainer.getBoundingClientRect().width}px - ${style.ui_gapWidth}% - ${style.ui_windowLeftRightMargin}%)`;
}

if (isVariableDefined(paginationContainer)) {
Expand All @@ -88,7 +109,6 @@ function updateTOCUI(isIncreasing) {
}
}

const maxWidth = parseFloat(style.ui_maxWidth);
const paginationLeftPercent = parseInt(style.ui_contentWidth) / 2 + parseInt(style.ui_contentMarginLeft);
const paginationLeft = vw(100) <= maxWidth ? paginationLeftPercent : (paginationLeftPercent * maxWidth / 100 + (vw(100) - maxWidth) / 2) / vw(100) * 100;
style.ui_paginationCenter = paginationLeft.toString();
Expand Down

0 comments on commit b832d49

Please sign in to comment.