上传文件至 app/templates

pull/127/head
lixiaofeng 2024-05-27 22:47:58 +08:00
parent 9aa4dc1e38
commit 045352f8aa
1 changed files with 11 additions and 53 deletions

View File

@ -109,9 +109,9 @@
</div> </div>
</div> </div>
<input type="checkbox" id="highlightCheckbox" onclick="toggleHighlighting()" />生词高亮 <input type="checkbox" onclick="toggleHighlighting()" checked/>生词高亮
<input type="checkbox" id="readCheckbox" onclick="onReadClick()" />大声朗读 <input type="checkbox" onclick="onReadClick()" checked/>大声朗读
<input type="checkbox" id="chooseCheckbox" onclick="onChooseClick()" />划词入库 <input type="checkbox" onclick="onChooseClick()" checked id="test1"/>划词入库
<div class="range"> <div class="range">
<div class="field"> <div class="field">
<div class="sliderValue"> <div class="sliderValue">
@ -124,7 +124,7 @@
<form method="post" action="/{{ username }}/userpage"> <form method="post" action="/{{ username }}/userpage">
<textarea name="content" id="selected-words" rows="10" cols="120"></textarea><br/> <textarea name="content" id="selected-words" rows="10" cols="120"></textarea><br/>
<button class="btn btn-primary btn-lg" type="submit" onclick="Reader.stopRead()">把生词加入我的生词库</button> <button class="btn btn-primary btn-lg" type="submit" onclick="Reader.stopRead()">把生词加入我的生词库</button>
<button class="btn btn-primary btn-lg" type="reset" onclick="clearSelectedWords()">清除</button> <button class="btn btn-primary btn-lg" type="reset">清除</button>
</form> </form>
{% if session.get['thisWord'] %} {% if session.get['thisWord'] %}
<script type="text/javascript"> <script type="text/javascript">
@ -166,6 +166,7 @@
<input id="selected-words2" type="hidden" value="{{ words }}"> <input id="selected-words2" type="hidden" value="{{ words }}">
{% endif %} {% endif %}
</div> </div>
<label id="selected-words3" type="hidden">
{{ yml['footer'] | safe }} {{ yml['footer'] | safe }}
{% if yml['js']['bottom'] %} {% if yml['js']['bottom'] %}
{% for js in yml['js']['bottom'] %} {% for js in yml['js']['bottom'] %}
@ -174,54 +175,11 @@
{% endif %} {% endif %}
<script type="text/javascript"> <script type="text/javascript">
window.onload = function () { // 页面加载时执行 window.onload = function () { // 页面加载时执行
const settings = {
// initialize settings from localStorage
highlightChecked: localStorage.getItem('highlightChecked') !== 'false', // localStorage stores strings, default to true. same below
readChecked: localStorage.getItem('readChecked') !== 'false',
chooseChecked: localStorage.getItem('chooseChecked') !== 'false',
rangeValue: localStorage.getItem('rangeValue') || '1',
selectedWords: localStorage.getItem('selectedWords') || ''
};
const elements = {
highlightCheckbox: document.querySelector('#highlightCheckbox'),
readCheckbox: document.querySelector('#readCheckbox'),
chooseCheckbox: document.querySelector('#chooseCheckbox'),
rangeComponent: document.querySelector('#rangeComponent'),
rangeValueDisplay: document.querySelector('#rangeValue'),
selectedWordsInput: document.querySelector('#selected-words')
};
// 应用设置到页面元素
elements.highlightCheckbox.checked = settings.highlightChecked;
elements.readCheckbox.checked = settings.readChecked;
elements.chooseCheckbox.checked = settings.chooseChecked;
elements.rangeComponent.value = settings.rangeValue;
elements.rangeValueDisplay.textContent = `${settings.rangeValue}x`;
elements.selectedWordsInput.value = settings.selectedWords;
// 刷新页面或进入页面时判断,若不是首篇文章,则上一篇按钮可见 // 刷新页面或进入页面时判断,若不是首篇文章,则上一篇按钮可见
if (sessionStorage.getItem('pre_page_button') !== 'display' && sessionStorage.getItem('pre_page_button')) { if(sessionStorage.getItem('pre_page_button')!="display" && sessionStorage.getItem('pre_page_button')){
$('#load_pre_article').show(); $('#load_pre_article').show();
} }
// 事件监听器
elements.selectedWordsInput.addEventListener('input', () => {
localStorage.setItem('selectedWords', elements.selectedWordsInput.value);
});
elements.rangeComponent.addEventListener('input', () => {
const rangeValue = elements.rangeComponent.value;
elements.rangeValueDisplay.textContent = `${rangeValue}x`;
localStorage.setItem('rangeValue', rangeValue);
});
}; };
function clearSelectedWords() {
localStorage.removeItem('selectedWords');
document.querySelector('#selected-words').value = '';
}
function load_next_article(){ function load_next_article(){
$.ajax({ $.ajax({
url: '/get_next_article/{{username}}', url: '/get_next_article/{{username}}',