From 175e086a781bb2a4b2cbf837e7eb975ca5c2a003 Mon Sep 17 00:00:00 2001 From: xiongjiaming <3190186054@qq.com> Date: Mon, 20 May 2024 20:53:14 +0800 Subject: [PATCH] Fix bug 540 --- app/templates/userpage_get.html | 30 ++++++++++++++++++ app/test/test_bug540_xiongjiaming.py | 47 ++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 app/test/test_bug540_xiongjiaming.py diff --git a/app/templates/userpage_get.html b/app/templates/userpage_get.html index edb8bf2..b0cfd27 100644 --- a/app/templates/userpage_get.html +++ b/app/templates/userpage_get.html @@ -112,6 +112,11 @@ 生词高亮 大声朗读 划词入库 + +
@@ -287,6 +292,31 @@ $('#read_all').show(); } } + function saveArticle() { + const articleTitle = document.getElementById('article_title').innerText; // 获取文章标题 + const article = document.getElementById('article').innerText; // 获取文章内容 + const savedArticlesDropdown = document.getElementById('saved_articles_dropdown'); // 获取下拉菜单 + var option = document.createElement('option'); // 创建一个新的下拉菜单选项 + option.text = articleTitle; // 将文章标题作为选项文本 + option.value = article; // 将文章内容作为选项值 + option.title = article; // 将文章内容作为工具提示内容 + savedArticlesDropdown.appendChild(option); // 将选项添加到下拉菜单中 + localStorage.setItem(articleTitle, article) //将标记文章存储到localstorage中 + alert("文章已标记") +} + window.onload = function() { + const savedArticlesDropdown = document.getElementById('saved_articles_dropdown'); + for (let i = 0; i < localStorage.length; i++) { + const key = localStorage.key(i); // 获取localStorage中的键 + const value = localStorage.getItem(key); // 获取localStorage中的值 + // 创建一个新的下拉菜单选项 + var option = document.createElement('option'); + option.text = key; // 将文章标题作为选项文本 + option.value = value; // 将文章内容作为选项值 + option.title = value; // 将文章内容作为工具提示内容 + savedArticlesDropdown.appendChild(option); // 将选项添加到下拉菜单中 + } +}