forked from mrlan/EnglishPal
Compare commits
No commits in common. "bug209-yaaqob" and "master" have entirely different histories.
bug209-yaa
...
master
|
@ -5,6 +5,10 @@ from UseSqlite import InsertQuery, RecordQuery
|
||||||
path_prefix = '/var/www/wordfreq/wordfreq/'
|
path_prefix = '/var/www/wordfreq/wordfreq/'
|
||||||
path_prefix = './' # comment this line in deployment
|
path_prefix = './' # comment this line in deployment
|
||||||
|
|
||||||
|
def verify_pass(newpass,oldpass):
|
||||||
|
if(newpass==oldpass):
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def verify_user(username, password):
|
def verify_user(username, password):
|
||||||
rq = RecordQuery(path_prefix + 'static/wordfreqapp.db')
|
rq = RecordQuery(path_prefix + 'static/wordfreqapp.db')
|
||||||
|
@ -47,6 +51,8 @@ def change_password(username, old_password, new_password):
|
||||||
if not verify_user(username, old_password): # 旧密码错误
|
if not verify_user(username, old_password): # 旧密码错误
|
||||||
return False
|
return False
|
||||||
# 将用户名和密码一起加密,以免暴露不同用户的相同密码
|
# 将用户名和密码一起加密,以免暴露不同用户的相同密码
|
||||||
|
if verify_pass(new_password,old_password): #新旧密码一致
|
||||||
|
return False
|
||||||
password = md5(username + new_password)
|
password = md5(username + new_password)
|
||||||
rq = InsertQuery(path_prefix + 'static/wordfreqapp.db')
|
rq = InsertQuery(path_prefix + 'static/wordfreqapp.db')
|
||||||
rq.instructions_with_parameters("UPDATE user SET password=:password WHERE name=:username", dict(
|
rq.instructions_with_parameters("UPDATE user SET password=:password WHERE name=:username", dict(
|
||||||
|
|
|
@ -29,9 +29,10 @@ function highLight() {
|
||||||
if (sel_word1 != null) {
|
if (sel_word1 != null) {
|
||||||
var list = sel_word1.value.split(" ");
|
var list = sel_word1.value.split(" ");
|
||||||
for (var i = 0; i < list.length; ++i) {
|
for (var i = 0; i < list.length; ++i) {
|
||||||
list[i] = list[i].replace(/(^\s*)|(\s*$)/g, "");
|
list[i] = list[i].replace(/(^\s*)|(\s*$)/g, "");//消除字符串两边空字符
|
||||||
if (list[i] != "" && "<mark>".indexOf(list[i]) == -1 && "</mark>".indexOf(list[i]) == -1) {
|
if (list[i] != "" && "<mark>".indexOf(list[i]) == -1 && "</mark>".indexOf(list[i]) == -1) {
|
||||||
txt = txt.replace(new RegExp(list[i], "g"), "<mark>" + list[i] + "</mark>");
|
|
||||||
|
txt = txt.replace(new RegExp("\\s"+list[i]+"\\s", "g"), " <mark>" + list[i] + "</mark> ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +41,7 @@ function highLight() {
|
||||||
for (var i = 0; i < list2.length; ++i) {
|
for (var i = 0; i < list2.length; ++i) {
|
||||||
list2[i] = list2[i].replace(/(^\s*)|(\s*$)/g, "");
|
list2[i] = list2[i].replace(/(^\s*)|(\s*$)/g, "");
|
||||||
if (list2[i] != "" && "<mark>".indexOf(list2[i]) == -1 && "</mark>".indexOf(list2[i]) == -1) {
|
if (list2[i] != "" && "<mark>".indexOf(list2[i]) == -1 && "</mark>".indexOf(list2[i]) == -1) {
|
||||||
txt = txt.replace(new RegExp(list2[i], "g"), "<mark>" + list2[i] + "</mark>");
|
txt = txt.replace(new RegExp("\\s"+list2[i]+"\\s", "g"), " <mark>" + list2[i] + "</mark> ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,64 +1,45 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8">
|
||||||
<meta
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=3.0, user-scalable=yes" />
|
||||||
name="viewport"
|
|
||||||
content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=3.0, user-scalable=yes"
|
|
||||||
/>
|
|
||||||
<meta name="format-detection" content="telephone=no" />
|
<meta name="format-detection" content="telephone=no" />
|
||||||
|
|
||||||
{{ yml['header'] | safe }} {% if yml['css']['item'] %} {% for css in
|
{{ yml['header'] | safe }}
|
||||||
yml['css']['item'] %}
|
{% if yml['css']['item'] %}
|
||||||
<link href="{{ css }}" rel="stylesheet" />
|
{% for css in yml['css']['item'] %}
|
||||||
{% endfor %} {% endif %} {% if yml['js']['head'] %} {% for js in
|
<link href="{{ css }}" rel="stylesheet">
|
||||||
yml['js']['head'] %}
|
{% endfor %}
|
||||||
<script src="{{ js }}"></script>
|
{% endif %}
|
||||||
{% endfor %} {% endif %}
|
{% if yml['js']['head'] %}
|
||||||
|
{% for js in yml['js']['head'] %}
|
||||||
|
<script src="{{ js }}" ></script>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<title>EnglishPal Study Room for {{username}}</title>
|
<title>EnglishPal Study Room for {{username}}</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<p>勾选不认识的单词</p>
|
<p>勾选不认识的单词</p>
|
||||||
<form method="post" action="/{{username}}/mark">
|
<form method="post" action="/{{username}}/mark">
|
||||||
<input type="submit" name="add-btn" value="加入我的生词簿" />
|
<input type="submit" name="add-btn" value="加入我的生词簿"/>
|
||||||
<input
|
{% for x in lst %}
|
||||||
onclick="checkall()"
|
{% set word = x[0]%}
|
||||||
type="button"
|
|
||||||
name="add-btn"
|
|
||||||
value="select all"
|
|
||||||
/>
|
|
||||||
{% for x in lst %} {% set word = x[0]%}
|
|
||||||
<p>
|
<p>
|
||||||
<font color="grey">{{loop.index}}</font>
|
<font color="grey">{{loop.index}}</font>
|
||||||
:
|
:
|
||||||
<a
|
<a href='http://youdao.com/w/eng/{{word}}/#keyfrom=dict2.index' title={{word}}>{{word}}</a>
|
||||||
href="http://youdao.com/w/eng/{{word}}/#keyfrom=dict2.index"
|
|
||||||
title="{{word}}"
|
|
||||||
>{{word}}</a
|
|
||||||
>
|
|
||||||
({{x[1]}})
|
({{x[1]}})
|
||||||
<input
|
<input type="checkbox" name="marked" value={{word}}>
|
||||||
class="select-all"
|
|
||||||
type="checkbox"
|
|
||||||
name="marked"
|
|
||||||
value="{{word}}"
|
|
||||||
/>
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</form>
|
</form>
|
||||||
{{ yml['footer'] | safe }} {% if yml['js']['bottom'] %} {% for js in
|
{{ yml['footer'] | safe }}
|
||||||
yml['js']['bottom'] %}
|
{% if yml['js']['bottom'] %}
|
||||||
<script src="{{ js }}"></script>
|
{% for js in yml['js']['bottom'] %}
|
||||||
<script>
|
<script src="{{ js }}" ></script>
|
||||||
function checkall() {
|
{% endfor %}
|
||||||
const selectAllCheckBox = document.querySelectorAll(".select-all");
|
{% endif %}
|
||||||
for (let i = 0; i < selectAllCheckBox.length; i++) {
|
</body>
|
||||||
selectAllCheckBox[i].checked = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
{% endfor %} {% endif %}
|
|
||||||
</body>
|
|
||||||
</html>
|
</html>
|
BIN
wordfreqapp.db
BIN
wordfreqapp.db
Binary file not shown.
Loading…
Reference in New Issue