Skip to content

Commit

Permalink
添加从头重打按钮
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleBing committed Mar 12, 2024
1 parent 0a9bb2d commit ddb784f
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 24 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

### v2.67 `2024-03-12`
- 添加从头重打按钮
- 顶部操作按钮顺序调整

### v2.66 `2022-11-11`
- 添加汉语词条跟打类型
- https -> http
Expand Down
16 changes: 10 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>玫枫跟打器 (Roseo Maple TypePad)</title>
<link rel="shortcut icon" href="img/logo.png" type="image/png">
<link rel="stylesheet" href="scss/typepad.css?v=2.66b2">
<link rel="stylesheet" href="scss/typepad.css?v=2.67">
</head>
<body>

Expand Down Expand Up @@ -56,10 +56,10 @@
<div class="side-menu hidden-sm">
<div class="tool-bar jc-space-between">
<div class="btn-group toolbar-info">
<div class="btn" onclick="engine.shuffleCurrent()" title="打乱当前段:⌘ + K 或 F4">打乱</div>
<div class="btn" onclick="engine.reset()" title="重打:⌘ + Y 或 F3">重打</div>
<div class="btn" onclick="engine.pause()" title="离开编辑区">暂停</div>
<div class="btn" onclick="engine.resume()" title="激活编辑区">继续</div>
<div class="btn" onclick="engine.shuffleCurrent()" title="打乱当前段:⌘ + K 或 F4">打乱</div>
<div class="btn" onclick="engine.reset()" title="重打:⌘ + Y 或 F3">重打</div>
</div>
</div>

