Firefox support

This commit is contained in:
daniel-j 2017-06-07 16:17:40 +02:00
parent c1f72abdad
commit a5e61539e7
4 changed files with 30 additions and 13 deletions

View file

@ -454,11 +454,18 @@ class FimFic2Epub extends Emitter {
}
// Internal/private methods
progress (part, percent, status) {
progress (part, percent, status = '') {
// let parts = 6.3
// let partsize = 1 / parts
// percent = (part / parts) + percent * partsize
this.trigger('progress', percent, status)
try {
this.trigger('progress', percent, status)
} catch (err) {
console.error(err)
}
if (status) {
console.log(status)
}
}
findRemoteResources (prefix, where, html) {

View file

@ -14,9 +14,9 @@ export function cleanMarkup (html) {
}
return new Promise((resolve, reject) => {
// replace HTML non-breaking spaces with normal spaces
html = html.replace(/ /g, ' ')
html = html.replace(/ /g, ' ')
// replace HTML entities with decimal entities
html = html.replace(/ /g, ' ')
html = html.replace(/ /g, ' ')
// fix some tags
html = html.replace(/<u>/g, '<span style="text-decoration: underline">')
@ -27,10 +27,7 @@ export function cleanMarkup (html) {
html = html.replace(/<p>\s*/g, '<p>')
html = html.replace(/\s*<\/p>/g, '</p>')
html = html.replace(/<p><p>/g, '<p>')
html = html.replace(/<\/div><\/p>/g, '</div>')
html = fixParagraphIndent(html)
// html = fixParagraphIndent(html)
html = fixDoubleSpacing(html)

View file

@ -28,6 +28,9 @@ export default function fetch (url, responseType) {
if (url.indexOf('//') === 0) {
url = 'http:' + url
}
if (url.indexOf('/') === 0) {
url = 'https://fimfiction.net' + url
}
if (isNode) {
return fetchNode(url, responseType)

View file

@ -98,6 +98,14 @@ function selectOptions (list, selected = '') {
})
}
function redraw (arg) {
try {
m.redraw(arg)
} catch (err) {
console.log(err)
}
}
let ffcProgress = m.prop(0)
let ffcStatus = m.prop('')
@ -140,12 +148,14 @@ let dialog = {
this.author(ffc.storyInfo.author.name)
this.description(ffc.storyInfo.short_description)
this.subjects(ffc.subjects.slice(0))
m.redraw(true)
redraw(true)
this.center()
ffc.fetchChapters().then(() => {
ffcProgress(-1)
m.redraw()
redraw()
})
}).catch((err) => {
throw err
})
}
}
@ -232,7 +242,7 @@ let dialog = {
ffc.options.paragraphStyle = this.paragraphStyle()
ffc.subjects = this.subjects()
ffc.options.joinSubjects = this.joinSubjects()
m.redraw()
redraw()
chain
.then(ffc.fetchAll.bind(ffc))
@ -337,7 +347,7 @@ function onProgress (percent, status) {
if (status) {
ffcStatus(status)
}
m.redraw()
redraw()
}
if (pageStoryId && isChromeExt) {