WIP: BugFix407 + Refactor #41

Draft
jinhaolin wants to merge 6 commits from Bug407-JinHaoLin into Alpha-snapshot20240618

[BUGFIX] fillword.js: in function 'read', add cancel current reading before read new words. BugFix 407

[BUGFIX] fillword.js: in function 'read', add cancel current reading before read new words. BugFix 407
jinhaolin added 2 commits 2022-06-13 16:30:26 +08:00

Bug412-JiangLetian 不是我们的提交,请注意

Bug412-JiangLetian 不是我们的提交,请注意
jinhaolin added 1 commit 2022-06-13 16:33:15 +08:00
jinhaolin changed title from Bug407-JinHaoLin to WIP: Bug407-JinHaoLin 2022-06-13 16:33:50 +08:00
jinhaolin changed title from WIP: Bug407-JinHaoLin to WIP: BugFix407 2022-06-13 16:34:07 +08:00
jinhaolin changed title from WIP: BugFix407 to WIP: BugFix407 + Refactor 2022-06-13 16:38:54 +08:00

[REFACTOR] fillword.js: Use const、let、var instead of use var singly. Add comments for understanding.

[REFACTOR] fillword.js: Use const、let、var instead of use var singly. Add comments for understanding.
lijia reviewed 2022-12-04 21:34:08 +08:00
@ -21,2 +26,3 @@
//关闭正在读的单词
function onReadClick(){
isRead = !isRead;
let isRead = !isRead;

let 是块级作用域,在带有let的块中声明的变量仅可在该块中使用。这里我觉得去掉let更好,因为在fillingWord()中也用到了isRead。

let 是块级作用域,在带有let的块中声明的变量仅可在该块中使用。这里我觉得去掉let更好,因为在fillingWord()中也用到了isRead。
lijia reviewed 2022-12-04 21:38:44 +08:00
@ -19,0 +20,4 @@
//关闭当前正在读的单词
reader.cancel()
//创建新的朗读任务
let msg = new SpeechSynthesisUtterance(word);

这里的let我觉得用得很好,限制了msg只在块级作用域起作用

这里的let我觉得用得很好,限制了msg只在块级作用域起作用
lijia reviewed 2022-12-04 21:39:30 +08:00
lijia reviewed 2022-12-04 21:39:52 +08:00
@ -10,1 +8,3 @@
var word = getWord();
//填充字符
function fillingWord(){
let word = getWord();

这里将var改成let我觉得用得很好,使得变量 word 只在块级作用域起作用

这里将var改成let我觉得用得很好,使得变量 `word` 只在块级作用域起作用
lijia reviewed 2022-12-04 21:40:39 +08:00
@ -5,0 +1,4 @@
var isRead = true;
var isChoose = true;
const reader = window.speechSynthesis; // 全局定义朗读者,以便朗读和暂停
//获取字符

注释规范:所有的注释部分"//"后面有且仅有一个空格。

注释规范:所有的注释部分"//"后面有且仅有一个空格。
lijia reviewed 2022-12-04 21:45:55 +08:00
@ -5,3 +5,2 @@
function getWord(){
var word = window.getSelection?window.getSelection():document.selection.createRange().text;
return word;
return window.getSelection?window.getSelection():document.selection.createRange().text;

这里将两行代码化简为一行,看起来不那么繁琐,少定义一个变量也减少出错的概率,但是格式上要注意空格 ?和:的前后都要有空格

这里将两行代码化简为一行,看起来不那么繁琐,少定义一个变量也减少出错的概率,但是格式上要注意空格 ?和:的前后都要有空格
XuLingLing approved these changes 2022-12-13 16:23:30 +08:00
XuLingLing left a comment

在变量前添加var类型,常量前增加const,增强代码可读性

在变量前添加var类型,常量前增加const,增强代码可读性
@ -4,1 +1,3 @@
var isRead = true;
var isChoose = true;
const reader = window.speechSynthesis; // 全局定义朗读者,以便朗读和暂停

在变量前添加var类型,常量前增加const,增强代码可读性

在变量前添加var类型,常量前增加const,增强代码可读性
@ -11,3 +11,3 @@
if (isRead) read(word);
if (!isChoose) return;
var element = document.getElementById("selected-words");
let element = document.getElementById("selected-words");

将var替换为let,是最新的JavaScript语法

将var替换为let,是最新的JavaScript语法

这里有评审错误,将var改为let的原因是:let是块作用域,所以在块作用域内定义的变量,比如说在for循环内,在其外面是不可被访问的,所以for循环推荐用let。将var改为let这点做的很好。

这里有评审错误,将var改为let的原因是:let是块作用域,所以在块作用域内定义的变量,比如说在for循环内,在其外面是不可被访问的,所以for循环推荐用let。将var改为let这点做的很好。
@ -19,0 +18,4 @@
//@word 要朗读的单词
function read(word){
//关闭当前正在读的单词
reader.cancel()

这里完善了read函数,在创建新的朗读时,将旧的或者正在进行的朗读任务取消。相比于修改之前的函数,修改后的函数让整个项目更加严谨。

这里完善了read函数,在创建新的朗读时,将旧的或者正在进行的朗读任务取消。相比于修改之前的函数,修改后的函数让整个项目更加严谨。
XuLingLing approved these changes 2022-12-13 21:33:53 +08:00
@ -12,3 +12,3 @@
if (!isChoose) return;
var element = document.getElementById("selected-words");
let element = document.getElementById("selected-words");
element.value = element.value + " " + word;

我觉得这里的代码可以改为element.value += " " + word;可以减少重复代码,让整个程序看起来更加简洁,结构清晰。

我觉得这里的代码可以改为`element.value += " " + word;`可以减少重复代码,让整个程序看起来更加简洁,结构清晰。
XuLingLing reviewed 2022-12-13 21:36:58 +08:00
@ -19,0 +16,4 @@
document.getElementById("text-content").addEventListener("click", fillingWord, false);
//朗读单词
//@word 要朗读的单词
function read(word){

这里将s改为了word,代码增强可读性,能够快速明白word代表的含义是要朗读的单词。改的好

这里将s改为了word,代码增强可读性,能够快速明白word代表的含义是要朗读的单词。改的好
lawrence added 111 commits 2023-04-26 18:55:36 +08:00
9d420acd8b [REFACTOR] user_service.py: Added id to user name, word and frequency for click to execute AJAX request in JS (#30)
1. Add jquery.js and word_operation.js to the static folder.

2. Changed the return type of the familiar, unfamiliar and deleteword methods of user_service.py.
    ```
    original: return redirect(url_for('userpage', username=username))
    now: return "success"
    ```
3. In order to get elements in JS to make ajax requests we add ids in userpage_get.html for familiar, unfamiliar, delete buttons and so on.

4. When the user's word book was retrieved, the list returned was already sorted in descending order of frequency, so redundant code was removed in userpage_get.html.

Co-authored-by: PeterQiu <www.1392993990@qq.com>
Co-authored-by: Lan Hui <1348141770@qq.com>
Reviewed-on: http://121.4.94.30:3000/mrlan/EnglishPal/pulls/30
Co-authored-by: 邱忠辉 <1392993990@qq.com>
Co-committed-by: 邱忠辉 <1392993990@qq.com>
c21659ba7e Bug477 重构 and 增加功能 (#48)
Co-authored-by: cjybyjk <cjybyjk@zjnu.edu.cn>
Co-authored-by: Lan Hui <1348141770@qq.com>
Reviewed-on: http://121.4.94.30:3000/mrlan/EnglishPal/pulls/48
Co-authored-by: 陈靖毅 <cjybyjk@zjnu.edu.cn>
Co-committed-by: 陈靖毅 <cjybyjk@zjnu.edu.cn>
2c1bc98833 Bug422-XuXing (#46)
增加了返回上一篇的按钮及相关功能的实现,当点击下一篇文章跳转至下一篇时,页面中会增加一个返回上一篇按钮,点击返回上一篇按钮后可以回到上一篇。

Co-authored-by: Lan Hui <1348141770@qq.com>
Reviewed-on: http://121.4.94.30:3000/mrlan/EnglishPal/pulls/46
Co-authored-by: 徐幸 <2567198082@qq.com>
Co-committed-by: 徐幸 <2567198082@qq.com>
ab01b8e19b Hui-Build (#55)
Make English Pal docker run automatically each time after Ubuntu reboot.

Hui

Co-authored-by: Hui Lan <lanhui@zjnu.edu.cn>
Reviewed-on: http://121.4.94.30:3000/mrlan/EnglishPal/pulls/55
Co-authored-by: mrlan <mrlan@noreply.121.4.94.30>
Co-committed-by: mrlan <mrlan@noreply.121.4.94.30>
671df67723 Bug487-WuYuhan-Refactor (#58)
将所有用于用户名验证的逻辑放入到 `UserName` 类中。

Hui

Co-authored-by: Lan Hui <1348141770@qq.com>
Reviewed-on: http://121.4.94.30:3000/mrlan/EnglishPal/pulls/58
Co-authored-by: mrlan <mrlan@noreply.121.4.94.30>
Co-committed-by: mrlan <mrlan@noreply.121.4.94.30>
5c85041135 Bug 512 - 文章朗读问题
在fillwowrd.js中添加了stopRead()函数,将其添加给对应按钮或超链接以终止朗读。
e74f1ff477 Bug505-ZhangYiteng (#61)
bug修改只涉及到account_service.py中新增的5行。
其他增删都是重写reset.html(页面样式和login、signup页面相一致),并将reset、signup、login三个页面的共同样式抽离出独立的css文件。

Co-authored-by: Q_yt <2483750517@qq.com>
Co-authored-by: Hui Lan <lanhui@zjnu.edu.cn>
Reviewed-on: http://121.4.94.30:3000/mrlan/EnglishPal/pulls/61
Co-authored-by: 张艺腾 <2483750517@qq.com>
Co-committed-by: 张艺腾 <2483750517@qq.com>
lawrence added 31 commits 2023-05-29 12:28:53 +08:00
mrlan changed title from WIP: BugFix407 + Refactor to WIP: BugFix407 + Refactor 2024-09-07 07:39:55 +08:00
mrlan changed target branch from master to Alpha-snapshot20240618 2024-09-07 07:39:55 +08:00
This pull request has changes conflicting with the target branch.
  • app/static/js/fillword.js
  • app/templates/userpage_get.html
You can also view command line instructions.

Step 1:

From your project repository, check out a new branch and test the changes.
git checkout -b Bug407-JinHaoLin Alpha-snapshot20240618
git pull origin Bug407-JinHaoLin

Step 2:

Merge the changes and update on Gitea.
git checkout Alpha-snapshot20240618
git merge --no-ff Bug407-JinHaoLin
git push origin Alpha-snapshot20240618
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: mrlan/EnglishPal#41
There is no content yet.