Skip to content

Commit 414e21f

Browse files
committed
v1.1.4 Release
Fixed a fairly serious bug that affected only new users of the app. Didn't catch this before because I didn't clear my synchronized settings for a long time... Fixed a bug where if a page did some funky dynamic loading and unloaded the popup element, it would not create a new one.
1 parent c2e624b commit 414e21f

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

js/liuchan.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ class LiuChan {
8989
highlightText: true,
9090
highlightInput: false,
9191
scaleOnZoom: true,
92-
showOnKey: "0",
92+
showOnKey: 0,
9393
disableKeys: false
9494
},
9595
styling: {
9696
useCustomization: false,
97-
customColors: ['#FFFFE0', '#D7D3AF', 'rgba(66,8,8,0.10)'],
97+
customColors: ["#ffffe0", "#d7d3af", "RGBA(0,8,8,0.1)"],
9898
borderThickness: 2,
9999
borderRadius: 8
100100
},
@@ -112,11 +112,11 @@ class LiuChan {
112112
displayHelp: true,
113113
lineEnding: 'n',
114114
copySeparator: 'tab',
115-
maxClipCopyEntries: 7,
115+
maxClipCopyEntries: "7",
116116
ttsDialect: "zh-CN",
117117
ttsSpeed: 0.9,
118118
useCustomTones: false,
119-
customTones: ['#F2777A', '#99CC99', '#6699CC', '#CC99CC', '#CCCCCC', '#66CCCC'],
119+
customTones: ["#f2777a", "#99cc99", "#6699cc", "#cc99cc", "#cccccc", "#66cccc"],
120120
version: CURRENT_VERSION
121121
};
122122

js/liuchancontent.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ const lcxContent = {
4848
window.onresize = this.setZoomLevel;
4949
}
5050

51+
this.createPopup();
52+
this.enabled = true;
53+
},
54+
55+
createPopup: function() {
5156
// Create and append stylesheet
5257
this.loadStyleSheet();
5358

@@ -64,9 +69,9 @@ const lcxContent = {
6469
popup.style.setProperty('display', 'none', 'important');
6570

6671
this.setCustomStyling(popup);
67-
this.setZoomLevel();
72+
this.setZoomLevel(popup);
6873

69-
this.enabled = true;
74+
return popup;
7075
},
7176

7277
loadStyleSheet: function() {
@@ -143,8 +148,8 @@ const lcxContent = {
143148
});
144149
},
145150

146-
setZoomLevel: function () {
147-
const popup = window.document.getElementById("liuchan-window");
151+
setZoomLevel: function (popup) {
152+
//const popup = window.document.getElementById("liuchan-window");
148153
const zoomLevel = window.devicePixelRatio * 100;
149154

150155
// This functions scales the popup as the user zooms in order to make it seem as if it's not scaling. Yep.
@@ -169,7 +174,11 @@ const lcxContent = {
169174

170175
showPopup: function (text, elem, x, y) {
171176
const wd = window.document;
172-
const popup = wd.getElementById('liuchan-window');
177+
let popup = wd.getElementById('liuchan-window');
178+
if (popup === null) {
179+
// Sometimes pages do some funky dynamic loading and we lose the popup, so we recreate it.
180+
popup = this.createPopup();
181+
}
173182

174183
if (isNaN(x) || isNaN(y)) {
175184
x = 0;

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 2,
33
"name": "LiuChan Chinese Popup Dictionary",
44
"short_name": "LiuChan",
5-
"version": "1.1.3",
5+
"version": "1.1.4",
66
"options_page": "html/options.html",
77
"options_ui": {
88
"page": "html/options.html"

0 commit comments

Comments
 (0)