Skip to content

Commit bd7f07b

Browse files
committed
Fixed: some JS code was still using frames.
Fixed: click on "add_term" made right frames open and close instant Changed: do_text.php can use "text" instead of "start". Added: info_export_template.htm from the official documentation.
1 parent efdb850 commit bd7f07b

14 files changed

Lines changed: 460 additions & 74 deletions

‎all_words_wellknown.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@
7979
?>
8080
<script type="text/javascript">
8181
//<![CDATA[
82-
var contexth = window.parent.frames['h'].document;
82+
const context = window.parent.document;
8383
<?php echo $javascript; ?>
84-
$('#learnstatus', contexth).html('<?php echo addslashes(texttodocount2($_REQUEST['text'])); ?>');
85-
window.parent.frames['l'].setTimeout('cClick()', 1000);
84+
$('#learnstatus', context).html('<?php echo addslashes(texttodocount2($_REQUEST['text'])); ?>');
85+
window.parent.setTimeout('cClick()', 1000);
8686
//]]>
8787
</script>
8888
<?php

‎bulk_translate_words.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@
4949
echo "</script>";
5050
flush();
5151
do_mysqli_query('UPDATE ' . $tbpref . 'textitems2 join ' . $tbpref . 'words on lower(Ti2Text)=WoTextLC AND Ti2WordCount =1 and Ti2LgID=WoLgID and WoID > ' . $max . ' set Ti2WoID = WoID');
52-
echo "<script type=\"text/javascript\">$('#learnstatus', window.parent.frames['h'].document).html('",addslashes(texttodocount2($tid)),"');$('#displ_message').remove();";
52+
echo "<script type=\"text/javascript\">$('#learnstatus', window.parent.document).html('",addslashes(texttodocount2($tid)),"');$('#displ_message').remove();";
5353
if(!isset($pos)) {
54-
echo "window.parent.frames['l'].focus();window.parent.frames['l'].setTimeout('cClick()', 100);";
54+
echo "window.parent.getElementById('frame-l').focus();window.parent.setTimeout('cClick()', 100);";
5555
}
5656
echo "</script>";
5757
flush();

‎delete_mword.php‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@
3030
?>
3131
<script type="text/javascript">
3232
//<![CDATA[
33-
var context = window.parent.frames['l'].document;
34-
var contexth = window.parent.frames['h'].document;
33+
var context = window.parent.document;
3534
$('.word<?php echo $wid; ?>', context).each(function(){
3635
sid = $(this).parent();
3736
$(this).remove();
@@ -49,9 +48,9 @@
4948
?>
5049

5150
});
52-
$('#learnstatus', contexth).html('<?php echo addslashes(texttodocount2($tid)); ?>');
53-
window.parent.frames['l'].focus();
54-
window.parent.frames['l'].setTimeout('cClick()', 100);
51+
$('#learnstatus', context).html('<?php echo addslashes(texttodocount2($tid)); ?>');
52+
window.parent.focus();
53+
window.parent.setTimeout('cClick()', 100);
5554
//]]>
5655
</script>
5756
<?php

