Skip to content
This repository has been archived by the owner on Mar 29, 2023. It is now read-only.

[Work in Progress] Functionality to highlight user list #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions words_discoverer_chrome/adjust.html
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@
<span class="hlExample">Example of <span id="iql"></span><span id="idiomHlText">highlighted English</span><span id="iqr"></span> expression.</span><br>
<br>
</div>

<input type="checkbox" class="checkbox" id="userWordsEnabled"><span class="cbHeaderLabel">Enable user words highlighting</span><br>

<button class="longButton" id="saveVisuals">__MSG_saveVisuals__</button>
</fieldset>
</div>
Expand Down
1 change: 1 addition & 0 deletions words_discoverer_chrome/adjust.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ function process_display() {
handle_rb_loop(ib_rb_ids, wd_hl_settings.idiomParams, "backgroundColor");

add_cb_event_listener("wordsEnabled", wd_hl_settings.wordParams, "enabled");
add_cb_event_listener("userWordsEnabled", wd_hl_settings.userWordParams, "enabled");
add_cb_event_listener("idiomsEnabled", wd_hl_settings.idiomParams, "enabled");
add_cb_event_listener("wordsBold", wd_hl_settings.wordParams, "bold");
add_cb_event_listener("idiomsBold", wd_hl_settings.idiomParams, "bold");
Expand Down
10 changes: 10 additions & 0 deletions words_discoverer_chrome/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,9 +466,19 @@ function initialize_extension() {
useColor: true,
color: "blue"
};
user_word_hl_params = {
enabled: true,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understing was that the list should be disabled by default (until user uploads it)

quoted: false,
bold: true,
useBackground: false,
backgroundColor: "rgb(255, 248, 220)",
useColor: true,
color: "green"
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing semicolon!

wd_hl_settings = {
wordParams: word_hl_params,
idiomParams: idiom_hl_params,
userWordParams: user_word_hl_params
};
chrome.storage.local.set({"wd_hl_settings": wd_hl_settings});
}
Expand Down
16 changes: 15 additions & 1 deletion words_discoverer_chrome/content_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,17 @@ function text_to_hl_nodes(text, dst) {
}
num_nonempty += 1;
var match = undefined;

//finding user vocabulary
if (!match && wd_hl_settings.userWordParams.enabled) {
if (user_vocabulary.hasOwnProperty(tokens[wnum])) {
match = {normalized: tokens[wnum], kind: "userWord", begin: ibegin, end: ibegin + tokens[wnum].length};
ibegin += tokens[wnum].length + 1;
wnum += 1;
num_good += 1;
}
}

if (!match && wd_hl_settings.idiomParams.enabled) {
var lwnum = wnum; //look ahead word number
var libegin = ibegin; //look ahead word begin
Expand Down Expand Up @@ -236,7 +247,10 @@ function text_to_hl_nodes(text, dst) {
for (var i = 0; i < matches.length; i++) {
text_style = undefined;
match = matches[i];
if (match.kind === "lemma") {
if (match.kind == "userWord") {
hlParams = wd_hl_settings.userWordParams;
text_style = make_hl_style(hlParams);
} else if (match.kind === "lemma") {
hlParams = wd_hl_settings.wordParams;
text_style = make_hl_style(hlParams);
} else if (match.kind === "idiom") {
Expand Down