Skip to content

Commit

Permalink
[Feature] Highlight to speech (#147)
Browse files Browse the repository at this point in the history
Adds the highlight to speech feature. Adds the execution permission on `INSTALL.sh`?
  • Loading branch information
ProgramComputer authored Dec 30, 2023
1 parent 403b2b4 commit e764e9a
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 3 deletions.
Empty file modified INSTALL.sh
100644 → 100755
Empty file.
1 change: 1 addition & 0 deletions do_text_text.php
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,7 @@ function do_text_text_content($textid, $only_body=true): void
'TID' => $textid,
'ADDFILTER' => makeStatusClassFilter((int)$visit_status),
'JQ_TOOLTIP' => getSettingWithDefault('set-tooltip-mode') == 2 ? 1 : 0,
'HTS' => getSettingWithDefault('set-hts'),
// Add new globals
'ANNOTATIONS_MODE' => $mode_trans,
'POS' => $pos
Expand Down
3 changes: 3 additions & 0 deletions inc/kernel_utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ function get_setting_data()
'set-tts' => array(
"dft" => '1', "num" => 0
),
'set-hts' => array(
"dft" => '1', "num" => 0
),
'set-term-sentence-count' => array(
"dft" => '1', "num" => 0
),
Expand Down
14 changes: 14 additions & 0 deletions inc/session_utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -2407,6 +2407,20 @@ function get_annotation_position_selectoptions($v): string
$r .= ">Above</option>";
return $r;
}
// -------------------------------------------------------------

function get_hts_selectoptions($v): string
{
if (! isset($v) ) { $v = 1;
}
$r = "<option value=\"1\"" . get_selected($v, 1);
$r .= ">Never</option>";
$r .= "<option value=\"2\"" . get_selected($v, 2);
$r .= ">On Click</option>";
$r .= "<option value=\"3\"" . get_selected($v, 3);
$r .= ">On Hover</option>";
return $r;
}

// -------------------------------------------------------------

Expand Down
5 changes: 3 additions & 2 deletions js/pgm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 21 additions & 1 deletion settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@
1 : 0
)
);
saveSetting(
'set-hts',
$_REQUEST['set-hts']
);

saveSetting(
'set-archivedtexts-per-page',
Expand Down Expand Up @@ -568,7 +572,7 @@
</tr>
<!-- ******************************************************* -->
<tr>
<th class="th1 center">Text to Speech</th>
<th class="th1 center" rowspan="2">Text to Speech</th>
<td class="td1 center">Save Audio Files to Disk</td>
<td class="td1 center">
<input type="checkbox" name="set-tts" value="1"
Expand All @@ -580,6 +584,22 @@
</td>
</tr>
<!-- ******************************************************* -->
<tr>
<td class="td1 center">Read word aloud</td>
<td class="td1 center">
<select name="set-hts" class="notempty respinput">
<?php
echo get_hts_selectoptions(
getSettingWithDefault('set-hts')
);
?>
</select>
</td>
<td class="td1 center">
<img src="icn/status-busy.png" title="Field must not be empty" alt="Field must not be empty" />
</td>
</tr>
<!-- ******************************************************* -->
<tr>
<th class="th1 center" rowspan="7">Text, Term,<br />Newsfeed &amp;<br />Tag Tables</th>
<td class="td1 center">Texts per Page</td>
Expand Down
9 changes: 9 additions & 0 deletions src/js/jq_pgm.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ RTL = 0;
ANN_ARRAY = {};
DELIMITER = '';
JQ_TOOLTIP = 0;
HTS = 0;

/**************************************************************
LWT jQuery functions
Expand Down Expand Up @@ -714,6 +715,10 @@ function mword_click_event_do_text_text () {
$(this).attr('data_wid'), status, $(this).attr('data_code'), ann
);
}
if (HTS == 2) {
const lg = getLangFromDict(WBLINK3);
readTextAloud($(this).text(), lg);
}
return false;
}

Expand Down Expand Up @@ -875,6 +880,10 @@ function word_hover_over () {
if (JQ_TOOLTIP) {
$(this).trigger('mouseover');
}
if (HTS == 3) {
const lg = getLangFromDict(WBLINK3);
readTextAloud($(this).text(), lg);
}
}
}

Expand Down

0 comments on commit e764e9a

Please sign in to comment.