├── statics ├── img │ └── avatar.jpg ├── font │ ├── HanZiRootFont.ttf │ └── HanZiRootFont.woff2 ├── css │ └── main.css └── js │ └── main.js ├── README.md ├── index.html ├── song.html └── LICENSE /statics/img/avatar.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Werneror/FingerMemory/HEAD/statics/img/avatar.jpg -------------------------------------------------------------------------------- /statics/font/HanZiRootFont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Werneror/FingerMemory/HEAD/statics/font/HanZiRootFont.ttf -------------------------------------------------------------------------------- /statics/font/HanZiRootFont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Werneror/FingerMemory/HEAD/statics/font/HanZiRootFont.woff2 -------------------------------------------------------------------------------- /statics/css/main.css: -------------------------------------------------------------------------------- 1 | /* 字体 */ 2 | @font-face{ 3 | font-family: "HanZiRootFont"; 4 | font-style: normal; 5 | font-weight: 400; 6 | src: url("../font/HanZiRootFont.woff2") format("woff2"), url("../font/HanZiRootFont.ttf") format("ttf"); 7 | } 8 | 9 | html, body{ 10 | margin: 0; 11 | height: 100%; 12 | text-align: center; 13 | } 14 | header{ 15 | margin-bottom: 50px; 16 | } 17 | footer{ 18 | width: 100%; 19 | text-align: center; 20 | position: absolute; 21 | bottom: 0px; 22 | } 23 | input{ 24 | text-align: center; 25 | } 26 | h1{ 27 | margin: 0px; 28 | } 29 | .instructions { 30 | width: 450px; 31 | margin: auto; 32 | } 33 | .zigen{ 34 | font-family: HanZiRootFont; 35 | } 36 | #setting, #ground, #custom, #add-custom { 37 | display: none; 38 | } 39 | #display { 40 | margin: 30px; 41 | font-size: 100px; 42 | } 43 | 44 | .list { 45 | padding-left: 0; 46 | } 47 | .list li { 48 | list-style: none; 49 | } 50 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 手指记忆 2 | 3 | ## 简介 4 | 5 | 最近我在学习五笔输入法。使用一个输入法,我需要能够做到不过脑子,下意识地便能进行正确的输入。这需要大量的练习,让自己的手指“记住”五笔输入法才行。大脑记住某个东西尚且需要重复,手指“记住”某个东西非有大量练习不可。 6 | 7 | 我在学习时使用金山打字通作为训练教程。使用后发现金山打字通训练时字根或汉字的出现是固定的。无论我对某个字根或汉字的输入多么熟悉,它出现的频率也不会减少;无论我对某个字根或汉字的输入多么陌生,它出现的频率也不会增加。我一遍又一遍的训练,熟悉的还是熟悉,陌生的依旧陌生。 8 | 9 | 我发现这是不符合[刻意练习原则](https://baike.baidu.com/item/%E5%88%BB%E6%84%8F%E8%AE%AD%E7%BB%83%E7%90%86%E8%AE%BA/19845073)的。我们应该花更多的时间刻意地练习自己不熟悉的部分。所以一个好的五笔输入法训练系统应该能够记录练习者的练习情况,根据其掌握程度动态地制定训练任务,更多地训练练习者不熟悉的字根或汉字。 10 | 11 | 我想要寻找一个这样的、符合刻意练习原则的五笔输入法训练系统,却没能找到。于是决定自己动手实现,便有了这个项目。 12 | 13 | 本项目是以刻意练习理论为指导、根据练习者掌握情况动态生成训练内容、优先训练练习者掌握不佳内容的五笔输入法训练系统。 14 | 15 | 本项目是一个**纯前端**项目,没有服务器端,所有用户数据都保存在浏览器中。 16 | 17 | 18 | ## 关卡设置 19 | 20 | - 第零关:指法练习 21 | - 第一关:字根输入 22 | - 第二关:一级简码 23 | - 第三关:键名汉字 24 | - 第四关:二级简码 25 | - 第五关:三级简码 26 | - 第六关:常用汉字 27 | 28 | 关卡写在文件[statics/js/data.js](statics/js/data.js)中。 29 | 30 | 其中“第五关:三级简码”只选取了最常用的一小部分三级简码。“第六关:常用汉字”选取了最常用的 6763 个汉字,来源见[此处](https://github.com/sxei/pinyinjs/blob/master/other/%E5%B8%B8%E7%94%A86763%E4%B8%AA%E6%B1%89%E5%AD%97%E4%BD%BF%E7%94%A8%E9%A2%91%E7%8E%87%E8%A1%A8.txt)。通过第六关即可认为已较为熟练地掌握了五笔输入法。 31 | 32 | ## 算法 33 | 34 | ### 显示与输入 35 | 36 | 在“第一关:字根输入”中,我们会在屏幕上显示一个字根,如“礻”,用户看到这个字根后应该按下这个字根所在按键“p”。在这个过程中,我们称字根“礻”为`显示`(display),按键“p”为`输入`(input)。`显示`的取值范围是任意的,如在第零关中它是字母,在第一关中它是字根。`输入`的取值只能是可以用键盘输入的东西,如字母或汉字。一个`显示`对应且仅对应一个`输入`,一个`输入`可以对应多个`显示`。我们称一对`显示`-`输入`为一个训练元。关卡便是一些训练元的集合。 37 | 38 | ### 不熟练度度量 39 | 40 | 设从`显示`显示在屏幕上到用户输入`输入`经历的时间为`T`(单位:秒),则不熟练度`U`为: 41 | 42 | ``` 43 | U = T^0.5 44 | ``` 45 | 46 | 这个函数不收敛,所以需要指定一个时间最大值,当输入错误或`T`超过时间最大值时,将`T`置为时间最大值。 47 | 48 | 每个训练元都对应一个不熟练度,初始时不熟练度为时间最大值对应的不熟练度。练习者的每次练习都会更新相应训练元的不熟练度。 49 | 50 | 下表是一些`T`和`U`的对应: 51 | 52 | T | U 53 | :--:| :-: 54 | 0.0 | 0.00 55 | 0.1 | 0.32 56 | 0.2 | 0.45 57 | 0.5 | 0.71 58 | 1.0 | 1.00 59 | 1.5 | 1.22 60 | 5.0 | 2.23 61 | 5.0 | 2.23 62 | 10 | 3.16 63 | 60 | 7.75 64 | 65 | 66 | ### 训练元选择器 67 | 68 | 每一个关卡都有一个训练元集合,训练元选择器的作用是从训练元集合中选取一个训练元,将训练元的`显示`显示在屏幕上,然后等待用户输入。 69 | 70 | 如何选择呢?我们按照不熟练度加权进行随机选取。设训练元集合中的训练元的不熟练度之和为`S`,其中第`i`个训练元的不熟练度为`Ui`,则选择第`i`个训练元的概率为: 71 | 72 | ``` 73 | P(i) = Ui / S 74 | ``` 75 | 76 | 显然,所有训练元被选择的概率之和为1,每次必有一个训练元被选中。 77 | 78 | ### 过关条件 79 | 80 | 每一关都定义一个过关条件`condition`。当一个训练元的不熟练度小于或等于`condition`时,我们认为用户对该训练元足够熟悉。当某一关的训练元集合中所有训练元的不熟练度均小于或等于`condition`时我们认为练习者通过此关。 81 | 82 | ## TODO 83 | 84 | - [ ] 不熟练度度量函数过于简单,不够理想,有待探索 85 | - [ ] 过关条件`condition`等参数还需调整 86 | - [ ] 编写帮助页面 87 | - [ ] 界面很简陋,有待完善 88 | - [x] 添加关卡选择功能 89 | 90 | ## 开源证书 91 | 92 | GNU General Public License v3.0 93 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 手指记忆-基于刻意练习的五笔输入法训练 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |
19 |

