This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let flow = new Flow("#someid"); | |
let page = flow.pages(":first"); | |
page.toRange(); | |
let words = flow.pages().sentences(":last").words(-3); | |
words.wrap("<span class='no-break'>"); | |
words.breakBefore(); | |
words.breakAfter(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
book.on('renderer:locationChanged', function(locationCfi){ | |
var epubcfi = new EPUBJS.EpubCFI(); | |
var doc = book.renderer.doc; | |
var mark = document.createElement("a"); | |
// Give the marker an unique id | |
mark.id = "look-for-me-1234"; | |
// Add the marker | |
epubcfi.addMarker(locationCfi, doc, marker); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Book.on("renderer:visibleRangeChanged", function(cfirange) { | |
var text = ''; | |
var cfi = new EPUBJS.EpubCFI(); | |
var startRange = cfi.generateRangeFromCfi(cfirange.start, Book.renderer.render.document); | |
var endRange = cfi.generateRangeFromCfi(cfirange.end, Book.renderer.render.document); | |
// Create a new range to handle full cfi range (this should be fixed in v0.3) | |
var fullRange = document.createRange(); | |
if (startRange) { | |
fullRange.setStart(startRange.startContainer, startRange.startOffset); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From: https://github.com/futurepress/epub.js/blob/master/reader_src/controllers/controls_controller.js | |
var hashChanged = function(){ | |
var hash = window.location.hash.slice(1); | |
book.goto(hash); | |
}; | |
book.on('renderer:locationChanged', function(cfi){ | |
var cfiFragment = "#" + cfi; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var epubcfi = new EPUBJS.EpubCFI(); | |
var text; | |
// Find the range | |
var range = epubcfi.generateRangeFromCfi("epubcfi(/6/14[xchapter_001]!4/2/14/2[c001p0006]/1:305)", Book.renderer.doc); | |
text = range.toString(); | |
// Or find the containing element and then get the offset | |
var parent = epubcfi.findParent("epubcfi(/6/14[xchapter_001]!4/2/14/2[c001p0006]/1:305)", Book.renderer.doc); | |
text = parent.textContent |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<display_options> | |
<platform name="*"> <!-- all devices --> | |
<option name="fixed-layout">true</option> <!-- fixes the layout --> | |
<option name="specified-fonts">true</option> <!-- set to "true" when embedding fonts --> | |
<option name="open-to-spread">true</option> <!-- single page or full spread on open --> | |
<!--<option name="orientation-lock">landscape-only</option> "landscape-only" or "portrait-only" or leave this line commented --> | |
<option name="interactive">true</option> <!-- set to "true" when using javascript or canvas --> | |
</platform> | |
</display_options> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EPUBJS.Hooks.register("beforeChapterDisplay").overrideStyles = function(callback, renderer){ | |
EPUBJS.core.addCss("overrides.css", false, renderer.render.document.head); | |
callback(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops"> | |
<head> | |
<title>YOUR TITLE</title> | |
</head> | |
<body> | |
YOUR CONTENT | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USERNAME = 'abc' | |
PASSWORD = 'xyz' | |
EPUBJS.core.request = function(url, type) { | |
var supportsURL = window.URL; | |
var BLOB_RESPONSE = supportsURL ? "blob" : "arraybuffer"; | |
var deferred = new RSVP.defer(); | |
var xhr = new XMLHttpRequest(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function request(url, response, failure) { | |
var request = new XMLHttpRequest(); | |
var failed = failure || function(){}; | |
request.open("GET", url, true); | |
request.onreadystatechange = function(e) { | |
if(request.readyState == 4) { | |
if(request.status == 200) { |
NewerOlder