Compare commits

..

1 Commits

Author SHA1 Message Date
安秀秀 78e5524bae userpage_post.html: update userpage_post.html. 2022-05-29 15:19:07 +08:00
3 changed files with 29 additions and 11 deletions

View File

@ -5,10 +5,6 @@ from UseSqlite import InsertQuery, RecordQuery
path_prefix = '/var/www/wordfreq/wordfreq/'
path_prefix = './' # comment this line in deployment
def verify_pass(newpass,oldpass):
if(newpass==oldpass):
return True
def verify_user(username, password):
rq = RecordQuery(path_prefix + 'static/wordfreqapp.db')
@ -51,8 +47,6 @@ def change_password(username, old_password, new_password):
if not verify_user(username, old_password): # 旧密码错误
return False
# 将用户名和密码一起加密,以免暴露不同用户的相同密码
if verify_pass(new_password,old_password): #新旧密码一致
return False
password = md5(username + new_password)
rq = InsertQuery(path_prefix + 'static/wordfreqapp.db')
rq.instructions_with_parameters("UPDATE user SET password=:password WHERE name=:username", dict(

View File

@ -29,10 +29,9 @@ function highLight() {
if (sel_word1 != null) {
var list = sel_word1.value.split(" ");
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) {
txt = txt.replace(new RegExp("\\s"+list[i]+"\\s", "g"), " <mark>" + list[i] + "</mark> ");
txt = txt.replace(new RegExp(list[i], "g"), "<mark>" + list[i] + "</mark>");
}
}
}
@ -41,7 +40,7 @@ function highLight() {
for (var i = 0; i < list2.length; ++i) {
list2[i] = list2[i].replace(/(^\s*)|(\s*$)/g, "");
if (list2[i] != "" && "<mark>".indexOf(list2[i]) == -1 && "</mark>".indexOf(list2[i]) == -1) {
txt = txt.replace(new RegExp("\\s"+list2[i]+"\\s", "g"), " <mark>" + list2[i] + "</mark> ");
txt = txt.replace(new RegExp(list2[i], "g"), "<mark>" + list2[i] + "</mark>");
}
}
}

View File

@ -19,10 +19,19 @@
<title>EnglishPal Study Room for {{username}}</title>
</head>
<style>
#checkall{
opacity: 0;
}
#span{
opacity: 0;
}
</style>
<body>
<p>勾选不认识的单词</p>
<form method="post" action="/{{username}}/mark">
<input type="submit" name="add-btn" value="加入我的生词簿"/>
<input type="checkbox" name="add-btn" value="全选"id="checkall"/><span id="span">全选</span><br>
{% for x in lst %}
{% set word = x[0]%}
<p>
@ -32,7 +41,6 @@
({{x[1]}})
<input type="checkbox" name="marked" value={{word}}>
</p>
{% endfor %}
</form>
{{ yml['footer'] | safe }}
@ -41,5 +49,22 @@
<script src="{{ js }}" ></script>
{% endfor %}
{% endif %}
<script>
let all=document.getElementById("checkall");
let span=document.getElementById("span");
let checks=document.getElementsByName("marked")
if(checks.length>10){
all.style.opacity='1'
span.style.opacity='1'
}
all.addEventListener("click",function(){ //在按钮处设置监听
let flag=all.checked; //把按钮的checked值赋给flag
for(let i=0;i<checks.length;i++){
//循环多选框元素集把多选框的checked改成flag
//当btn选中其他也选中状态跟随
checks[i].checked=flag;
}
})
</script>
</body>
</html>