个人中心

20 |
21 | 22 |
23 |
24 | 25 |
26 | 欢迎,Werner 27 |

28 |
29 |
30 |
训练总时长:
31 |
训练总次数:
32 |
当前位于:第
33 |
34 |
35 | 36 | 37 | 38 |
39 |
40 |
关卡概览:
41 | 42 |
43 | 44 |
45 | 46 | 47 |

48 | 49 | 50 |

51 | 本站所有数据都保存在浏览器中,不会上传任何数据到服务器。
52 | 若您删除了浏览器缓存,则可能丢失在本站的数据。
53 |
54 | 55 |
56 | 57 |
58 |
59 | 60 |
61 |
62 |
本关进度:
63 |
64 |
TOP:
65 |
66 | 67 |
68 | 69 |
70 |
已添加的自定义练习:
71 | 72 |
73 | 74 | 75 |
76 |

77 |
使用说明:在其他打字网站,如酷酷网,练习输入一篇文章后,可以把输错的汉字新建为自定义练习进行专门地练习。自定义练习不保存练习进度,每次点击“练习”都会重新开始,也不计入练习总次数和总时长。
78 |
79 | 80 |
81 | 名称: 82 |

83 | 84 |

85 |
86 | 87 | 88 |
89 |
90 |
91 | 92 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /song.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 五笔字根歌 5 | 6 | 7 | 8 | 9 | 10 | 19 | 20 | 21 | 22 |