Expand Down Expand Up @@ -331,8 +331,8 @@ <h1>玫枫跟打器<br>(<a target="_blank" href="https://github.com/KyleBing/typ
</div>
<div class="copyright">
<a target="_blank" href="http://kylebing.cn" class="link">KyleBing</a>
<p>v2.66</p>
<p>2022.11.25</p>
<p>v2.67</p>
<p>2024.03.12</p>
</div>
</div>

Expand Down Expand Up @@ -414,6 +414,10 @@ <h1>玫枫跟打器<br>(<a target="_blank" href="https://github.com/KyleBing/typ
<div class="btn" onclick="engine.prevChapter()" title="上一段:⌘ + U 或 F1"></div>
<div class="btn" onclick="engine.nextChapter()" title="下一段:⌘ + J 或 F2"></div>
</div>
<div class="btn-group">
<div class="btn" onclick="engine.toTopChapter()" title="至第一段">|《</div>
<div class="btn" onclick="engine.toEndChapter()" title="至最后一段">》|</div>
</div>
<div class="btn-group hidden" id="panelRepeatController">
<div id="repeatMonitor" class="btn no-action number" onclick="engine.reset()" title="⌘ + K">
<span id="repeatCountCurrent" class="chapter-current bold current number" title="当前重打次数">1</span> /
Expand Down Expand Up @@ -527,7 +531,7 @@ <h1>玫枫跟打器<br>(<a target="_blank" href="https://github.com/KyleBing/typ
</div>

<script src="js/require_v2.3.6.js"></script>
<script src="js/typepad.js?v=2.66b2"></script>
<script src="js/typepad.js?v=2.67"></script>

<script>
setTimeout(() => {
Expand Down
26 changes: 26 additions & 0 deletions js/class/Engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,32 @@ define(
}
}

toTopChapter(){
this.config.repeatCountCurrent = 1;
this.config.chapter = 1;
if (this.config.articleType === ArticleType.word) // 1. ArticleType.word
{
this.arrayWordDisplaying = this.arrayWordAll.slice(0, this.config.count * this.config.chapter); // 截取当前需要显示的数组段
let arrayCurrentWord = this.arrayWordDisplaying.map(item => {
return item.word
}); // 取到英文,数组
this.currentWords = arrayCurrentWord.join(' ');
} else if (this.config.articleType === ArticleType.phrase) // 2. ArticleType.phrase
{
this.arrayWordDisplaying = this.arrayWordAll.slice(0, this.config.count * this.config.chapter); // 截取当前需要显示的数组段
this.currentWords = this.arrayWordDisplaying.join(' ');
} else // 3. ArticleType.others
{
this.currentWords = this.currentOriginWords.slice(0, this.config.count * this.config.chapter).join('');
}
this.reset();
this.config.save();
}
toEndChapter(){
this.config.chapter = this.config.chapterTotal - 1
this.nextChapter()
}

// 自定义文章
customizeArticle(){
$('#app').style.overflow = 'hidden'
Expand Down
2 changes: 1 addition & 1 deletion js/typepad.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ require(['ArticleType', 'Article', 'Engine', 'Editor'],
// Service Worker
if ('serviceWorker' in navigator){
navigator.serviceWorker
.register('/tools/typepad/typepad-sw.js?v=2.66b2')
.register('/tools/typepad/typepad-sw.js?v=2.67')
.then(()=>{
console.log('Server Worker has registered');
})
Expand Down
34 changes: 17 additions & 17 deletions typepad-sw.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
const preFix = 'typepad'
const version = '2.66b2';
const version = '2.67';

self.addEventListener('install', event => {
self.skipWaiting();
event.waitUntil(
caches.open(preFix + version).then(cache => {
return cache.addAll([
'/tools/typepad',
'/tools/typepad/index.html?v=2.66b2',
'/tools/typepad/scss/typepad.css?v=2.66b2',
'/tools/typepad/index.html?v=2.67',
'/tools/typepad/scss/typepad.css?v=2.67',

// 英文单词
'/tools/typepad/js/class/english-vocabulary/CET4mini.js?v=2.66b2',
'/tools/typepad/js/class/english-vocabulary/CET4mini.js?v=2.67',

// 汉语单词
'/tools/typepad/js/class/phrase/Phrase.js?v=2.66b2',
'/tools/typepad/js/class/phrase/Phrase.js?v=2.67',

'/tools/typepad/js/class/Database.js?v=2.66b2',
'/tools/typepad/js/class/Utility.js?v=2.66b2',
'/tools/typepad/js/class/KeyCount.js?v=2.66b2',
'/tools/typepad/js/class/Config.js?v=2.66b2',
'/tools/typepad/js/class/Editor.js?v=2.66b2',
'/tools/typepad/js/class/Article.js?v=2.66b2',
'/tools/typepad/js/class/ArticleType.js?v=2.66b2',
'/tools/typepad/js/class/Reg.js?v=2.66b2',
'/tools/typepad/js/class/Engine.js?v=2.66b2',
'/tools/typepad/js/class/Record.js?v=2.66b2',
'/tools/typepad/js/class/CETWord.js?v=2.66b2',
'/tools/typepad/js/class/Database.js?v=2.67',
'/tools/typepad/js/class/Utility.js?v=2.67',
'/tools/typepad/js/class/KeyCount.js?v=2.67',
'/tools/typepad/js/class/Config.js?v=2.67',
'/tools/typepad/js/class/Editor.js?v=2.67',
'/tools/typepad/js/class/Article.js?v=2.67',
'/tools/typepad/js/class/ArticleType.js?v=2.67',
'/tools/typepad/js/class/Reg.js?v=2.67',
'/tools/typepad/js/class/Engine.js?v=2.67',
'/tools/typepad/js/class/Record.js?v=2.67',
'/tools/typepad/js/class/CETWord.js?v=2.67',
'/tools/typepad/js/require_v2.3.6.js',
'/tools/typepad/js/typepad.js?v=2.66b2',
'/tools/typepad/js/typepad.js?v=2.67',
'/tools/typepad/img/logo.png',
'/tools/typepad/scss/font/DSDigital.ttf',
'/tools/typepad/scss/font/Galvji.ttf',
Expand Down

0 comments on commit ddb784f

Please sign in to comment.