‎delete_word.php‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ function delete_word_javascript($wid, $tid)
7272
?>
7373
<script type="text/javascript">
7474
//<![CDATA[
75-
var context = window.parent.document.getElementById('frame-l');
76-
var contexth = window.parent.document.getElementById('frame-h');
75+
var context = window.parent.document;
7776
var title;
7877
if (window.parent.document.getElementById('frame-l').JQ_TOOLTIP) {
7978
title = ''
@@ -91,9 +90,8 @@ function delete_word_javascript($wid, $tid)
9190
.attr('data_wid','')
9291
.attr('title', title)
9392
.removeAttr("data_img");
94-
$('#learnstatus', contexth).html('<?php echo addslashes(texttodocount2($tid)); ?>');
93+
$('#learnstatus', context).html('<?php echo addslashes(texttodocount2($tid)); ?>');
9594
window.parent.document.getElementById('frame-l').focus();
96-
//window.parent.frames['l'].setTimeout('cClick()', 100);
9795
window.parent.setTimeout('cClick()', 100);
9896
//]]>
9997
</script>

‎do_test.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
* Call: do_test.php?lang=[langid]
99
* Call: do_test.php?text=[textid]
1010
* Call: do_test.php?selection=1 (SQL via $_SESSION['testsql'])
11+
* Call: do_test.php?type=table for a table of words
12+
* Call: do_test.php?type=[1-5] for a test of words.
1113
*
1214
* @package Lwt
1315
* @author LWT Project <lwt-project@hotmail.com>

‎do_text.php‎

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* \file
55
* \brief Start Reading a text (frameset)
66
*
7-
* Call: do_text.php?start=[textid]
7+
* Call: do_text.php?text=[textid]
88
* Create the main window when reading texts.
99
*
1010
* @package Lwt
@@ -19,16 +19,35 @@
1919
require_once 'do_text_header.php';
2020
require_once 'do_text_text.php';
2121

22+
/**
23+
* Get text ID (if possible).
24+
*
25+
* Text ID if first looked at int the 'text' parameter. If not found, then look at 'start'.
26+
*
27+
* @return int|null Text ID or null
28+
*/
29+
function get_text_id() {
30+
if (isset($_REQUEST['text']) && is_integer($_REQUEST['text'])) {
31+
return (int)$_REQUEST['text'];
32+
}
33+
if (isset($_REQUEST['start']) && is_integer($_REQUEST['start'])) {
34+
return (int)$_REQUEST['start'];
35+
}
36+
return null;
37+
}
38+
2239
/**
2340
* Echo the page content for the mobile version of do_text.
2441
*
42+
* @param int $textid Text ID
43+
*
2544
* @return void
2645
*/
27-
function do_text_mobile_content() {
46+
function do_text_mobile_content($textid) {
2847
?>
2948
<div id="frame-h">
3049
<iframe id="frame-h-2"
31-
src="do_text_header.php?text=<?php echo $_REQUEST['start']; ?>"
50+
src="do_text_header.php?text=<?php echo $textid; ?>"
3251
scrolling="yes" name="h">
3352
</iframe>
3453
</div>
@@ -37,7 +56,7 @@ function do_text_mobile_content() {
3756
</div>
3857
<div id="frame-l">
3958
<iframe id="frame-l-2"
40-
src="do_text_text.php?text=<?php echo $_REQUEST['start']; ?>" scrolling="yes" name="l">
59+
src="do_text_text.php?text=<?php echo $textid; ?>" scrolling="yes" name="l">
4160
</iframe>
4261
</div>
4362
<div id="frame-ru">
@@ -50,19 +69,20 @@ function do_text_mobile_content() {
5069
/**
5170
* Echo the page content for the desktop version of do_text.
5271
*
53-
* @param string|null Audio URI
72+
* @param int $textid Text ID
73+
* @param string|null $audio Audio URI
5474
*
5575
* @return void
5676
*/
57-
function do_text_desktop_content($audio) {
77+
function do_text_desktop_content($textid, $audio) {
5878
?>
59-
<div style="width: 95%; height: 100%;" onclick="setTimeout(hideRightFrames, 1000);">
79+
<div style="width: 95%; height: 100%;">
6080
<div id="frame-h">
61-
<?php do_text_header_content($_REQUEST['start'], true); ?>
81+
<?php do_text_header_content($textid, true); ?>
6282
</div>
6383
<hr />
6484
<div id="frame-l">
65-
<?php do_text_text_content($_REQUEST['start'], true); ?>
85+
<?php do_text_text_content($textid, true); ?>
6686
</div>
6787
</div>
6888
<div id="frames-r" style="position: fixed; top: 0; right: -100%; width: 100%; height: 100%;"
@@ -84,13 +104,14 @@ function do_text_desktop_content($audio) {
84104
/**
85105
* Echo the text page.
86106
*
87-
* @param bool Set to true if you want the mobile version of the page.
107+
* @param int $textit Text ID
108+
* @param bool $mobile Set to true if you want the mobile version of the page.
88109
*
89110
* @return void
90111
*
91112
* @global string $tbpref Database table prefix.
92113
*/
93-
function do_text_page($mobile)
114+
function do_text_page($textid, $mobile)
94115
{
95116
global $tbpref;
96117

@@ -106,16 +127,16 @@ function do_text_page($mobile)
106127
if ($mobile && false) {
107128
do_frameset_mobile_css();
108129
do_frameset_mobile_js($audio);
109-
do_text_mobile_content();
130+
do_text_mobile_content($textid);
110131
} else {
111132
// Not mobile
112-
do_text_desktop_content($audio);
133+
do_text_desktop_content($textid, $audio);
113134
}
114135
pageend();
115136
}
116137

117-
if (isset($_REQUEST['start'])) {
118-
do_text_page(is_mobile());
138+
if (get_text_id() !== null) {
139+
do_text_page(get_text_id(), is_mobile());
119140
} else {
120141
// Document not ready
121142
header("Location: edit_texts.php");

‎do_text_header.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ function do_text_header_content($textid, $only_body=true): void
311311
}
312312

313313
// Show the content automatically if text is in the request
314-
if (getreq('text')) {
314+
if (false && getreq('text')) {
315315
do_text_header_content(getreq('text'), false);
316316
}
317317
?>

‎do_text_text.php‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
*
77
* Call: do_text_text.php?text=[textid]
88
*
9-
* @author LWT Project <lwt-project@hotmail.com>
10-
* @since 1.0.3
9+
* @package Lwt
10+
* @author LWT Project <lwt-project@hotmail.com>
11+
* @license Unlicense <http://unlicense.org/>
12+
* @link https://hugofara.github.io/lwt/docs/html/do__text__text_8php.html
13+
* @since 1.0.3
1114
*/
1215

1316
require_once 'inc/session_utility.php';
@@ -470,7 +473,7 @@ function do_text_text_content($textid, $only_body=true): void
470473
}
471474

472475
// This code runs when calling this script, be careful!
473-
if (isset($_REQUEST['text'])) {
476+
if (false && isset($_REQUEST['text'])) {
474477
do_text_text_content($_REQUEST['text'], false);
475478
}
476479
?>

0 commit comments

Comments
 (0)