五笔字根歌

23 | 24 |

1区

25 |
26 |
11
27 |
G
28 |
口诀:王旁青头jiān五一
29 |
字根:一丁丅丄丂七
30 |
31 |
32 |
12
33 |
F
34 |
口诀:土士二干十寸雨
35 |
字根:丐丑专丒丕丘丙世丗且
36 |
37 |
38 |
13
39 |
D
40 |
口诀:大犬三羊古石厂,羊有直斜套去大
41 |
字根:丠両两严並丢丣丨丩个丫丧
42 |
43 |
44 |
14
45 |
S
46 |
口诀:木丁西
47 |
字根:丰丱串丳
48 |
49 |
50 |
15
51 |
A
52 |
口诀:工戈草头右框七
53 |
字根:乀乁乂久乄乆乇乃么之乍义乊乌
54 |
55 | 56 |

2区

57 |
58 |
21
59 |
H
60 |
口诀:目具上止虎皮
61 |
字根:乐乒乗乘乙乕乖乓乔乑乚
62 |
63 |
64 |
22
65 |
J
66 |
口诀:日早两竖与虫依
67 |
字根:习乡乢乣乤乥书乧乨
68 |
69 |
70 |
23
71 |
K
72 |
口诀:口与川,字根稀
73 |
字根:买乱乲
74 |
75 |
76 |
24
77 |
L
78 |
口诀:田甲方框四车力
79 |
字根:亀亁亃亂亄亅了亇争予亊
80 |
81 |
82 |
25
83 |
M
84 |
口诀:山由贝,下框几
85 |
字根:亐云互亓五井亖亗
86 |
87 | 88 |

3区

89 |
90 |
31
91 |
T
92 |
口诀:禾竹一撇双人立,反文条头共三一
93 |
字根:亠亡交亥亢亣亨亦产
94 |
95 |
96 |
32
97 |
R
98 |
口诀:白手看头三二斤
99 |
字根:亰亱亳亵亲亶亴亷亹亸
100 |
101 |
102 |
33
103 |
E
104 |
口诀:月shān乃用家衣底
105 |
字根:什仁仃仅仆仄仂仇仈仌今仉介
106 |
107 |
108 |
34
109 |
W
110 |
口诀:人和八,三四里
111 |
字根:仐仑仒仓仔
112 |
113 |
114 |
35
115 |
Q
116 |
口诀:金勺缺点无尾鱼,犬旁留叉儿一点夕,氏无七
117 |
字根:仠仡令仨以仦仢代仧仩仪仫们仭仮
118 |
119 | 120 |

4区

121 |
122 |
41
123 |
Y
124 |
口诀:言文方广在四一,高头一捺谁人去
125 |
字根:仰仱仲仳价仵件仴仸仹
126 |
127 |
128 |
42
129 |
U
130 |
口诀:立辛两点六门bìng
131 |
字根:伀企伅伃伇伆伋伄伉伊伂伌伈
132 |
133 |
134 |
43
135 |
I
136 |
口诀:水旁兴头小倒立
137 |
字根:伐伕休伓伒优会伔伖众伙
138 |
139 |
140 |
44
141 |
O
142 |
口诀:火业头,四点米
143 |
字根:传伡伢伤伣伥
144 |
145 |
146 |
45
147 |
P
148 |
口诀:之字军盖建道底,摘shì
149 |
字根:估伴伳伲伱伵
150 |
151 | 152 |

