Поправки багов

This commit is contained in:
Book Pauk
2019-02-03 23:01:07 +07:00
parent cd4fb75c9d
commit 079ebb5ce1
2 changed files with 49 additions and 51 deletions

View File

@@ -38,61 +38,58 @@ class CopyTextPage extends Vue {
} }
async init(bookPos, parsed, copyFullText) { async init(bookPos, parsed, copyFullText) {
if (parsed && this.parsed != parsed) { this.text = 'Загрузка';
this.text = 'Загрузка'; await this.$nextTick();
await this.$nextTick();
const paraIndex = parsed.findParaIndex(bookPos); const paraIndex = parsed.findParaIndex(bookPos);
this.initStep = true; this.initStep = true;
this.stopInit = false; this.stopInit = false;
let nextPerc = 0; let nextPerc = 0;
let text = ''; let text = '';
let cut = ''; let cut = '';
let from = 0; let from = 0;
let to = parsed.para.length; let to = parsed.para.length;
if (!copyFullText) { if (!copyFullText) {
from = paraIndex - 100; from = paraIndex - 100;
from = (from < 0 ? 0 : from); from = (from < 0 ? 0 : from);
to = paraIndex + 100; to = paraIndex + 100;
to = (to > parsed.para.length ? parsed.para.length : to); to = (to > parsed.para.length ? parsed.para.length : to);
cut = '<p>..... Текст вырезан. Если хотите скопировать больше, поставьте в настройках галочку "Загружать весь текст"'; cut = '<p>..... Текст вырезан. Если хотите скопировать больше, поставьте в настройках галочку "Загружать весь текст"';
}
if (from > 0)
text += cut;
for (let i = from; i < to; i++) {
const p = parsed.para[i];
const parts = parsed.splitToStyle(p.text);
if (this.stopInit)
return;
text += `<p id="p${i}" class="copyPara">`;
for (const part of parts)
text += part.text;
const perc = Math.round(i/parsed.para.length*100);
if (perc > nextPerc) {
this.initPercentage = perc;
await sleep(1);
nextPerc = perc + 10;
} }
}
if (to < parsed.para.length)
text += cut;
if (from > 0) this.text = text;
text += cut; this.initStep = false;
for (let i = from; i < to; i++) {
const p = parsed.para[i];
const parts = parsed.splitToStyle(p.text);
if (this.stopInit)
return;
text += `<p id="p${i}" class="copyPara">`; await this.$nextTick();
for (const part of parts) this.$refs.text.focus();
text += part.text;
const perc = Math.round(i/parsed.para.length*100); const p = document.getElementById('p' + paraIndex);
if (p) {
if (perc > nextPerc) { this.$refs.text.scrollTop = p.offsetTop;
this.initPercentage = perc;
await sleep(1);
nextPerc = perc + 10;
}
}
if (to < parsed.para.length)
text += cut;
this.text = text;
this.initStep = false;
this.parsed = parsed;
await this.$nextTick();
this.$refs.text.focus();
const p = document.getElementById('p' + paraIndex);
if (p) {
this.$refs.text.scrollTop = p.offsetTop;
}
} }
} }

View File

@@ -200,14 +200,15 @@ class HistoryPage extends Vue {
const newRecent = bookManager.mostRecentBook(); const newRecent = bookManager.mostRecentBook();
if (this.mostRecentBook != newRecent) if (this.mostRecentBook != newRecent)
this.$emit('load-book', newRecent); this.$emit('load-book', newRecent);
this.mostRecentBook = newRecent; this.mostRecentBook = newRecent;
if (!this.mostRecentBook) if (!this.mostRecentBook)
this.close(); this.close();
} }
loadBook(url) { loadBook(url) {
this.$emit('load-book', {url}); if (this.mostRecentBook.url != url)
this.$emit('load-book', {url});
this.close(); this.close();
} }