Skip to content

Commit

Permalink
Merge pull request #25 from d-i-t-a/fixes/last-navigated-to
Browse files Browse the repository at this point in the history
Fixes last navigated to
  • Loading branch information
aferditamuriqi authored Apr 2, 2020
2 parents cfb11e3 + 7c8c1ad commit eb4fa2c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@d-i-t-a/reader",
"version": "1.0.8",
"version": "1.0.9",
"description": "A viewer application for EPUB files.",
"repository": "https://github.com/d-i-t-a/R2D2BC",
"main": "src/index.js",
Expand Down
10 changes: 5 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ export function currentResource() {
if (IS_DEV) { console.log("currentResource") }
return R2Navigator.currentResource()
}
export function currentTocHref() {
if (IS_DEV) { console.log("currentTocHref") }
return R2Navigator.currentTocHref()
export function mostRecentNavigatedTocItem() {
if (IS_DEV) { console.log("mostRecentNavigatedTocItem") }
return R2Navigator.mostRecentNavigatedTocItem()
}
export function totalResources() {
if (IS_DEV) { console.log("totalResources") }
Expand Down Expand Up @@ -266,8 +266,8 @@ exports.annotations = function () {
exports.currentResource = function() {
return currentResource()
}
exports.currentTocHref = function() {
return currentTocHref()
exports.mostRecentNavigatedTocItem = function() {
return mostRecentNavigatedTocItem()
}
exports.totalResources = function() {
return totalResources()
Expand Down
5 changes: 5 additions & 0 deletions src/model/Publication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ export default class Publication {
public getAbsoluteHref(href: string): string | null {
return new URL(href, this.manifestUrl.href).href;
}
public getRelativeHref(href: string): string | null {
const manifest = this.manifestUrl.href.replace("/manifest.json", ""); //new URL(this.manifestUrl.href, this.manifestUrl.href).href;
return href.replace(manifest, "");
}


public getTOCItemAbsolute(href: string): Link | null {
const absolute = this.getAbsoluteHref(href)
Expand Down
4 changes: 2 additions & 2 deletions src/navigator/IFrameNavigator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1000,8 +1000,8 @@ export default class IFrameNavigator implements Navigator {
totalResources(): number {
return this.publication.readingOrder.length
}
currentTocHref(): string {
return this.currentTOCRawLink
mostRecentNavigatedTocItem(): string {
return this.publication.getRelativeHref(this.currentTOCRawLink)
}
currentResource(): number {
let currentLocation = this.currentChapterLink.href
Expand Down
2 changes: 1 addition & 1 deletion viewer/index_api.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

<button onclick="javascript:alert(D2Reader.totalResources())">totalResources</button><br>
<button onclick="javascript:alert(D2Reader.currentResource())">currentResource</button><br>
<button onclick="javascript:alert(D2Reader.currentTocHref())">currentTocHref</button><br>
<button onclick="javascript:alert(D2Reader.mostRecentNavigatedTocItem())">mostRecentNavigatedTocItem</button><br>

<button onclick="javascript:D2Reader.resetUserSettings()">reset user setting</button><br>
<button onclick="javascript:D2Reader.publisher(true)">publisher default</button><br>
Expand Down

0 comments on commit eb4fa2c

Please sign in to comment.