Skip to content

Commit

Permalink
Changed assorted files to class syntax.
Browse files Browse the repository at this point in the history
* EpubItem
* EpubItemSupplier
* Parser
* BakaTsuki Parser
* Sonako parser
  • Loading branch information
dteviot committed Sep 28, 2016
1 parent f9c16af commit cfc4123
Show file tree
Hide file tree
Showing 5 changed files with 512 additions and 514 deletions.
55 changes: 27 additions & 28 deletions plugin/js/EpubItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,19 @@ class EpubItem {
// ToDo: assert that tagName in range <h1> ... <h4>
return tagName[1] - "1";
}
}

EpubItem.prototype.chapterInfo = function*() {
let that = this;
for(let element of that.elements) {
if (util.isHeaderTag(element)) {
yield {
depth: this.tagNameToTocDepth(element.tagName),
title: element.textContent,
src: that.getZipHref()
*chapterInfo() {
let that = this;
for(let element of that.elements) {
if (util.isHeaderTag(element)) {
yield {
depth: this.tagNameToTocDepth(element.tagName),
title: element.textContent,
src: that.getZipHref()
};
};
};
};
}
}

//==============================================================
Expand All @@ -82,23 +82,23 @@ class ChapterEpubItem extends EpubItem {
this.chapterTitle = chapter.title;
this.newArc = chapter.newArc;
}
}

ChapterEpubItem.prototype.chapterInfo = function*() {
let that = this;
if (that.newArc !== null) {
yield {
depth: 0,
title: that.newArc,
src: that.getZipHref()
*chapterInfo() {
let that = this;
if (that.newArc !== null) {
yield {
depth: 0,
title: that.newArc,
src: that.getZipHref()
}
}
}

if (typeof (that.chapterTitle) !== "undefined") {
yield {
depth: 1,
title: that.chapterTitle,
src: that.getZipHref()
if (typeof (that.chapterTitle) !== "undefined") {
yield {
depth: 1,
title: that.chapterTitle,
src: that.getZipHref()
}
}
}
}
Expand Down Expand Up @@ -259,9 +259,8 @@ class ImageInfo extends EpubItem {
div.appendChild(util.createComment(doc, origin));
return div;
}
}

ImageInfo.prototype.chapterInfo = function*() {
// images do not appear in table of contents
*chapterInfo() {
// images do not appear in table of contents
}
}

61 changes: 31 additions & 30 deletions plugin/js/EpubItemSupplier.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,41 @@ class EpubItemSupplier {
let that = this;
this.coverImageId = () => that.coverImageInfo.getId();
};
}

// used to populate manifest
EpubItemSupplier.prototype.manifestItems = function() {
return this.epubItems;
}

// used to populate spine
EpubItemSupplier.prototype.spineItems = function() {
return this.epubItems.filter(item => item.isInSpine);
}
// used to populate manifest
manifestItems() {
return this.epubItems;
}

// used to populate Zip file itself
EpubItemSupplier.prototype.files = function() {
return this.epubItems;
}
// used to populate spine
spineItems() {
return this.epubItems.filter(item => item.isInSpine);
}

// used to populate table of contents
EpubItemSupplier.prototype.chapterInfo = function*() {
let that = this;
for(let epubItem of that.epubItems) {
yield* epubItem.chapterInfo();
};
}
// used to populate Zip file itself
files() {
return this.epubItems;
}

EpubItemSupplier.prototype.makeCoverImageXhtmlFile = function() {
let that = this;
let doc = util.createEmptyXhtmlDoc();
let body = doc.getElementsByTagName("body")[0];
let userPreferences = that.imageCollector.userPreferences;
body.appendChild(that.coverImageInfo.createImageElement(userPreferences));
return util.xmlToString(doc);
}
// used to populate table of contents
*chapterInfo() {
let that = this;
for(let epubItem of that.epubItems) {
yield* epubItem.chapterInfo();
};
}

EpubItemSupplier.prototype.hasCoverImageFile = function() {
return (this.coverImageInfo != null);
makeCoverImageXhtmlFile() {
let that = this;
let doc = util.createEmptyXhtmlDoc();
let body = doc.getElementsByTagName("body")[0];
let userPreferences = that.imageCollector.userPreferences;
body.appendChild(that.coverImageInfo.createImageElement(userPreferences));
return util.xmlToString(doc);
}

hasCoverImageFile() {
return (this.coverImageInfo != null);
}
}
Loading

0 comments on commit cfc4123

Please sign in to comment.