diff --git a/chrome/main.js b/chrome/main.js
index bd8b0b1..f77c480 100644
--- a/chrome/main.js
+++ b/chrome/main.js
@@ -13,7 +13,7 @@ var arabicRegEx = new RegExp("([\u0600-\u06FF\u0750-\u077F\u08a0-\u08ff\uFB50-\u
* This Arabic regex allows and accepts any non Arabic symbols next to Arabic symbols,
* this means that it accepts anything as long as it has some Arabic symbol in it
*/
-var newArabicRegex = new RegExp(".+[\u0600-\u06FF\u0750-\u077F\u08a0-\u08ff\uFB50-\uFDFF\uFE70-\uFEFF\u0600-\u06FF\u0750-\u077F\u08a0-\u08ff\uFB50-\uFDFF\uFE70-\uFEFF]+", "g");
+var newArabicRegex = new RegExp(".+[\u0600-\u06FF\u0750-\u077F\u08a0-\u08ff\uFB50-\uFDFF\uFE70-\uFEFF\u0600-\u06FF\u0750-\u077F\u08a0-\u08ff\uFB50-\uFDFF\uFE70-\uFEFF]+.+", "g");
var defaultFont = "Droid Arabic Naskh";
// TODO figure out a way to have common code in one place instead of all this duplicated code
/** The keys of the {@linkcode chrome.storage.sync} */
@@ -142,34 +142,24 @@ function updateNode(node, textSize, lineHeight, font) {
if (node.nodeValue) {
var newSize = textSize / 100;
var newHeight = lineHeight / 100;
- var newHTML = void 0;
- var element = node.parentElement;
- if (font === "Original") {
- newHTML = "$&";
- var text = node.nodeValue.replace(newArabicRegex, newHTML);
- setNodeHtml(node, text);
- } else {
- updateByAdding(node, newSize, newHeight, font);
- }
+ updateByAdding(node, newSize, newHeight, font);
}
}
-// TODO remove this later
-function updateByStyling(element, textSize, lineHeight, font) {
- element.dir = "rtl";
- element.style.fontSize = textSize + "em";
- element.style.lineHeight = lineHeight + "em";
- element.style.fontFamily = "\"" + font + "\"" + "," + "sans-serif";
- element.setAttribute("wudooh", "true");
-}
+
function updateByAdding(node, textSize, lineHeight, font) {
- var newHTML = "$&";
+ var newHTML;
+ if (font === "Original") {
+ newHTML = "$&";
+ } else {
+ newHTML = "$&";
+ }
var text = node.nodeValue.replace(newArabicRegex, newHTML);
setNodeHtml(node, text);
}
@@ -276,7 +266,6 @@ sync.get(keys, function (fromStorage) {
startObserver(textSize, lineHeight, font);
notify();
}
- log();
});
/**
* Listener to update text if options are modified, the options being text size, line height and font
@@ -294,7 +283,6 @@ runtime.onMessage.addListener(function (message) {
observer = null;
}
startObserver(newSize, newHeight, message.font);
- log();
});
// TODO REMOVE LATER!
function log() {
diff --git a/chrome/main.ts b/chrome/main.ts
index 8f7f89a..5de554d 100644
--- a/chrome/main.ts
+++ b/chrome/main.ts
@@ -17,7 +17,7 @@ const arabicRegEx = new RegExp("([\u0600-\u06FF\u0750-\u077F\u08a0-\u08ff\uFB50-
* This Arabic regex allows and accepts any non Arabic symbols next to Arabic symbols,
* this means that it accepts anything as long as it has some Arabic symbol in it
*/
-const newArabicRegex = new RegExp(".+[\u0600-\u06FF\u0750-\u077F\u08a0-\u08ff\uFB50-\uFDFF\uFE70-\uFEFF\u0600-\u06FF\u0750-\u077F\u08a0-\u08ff\uFB50-\uFDFF\uFE70-\uFEFF]+", "g");
+const newArabicRegex = new RegExp(".+[\u0600-\u06FF\u0750-\u077F\u08a0-\u08ff\uFB50-\uFDFF\uFE70-\uFEFF\u0600-\u06FF\u0750-\u077F\u08a0-\u08ff\uFB50-\uFDFF\uFE70-\uFEFF]+.+", "g");
const defaultFont: string = "Droid Arabic Naskh";
@@ -175,37 +175,25 @@ function updateNode(node: Node, textSize: number, lineHeight: number, font: stri
if (node.nodeValue) {
let newSize: number = textSize / 100;
let newHeight: number = lineHeight / 100;
- let newHTML: string;
- let element: HTMLElement = node.parentElement;
-
- if (font === "Original") {
- newHTML = "$&";
- let text: string = node.nodeValue.replace(newArabicRegex, newHTML);
- setNodeHtml(node, text);
- } else {
- updateByAdding(node, newSize, newHeight, font);
- }
- }
-}
-// TODO remove this later
-function updateByStyling(element: HTMLElement, textSize: number, lineHeight: number, font: string) {
- element.dir = "rtl";
- element.style.fontSize = textSize + "em";
- element.style.lineHeight = lineHeight + "em";
- element.style.fontFamily = "\"" + font + "\"" + "," + "sans-serif";
- element.setAttribute("wudooh", "true");
+ updateByAdding(node, newSize, newHeight, font);
+ }
}
function updateByAdding(node: Node, textSize: number, lineHeight: number, font: string) {
- let newHTML = "$&";
+ let newHTML: string;
+ if (font === "Original") {
+ newHTML = "$&";
+ } else {
+ newHTML = "$&";
+ }
let text: string = node.nodeValue.replace(newArabicRegex, newHTML);
setNodeHtml(node, text);
@@ -320,8 +308,6 @@ sync.get(keys, (fromStorage) => {
startObserver(textSize, lineHeight, font);
notify();
}
-
- log();
});
/**
@@ -341,8 +327,6 @@ runtime.onMessage.addListener((message) => {
observer = null;
}
startObserver(newSize, newHeight, message.font);
-
- log()
});
// TODO REMOVE LATER!