fix options versioning code, update usage guide

This commit is contained in:
Alex Yatskov 2017-02-26 10:38:48 -08:00
parent 55dd9b1e6b
commit 6b7e094041
2 changed files with 11 additions and 12 deletions

View File

@ -23,11 +23,10 @@
</p>
<ol>
<li>Left-click on the <img src="../img/icon16.png" alt> icon to enable or disable Yomichan for the current browser instance.</li>
<li>Right-click on the <img src="../img/icon16.png" alt> icon and select <em>Options</em> to open the Yomichan options page.</li>
<li>Import any dictionaries (bundled or custom) you wish to use for Kanji and term searches; none are imported by default.</li>
<li>Click on the <img src="../img/icon16.png" alt> icon in the browser toolbar to open the Yomichan options page.</li>
<li>Import the dictionaries (bundled or custom) you wish to use for term and Kanji searches.</li>
<li>Hold down <kbd>Shift</kbd> (or the middle mouse button) as you hover over text to see term definitions.</li>
<li>Resize the definitions window by dragging the bottom-left corner inwards or outwards to make it smaller or larger.</li>
<li>Click on the <img src="../fg/img/play_audio.png" alt> icon to hear the term pronounced by a native speaker (if audio is available).</li>
<li>Click on Kanji in the definition window to view additional information about that character.</li>
</ol>
</div>

View File

@ -51,7 +51,7 @@ function optionsSetDefaults(options) {
const combine = (target, source) => {
for (const key in source) {
if (!(key in target)) {
if (!target.hasOwnProperty(key)) {
target[key] = source[key];
}
}
@ -69,9 +69,6 @@ function optionsSetDefaults(options) {
function optionsVersion(options) {
optionsSetDefaults(options);
options.version = options.version || 0;
const fixups = [
() => {
const copy = (targetDict, targetKey, sourceDict, sourceKey) => {
@ -125,10 +122,13 @@ function optionsVersion(options) {
}
];
if (options.version < fixups.length) {
fixups[options.version]();
++options.version;
optionsVersion(options);
optionsSetDefaults(options);
if (!options.hasOwnProperty('version')) {
options.version = fixups.length;
}
while (options.version < fixups.length) {
fixups[options.version++]();
}
return options;