5区

153 |
154 |
51
155 |
N
156 |
口诀:已半巳满不出己,左框折尸心和羽
157 |
字根:佀佁佂佃佄佌佋位低住佐佒体佔何佖佇佈佉但佑佊佅
158 |
159 |
160 |
52
161 |
B
162 |
口诀:子耳了也框向上
163 |
字根:你佡佨佥佬佦佩佧佪佫佤佢佣佭
164 |
165 |
166 |
53
167 |
V
168 |
口诀:女刀九jiù山朝西
169 |
字根:佰佱佲佴併佶佷佳
170 |
171 |
172 |
54
173 |
C
174 |
口诀:又巴马,丢矢矣
175 |
字根:侀侄侅侃侁侂
176 |
177 |
178 |
55
179 |
X
180 |
口诀:慈母无心弓和匕,幼无力
181 |
字根:侓侔侕侖侗侒侐侑
182 |
183 | 184 | 185 | 186 | -------------------------------------------------------------------------------- /statics/js/main.js: -------------------------------------------------------------------------------- 1 | /* 页面跳转函数 */ 2 | function gotoPage(newUrl) { 3 | window.location.href = newUrl; 4 | } 5 | 6 | /* 根据时间计算不熟练度 */ 7 | function unskilled(duration) { 8 | return parseFloat(Math.sqrt(duration).toFixed(2)); 9 | } 10 | 11 | /* 训练元随机发生器 */ 12 | function producer(trains) { 13 | var cache = new Array; 14 | for(train of trains) { 15 | cache.push(train); 16 | } 17 | // 按不熟练度降序排列 18 | cache.sort(function(a, b) {return b.unskilled - a.unskilled}); 19 | var accumulative = new Array; 20 | var total = 0; 21 | for(train of cache.slice(0, 100)) { // 只在最不熟练的前 100 中取训练元 22 | var start = total; 23 | total += train.unskilled; 24 | accumulative.push({'start': start, 25 | 'end': total, 26 | 'display': train.display, 27 | 'target': train.target}) 28 | } 29 | var random = Math.floor(Math.random() * total * 100) / 100; 30 | for(item of accumulative) { 31 | if(item.start <= random && random <= item.end){ 32 | return {'display': item.display, 'target': item.target}; 33 | } 34 | } 35 | } 36 | 37 | /* 用户类 */ 38 | function User() { 39 | this.getName = function() { 40 | if (this.name == undefined) { 41 | this.name = localStorage.name; 42 | } 43 | return this.name; 44 | }; 45 | this.setName = function(newName) { 46 | this.name = newName; 47 | localStorage.name = newName; 48 | }; 49 | this.getQQ = function() { 50 | if (this.qq == undefined) { 51 | this.qq = localStorage.qq; 52 | } 53 | return this.qq; 54 | }; 55 | this.setQQ = function(newQQ) { 56 | this.qq = newQQ; 57 | localStorage.qq = newQQ; 58 | }; 59 | this.getLevel = function() { 60 | // 取当前关卡 61 | var level = localStorage.level; 62 | if (level == undefined) { 63 | return 0; 64 | } else { 65 | return level; 66 | } 67 | }; 68 | this.addLevel = function() { 69 | // 进入到下一关 70 | localStorage.level = parseInt(this.getLevel()) + 1; 71 | }; 72 | this.getTimes = function() { 73 | // 取训练总次数 74 | var times = localStorage.times; 75 | if (times == undefined) { 76 | return 0; 77 | } else { 78 | return times; 79 | } 80 | }; 81 | this.addTimes = function() { 82 | // 给训练总次数加 1 83 | localStorage.times = parseInt(this.getTimes()) + 1; 84 | }; 85 | this.getDuration = function() { 86 | // 取训练总时长(单位:秒) 87 | var duration = localStorage.duration; 88 | if (duration == undefined) { 89 | return 0; 90 | } else { 91 | return duration; 92 | } 93 | }; 94 | this.addDuration = function(newDuration) { 95 | // 给取训练总时长增加值(单位:秒) 96 | localStorage.duration = parseFloat(this.getDuration()) + newDuration; 97 | }; 98 | this.isNewMember = function() { 99 | if (this.getName() == undefined) { 100 | return true; 101 | } else { 102 | return false; 103 | } 104 | }; 105 | this.getAvatar = function() { 106 | // 返回用户头像的 url 107 | var qq = this.getQQ(); 108 | if (qq != undefined) { 109 | return `http://q3.qlogo.cn/g?b=qq&nk=${qq}&s=640`; 110 | } else { 111 | return "statics/img/avatar.jpg" 112 | } 113 | } 114 | this.suicide = function(){ 115 | // 自杀,即清除所有数据 116 | this.name = undefined; 117 | this.qq = undefined; 118 | localStorage.clear(); 119 | }; 120 | } 121 | 122 | /* 自定义关卡类 */ 123 | function CustomLevel() { 124 | this.currentLevelName = ""; 125 | this.setCurrentLevelName = function(name) { 126 | this.currentLevelName = name; 127 | } 128 | this.getCurrentLevelName = function() { 129 | return this.currentLevelName; 130 | } 131 | this.getCurrentLevel = function() { 132 | return this.GetLevel(this.currentLevelName); 133 | } 134 | this.NewLevel = function(name, characters) { 135 | var custom = JSON.parse(localStorage.getItem("custom")); 136 | if (custom == null) { 137 | custom = {}; 138 | } 139 | var d = new Date(); 140 | var level = { 141 | "name": name, 142 | "characters": characters, 143 | "date": d.toLocaleString(), 144 | "size": characters.length, 145 | } 146 | custom[name] = level; 147 | localStorage.setItem("custom", JSON.stringify(custom)); 148 | }; 149 | this.DelLevel = function(name) { 150 | var custom = JSON.parse(localStorage.getItem("custom")); 151 | if (custom == null) { 152 | return; 153 | } 154 | delete custom[name]; 155 | localStorage.setItem("custom", JSON.stringify(custom)); 156 | } 157 | this.GetAllLevel = function() { 158 | var custom = JSON.parse(localStorage.getItem("custom")); 159 | if (custom == null) { 160 | custom = {}; 161 | } 162 | var customLevels = new Array(); 163 | for (var key in custom) { 164 | customLevels.push(custom[key]); 165 | } 166 | // 按时间倒序排序 167 | customLevels.sort(function(a, b) { 168 | if (a.date > b.date) { 169 | return -1; 170 | } else if (a.date < b.date) { 171 | return 1; 172 | } 173 | return 0; 174 | }); 175 | return customLevels; 176 | } 177 | this.GetLevel = function(name) { 178 | var custom = JSON.parse(localStorage.getItem("custom")); 179 | if (custom == null) { 180 | custom = {}; 181 | } 182 | return custom[name]; 183 | } 184 | } 185 | 186 | /* 关卡类 */ 187 | function Level(number, maxTime, condition) { 188 | 189 | this.number = number; 190 | this.maxTime = maxTime; 191 | this.condition = condition; 192 | 193 | this.getCondition = function() { 194 | return this.condition; 195 | } 196 | 197 | this.getMaxTime = function() { 198 | return this.maxTime; 199 | } 200 | 201 | this.getTrains = function() { 202 | return JSON.parse(localStorage.getItem("level" + this.number)); 203 | } 204 | 205 | this.saveTrains = function(trains) { 206 | localStorage.setItem("level" + this.number, JSON.stringify(trains)); 207 | } 208 | 209 | this.initTrains = function() { 210 | var trains = new Array(); 211 | var level = levels[this.number]; 212 | var data; 213 | if (typeof(level) == "undefined") { 214 | data = JSON.parse(localStorage.getItem("levelData" + this.number)); 215 | } else { 216 | data = level.data; 217 | } 218 | var maxUnskilled = unskilled(this.maxTime); 219 | for(item of data) { 220 | if (item.target != undefined) { 221 | var target = item.target; 222 | } else { 223 | var target = item.display; 224 | } 225 | trains.push({"display": item.display, 226 | "target": target, 227 | "unskilled": maxUnskilled}); 228 | } 229 | this.saveTrains(trains); 230 | } 231 | 232 | this.updateUnskilled = function(item, unskilled) { 233 | var trains = this.getTrains(); 234 | for (train of trains) { 235 | if(train.display === item.display && train.target === item.target){ 236 | train.unskilled = unskilled; 237 | } 238 | } 239 | this.saveTrains(trains); 240 | } 241 | 242 | if (this.getTrains() == undefined) { 243 | this.initTrains(); 244 | } 245 | } 246 | 247 | /* 页面切换 */ 248 | function setTitle(title) { 249 | document.getElementById("title").innerText = title; 250 | } 251 | 252 | function showSection(sectionId) { 253 | var sections = document.getElementsByTagName('section'); 254 | for (section of sections) { 255 | section.style.display = "none"; 256 | } 257 | document.getElementById(sectionId).style.display = "block"; 258 | if (sectionId === "profile") { 259 | initProfile(); 260 | } else if (sectionId === "setting"){ 261 | initSetting(); 262 | } else if (sectionId === "custom"){ 263 | initCustom(); 264 | } else if (sectionId === "AddCustom"){ 265 | initAddCustom(); 266 | } else if (sectionId === "ground"){ 267 | initGround(); 268 | } 269 | } 270 | 271 | /* 按钮点击动作函数 */ 272 | function openProfile() { 273 | setTitle("个人中心"); 274 | showSection("profile"); 275 | } 276 | 277 | function start() { 278 | customLevel.setCurrentLevelName(""); 279 | if(user.getLevel() < levels.length) { 280 | user.addTimes(); 281 | setTitle(levels[user.getLevel()].name); 282 | showSection("ground"); 283 | } 284 | } 285 | 286 | function startCustom(name) { 287 | setTitle("练习自定义关卡:"+name); 288 | customLevel.setCurrentLevelName(name); 289 | showSection("ground"); 290 | } 291 | 292 | function setting() { 293 | setTitle("设置用户信息"); 294 | showSection("setting"); 295 | } 296 | 297 | function custom() { 298 | setTitle("自定义练习"); 299 | showSection("custom"); 300 | document.getElementById("new-name").value = ""; 301 | document.getElementById("new-characters").value = ""; 302 | } 303 | 304 | function addCustom() { 305 | setTitle("新增自定义练习"); 306 | showSection("add-custom"); 307 | document.getElementById("new-name").disabled = false; 308 | } 309 | 310 | function logout() { 311 | user.suicide(); 312 | setTitle("注册新用户"); 313 | showSection("setting"); 314 | } 315 | 316 | function submit() { 317 | var name = document.getElementById("user-name").value; 318 | var qq = document.getElementById("user-qq").value; 319 | if (name != '') { 320 | user.setName(name); 321 | if (qq != '') { 322 | user.setQQ(qq); 323 | } 324 | openProfile(); 325 | } else { 326 | alert("昵称是必填的。"); 327 | } 328 | } 329 | 330 | var chinesePattern = new RegExp("[\u4E00-\u9FA5]+"); 331 | function newCustom() { 332 | var name = document.getElementById("new-name").value; 333 | var characters = new Set(document.getElementById("new-characters").value); 334 | var chineseCharacters = new Array(); 335 | characters.forEach(function(value) { 336 | if (chinesePattern.test(value)) { 337 | chineseCharacters.push(value); 338 | } 339 | }); 340 | if (name == '') { 341 | alert("名称是必填的。"); 342 | return; 343 | } 344 | if (chineseCharacters.length == 0) { 345 | alert("输入的有效字符为空。"); 346 | return; 347 | } 348 | customLevel.NewLevel(name, chineseCharacters); 349 | custom(); 350 | } 351 | 352 | /* 填充函数 */ 353 | function humanTime(seconds) { 354 | var humanRead = ""; 355 | var second = seconds % 60; 356 | var minute = parseInt((seconds % 3600) / 60); 357 | var hour = parseInt(seconds / 3600); 358 | if(hour != 0) { 359 | humanRead = hour + "小时"; 360 | } 361 | if(minute != 0) { 362 | humanRead += minute; 363 | if(second == 0) { 364 | humanRead += "分钟"; 365 | } else { 366 | humanRead += "分"; 367 | } 368 | } 369 | if(humanRead == "") { 370 | humanRead = second + "秒"; 371 | } else if (second != 0) { 372 | humanRead += second + "秒"; 373 | } 374 | return humanRead; 375 | } 376 | 377 | function levelChange() { 378 | var levelSelector = document.getElementById("level-selector"); 379 | var selectedLevel = levelSelector.options[levelSelector.selectedIndex].value; 380 | var r = confirm(`是否确定要跳转到第 ${selectedLevel} 关?`); 381 | if (r == true) { 382 | localStorage.level = parseInt(selectedLevel); 383 | } else { 384 | var level = user.getLevel(); 385 | levelSelector.value = level; 386 | } 387 | } 388 | 389 | function deleteCustom(name) { 390 | customLevel.DelLevel(name); 391 | custom(); 392 | } 393 | 394 | function editCustom(name) { 395 | setTitle("编辑自定义练习:"+name); 396 | showSection("add-custom"); 397 | var level = customLevel.GetLevel(name); 398 | var characters = ""; 399 | if (typeof(level) != "undefined") { 400 | for (char of level.characters) { 401 | characters += char; 402 | } 403 | } 404 | document.getElementById("new-name").disabled = true; 405 | document.getElementById("new-name").value = name; 406 | document.getElementById("new-characters").value = characters; 407 | } 408 | 409 | function initProfile() { 410 | var times = user.getTimes(); 411 | var level = user.getLevel(); 412 | document.getElementById("name").innerText = user.getName(); 413 | document.getElementById("times").innerText = times; 414 | document.getElementById("duration").innerText = humanTime(parseInt(user.getDuration())); 415 | if(level < levels.length) { 416 | document.getElementById("start-button").innerText = "开始你的第" + (parseInt(times) + 1) + "次练习"; 417 | } else { 418 | document.getElementById("start-button").innerText = "您已通关"; 419 | } 420 | var select = ''; 429 | document.getElementById("level").innerHTML = select; 430 | document.getElementById("avatar").src = user.getAvatar(); 431 | var html = ""; 432 | for(var i=0; i第 ${i} 关:${levels[i].name}`; 434 | } 435 | document.getElementById("list").innerHTML = html; 436 | } 437 | 438 | function initSetting() { 439 | var name = user.getName(); 440 | var qq = user.getQQ(); 441 | if (name != undefined) { 442 | document.getElementById("user-name").value = name; 443 | } 444 | if (qq != undefined) { 445 | document.getElementById("user-qq").value = qq; 446 | } 447 | } 448 | 449 | function initCustom() { 450 | var allLevels = customLevel.GetAllLevel(); 451 | var html = ""; 452 | for(level of allLevels) { 453 | html += `
  • ${level.name}(${level.size} 字,${level.date})
  • `; 454 | } 455 | if (html == "") { 456 | html = "还没有自定义练习,请先添加"; 457 | } 458 | document.getElementById("custom-list").innerHTML = html; 459 | } 460 | 461 | function initAddCustom() { 462 | 463 | } 464 | 465 | function initGround() { 466 | document.getElementById("input").focus(); 467 | var level; 468 | if (customLevel.getCurrentLevelName() == "") { 469 | var current = user.getLevel(); 470 | level = new Level(current, 471 | levels[current].maxTime, 472 | levels[current].condition); 473 | } else { 474 | var currentLevel = customLevel.getCurrentLevel(); 475 | localStorage.removeItem("level"+currentLevel.name); // 删除原有的练习数据 476 | var data = new Array(); 477 | for (char of currentLevel.characters) { 478 | data.push({"display": char}); 479 | } 480 | localStorage.setItem("levelData" + currentLevel.name, JSON.stringify(data)); 481 | level = new Level(currentLevel.name, 120, 1.8); 482 | } 483 | updateProgress(level.getTrains(), level.getCondition()); 484 | var display = document.getElementById("display"); 485 | var input = document.getElementById("input"); 486 | if(level.number == 1) { 487 | // 第一关是字根输入练习,为正确显示字根, 488 | // 需设置 class 为 zigen,以使用特殊字体 489 | document.getElementById("display").className = "zigen"; 490 | document.getElementById("top-error").className = "zigen"; 491 | } else { 492 | document.getElementById("display").className = ""; 493 | document.getElementById("top-error").className = ""; 494 | } 495 | step(display, input ,level); 496 | } 497 | 498 | function passLevel() { 499 | var name = customLevel.getCurrentLevelName(); 500 | if (name == "") { 501 | alert("恭喜你通过了" + levels[user.getLevel()].name); 502 | user.addLevel(); 503 | openProfile(); 504 | } else { 505 | alert("恭喜你通过了自定义练习:" + name); 506 | custom(); 507 | } 508 | } 509 | 510 | function updateProgress(trains, condition) { 511 | var skill = 0; 512 | var total = 0; 513 | var progress = document.getElementById("progress"); 514 | var topError = document.getElementById("top-error"); 515 | var topErrorList = new Array(); 516 | for (train of trains) { 517 | if (train.unskilled <= condition) { 518 | skill += 1; 519 | } 520 | total += 1; 521 | if (topErrorList.length < 5) { 522 | topErrorList.push(train); 523 | } else { 524 | for (var i=0; i < topErrorList.length; i++) { 525 | if (topErrorList[i].unskilled < train.unskilled) { 526 | topErrorList[i] = train; 527 | break; 528 | } 529 | } 530 | } 531 | } 532 | progress.innerText = skill + '/' + total; 533 | var text = ""; 534 | for (element of topErrorList) { 535 | text += element.display + " " 536 | } 537 | topError.innerText = text; 538 | if (skill == total) { 539 | passLevel(); 540 | } 541 | } 542 | 543 | function step(display, input ,level, pre_train=undefined) { 544 | input.value = ''; // 清除刷新页面后浏览器在input中的缓存 545 | if (pre_train != undefined) { 546 | var train = pre_train; 547 | } else { 548 | var train = producer(level.getTrains()); 549 | } 550 | var maxTime = level.getMaxTime(); 551 | var condition = level.getCondition(); 552 | display.innerText = train.display; 553 | var beginTime = new Date(); 554 | var recovery = false; 555 | window.lock = false; // 防止中文输入法未完成输入时先判断输入的字母 556 | input.onkeyup = function(event) { 557 | if (event.keyCode < 32 || event.keyCode > 126 || window.lock) { 558 | return; 559 | } 560 | var endTime = new Date(); 561 | var time = (endTime-beginTime) / 1000.0; 562 | user.addDuration(time); 563 | if(input.value == train.target) { 564 | if (time > maxTime) { 565 | time = maxTime; 566 | } 567 | if (!recovery) { 568 | var unskilledValue = unskilled(time); 569 | if (pre_train == undefined) { 570 | level.updateUnskilled(train, unskilledValue); 571 | } 572 | setTimeout(step, 50, display, input ,level); 573 | } else { 574 | setTimeout(step, 50, display, input ,level, train); 575 | } 576 | 577 | } else { 578 | if (!recovery) { 579 | level.updateUnskilled(train, unskilled(maxTime)); 580 | } 581 | setTimeout("input.value = '';", 50); 582 | recovery = true; 583 | inputError(); 584 | } 585 | updateProgress(level.getTrains(), condition); 586 | }; 587 | if (!window.HasBeenListen) { 588 | input.addEventListener('compositionstart', function () { 589 | window.lock = true; 590 | }); 591 | input.addEventListener('compositionend', function () { 592 | window.lock = false; 593 | }); 594 | window.HasBeenListen = true; 595 | } 596 | } 597 | 598 | function inputError() { 599 | document.getElementById('input').style.border = '3px solid red'; 600 | document.getElementById('display').style.color = 'red'; 601 | setTimeout("document.getElementById('input').style.border = '';document.getElementById('display').style.color = '';", 200); 602 | } 603 | 604 | /* 页面加载后执行 */ 605 | window.onload = function(){ 606 | user = new User(); 607 | customLevel = new CustomLevel(); 608 | if (user.isNewMember()) { 609 | setTitle("注册新用户"); 610 | showSection("setting"); 611 | } else { 612 | initProfile(); 613 | } 614 | } 615 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------