Compare commits
No commits in common. "2fdd070361562e5c87701530a6ee5e53676bfb27" and "f104a688f203220610001a29e4457ce27252c016" have entirely different histories.
2fdd070361
...
f104a688f2
4 changed files with 90 additions and 147 deletions
|
|
@ -79,7 +79,7 @@ class Icons(dict):
|
||||||
c.close()
|
c.close()
|
||||||
conn.close()
|
conn.close()
|
||||||
except:
|
except:
|
||||||
logger.debug('failed to insert icon %s', id, exc_info=True)
|
logger.debug('failed to insert icon %s', id)
|
||||||
|
|
||||||
def __delitem__(self, id):
|
def __delitem__(self, id):
|
||||||
sql = 'DELETE FROM icon WHERE id = ?'
|
sql = 'DELETE FROM icon WHERE id = ?'
|
||||||
|
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
|
|
||||||
::selection {
|
|
||||||
background: rgba(255,255,0, 0.3)
|
|
||||||
}
|
|
||||||
.epubjs-hl {
|
|
||||||
fill: yellow;
|
|
||||||
fill-opacity: 0.3;
|
|
||||||
mix-blend-mode: multiply;
|
|
||||||
}
|
|
||||||
.epubjs-hl.selected {
|
|
||||||
fill: blue;
|
|
||||||
}
|
|
||||||
|
|
@ -11,7 +11,6 @@
|
||||||
<link rel="stylesheet" href="/static/epub.js/css/normalize.css?2">
|
<link rel="stylesheet" href="/static/epub.js/css/normalize.css?2">
|
||||||
<link rel="stylesheet" href="/static/epub.js/css/main.css?2">
|
<link rel="stylesheet" href="/static/epub.js/css/main.css?2">
|
||||||
<link rel="stylesheet" href="/static/epub.js/css/popup.css?2">
|
<link rel="stylesheet" href="/static/epub.js/css/popup.css?2">
|
||||||
<link rel="stylesheet" href="/static/epub.js/css/annotations.css?2">
|
|
||||||
<style>
|
<style>
|
||||||
.arrow {
|
.arrow {
|
||||||
-webkit-user-select: none;
|
-webkit-user-select: none;
|
||||||
|
|
@ -92,18 +91,50 @@
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script src="/static/epub.js/js/libs/jquery.min.js"></script>
|
<script src="/static/epub.js/libs/jquery-2.1.0.min.js"></script>
|
||||||
<script src="/static/epub.js/js/libs/zip.min.js"></script>
|
|
||||||
<script src="/static/reader/epub.js"></script>
|
<script src="/static/epub.js/libs/zip.min.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
"use strict";
|
||||||
|
var reader;
|
||||||
|
document.onreadystatechange = function () {
|
||||||
|
if (document.readyState == "complete") {
|
||||||
|
EPUBJS.filePath = "/static/epub.js/libs/";
|
||||||
|
EPUBJS.cssPath = "/static/epub.js/css/";
|
||||||
|
// fileStorage.filePath = EPUBJS.filePath;
|
||||||
|
reader = ePubReader(document.location.pathname.replace(/\/reader\//, '/epub/'));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
<!-- Render -->
|
<!-- Render -->
|
||||||
<script src="/static/epub.js/js/epub.js"></script>
|
<script src="/static/epub.js/epub.js"></script>
|
||||||
|
|
||||||
|
<!-- Hooks -->
|
||||||
|
<script src="/static/epub.js/hooks.js"></script>
|
||||||
|
|
||||||
<!-- Reader -->
|
<!-- Reader -->
|
||||||
<script src="/static/epub.js/js/reader.min.js"></script>
|
<script src="/static/epub.js/reader.js"></script>
|
||||||
|
|
||||||
<!-- Plugins -->
|
<!-- Plugins -->
|
||||||
<!-- <script src="js/plugins/search.js"></script> -->
|
<!--
|
||||||
|
<script src="/static/epub.js/plugins/search.js"></script>
|
||||||
|
-->
|
||||||
|
|
||||||
<!-- Highlights -->
|
<!-- Highlights -->
|
||||||
<!-- <script src="/static/epub.js/js/hooks/extensions/highlight.js"></script> -->
|
<!--
|
||||||
|
<script src="/static/epub.js/libs/jquery.highlight.js"></script>
|
||||||
|
<script src="/static/epub.js/hooks/extensions/highlight.js"></script>
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- File Storage -->
|
||||||
|
<!-- <script src="/static/epub.js/libs/fileStorage.min.js"></script> -->
|
||||||
|
|
||||||
|
<!-- Full Screen -->
|
||||||
|
<!--
|
||||||
|
<script src="/static/epub.js/libs/screenfull.min.js"></script>
|
||||||
|
-->
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="sidebar">
|
<div id="sidebar">
|
||||||
|
|
@ -118,6 +149,7 @@
|
||||||
<!--
|
<!--
|
||||||
<a id="show-Notes" class="show_view icon-edit" data-view="Notes">Notes</a>
|
<a id="show-Notes" class="show_view icon-edit" data-view="Notes">Notes</a>
|
||||||
-->
|
-->
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div id="tocView" class="view">
|
<div id="tocView" class="view">
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,77 +0,0 @@
|
||||||
"use strict";
|
|
||||||
var reader;
|
|
||||||
var id = document.location.pathname.split('/')[1];
|
|
||||||
var annotations = JSON.parse(localStorage[id + '.annotations'] || '[]')
|
|
||||||
|
|
||||||
function saveAnnotations() {
|
|
||||||
localStorage[id + '.annotations'] = JSON.stringify(annotations)
|
|
||||||
}
|
|
||||||
|
|
||||||
function getText(book, cfiRange, cb) {
|
|
||||||
book.getRange(cfiRange).then(function (range) {
|
|
||||||
var text;
|
|
||||||
if (range) {
|
|
||||||
text = range.toString();
|
|
||||||
}
|
|
||||||
cb(text)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function onHighlightClicked(e) {
|
|
||||||
console.log("highlight clicked", e.target.dataset.epubcfi);
|
|
||||||
if(e.target.classList.contains('selected')) {
|
|
||||||
e.target.classList.remove('selected')
|
|
||||||
} else {
|
|
||||||
document.querySelectorAll('.epubjs-hl.selected').forEach(function(other) {
|
|
||||||
other.classList.remove('selected')
|
|
||||||
})
|
|
||||||
e.target.classList.add('selected')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
document.onreadystatechange = function () {
|
|
||||||
if (document.readyState == "complete") {
|
|
||||||
EPUBJS.filePath = "/static/epub.js/js/libs/";
|
|
||||||
EPUBJS.cssPath = "/static/epub.js/css/";
|
|
||||||
EPUBJS.core.addCss('/static/css/epub.css')
|
|
||||||
// fileStorage.filePath = EPUBJS.filePath;
|
|
||||||
reader = ePubReader(document.location.pathname.replace(/\/reader\//, '/epub/'), {
|
|
||||||
restore: true
|
|
||||||
});
|
|
||||||
var rendition = reader.rendition,
|
|
||||||
book = reader.book;
|
|
||||||
|
|
||||||
annotations.forEach(function(a) {
|
|
||||||
rendition.annotations.highlight(a.cfiRange, a.data || {}, onHighlightClicked);
|
|
||||||
})
|
|
||||||
|
|
||||||
reader.rendition.on('keydown', function(event) {
|
|
||||||
if (event.key == 'Delete') {
|
|
||||||
document.querySelectorAll('.epubjs-hl.selected').forEach(function(a) {
|
|
||||||
annotations = annotations.filter(function(annotation) {
|
|
||||||
return annotation.cfiRange != a.dataset.epubcfi
|
|
||||||
})
|
|
||||||
rendition.annotations.remove(a.dataset.epubcfi)
|
|
||||||
saveAnnotations()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
rendition.on("selected", function(cfiRange, contents) {
|
|
||||||
getText(book, cfiRange, function(quote) {
|
|
||||||
var data = {
|
|
||||||
quote: quote
|
|
||||||
}
|
|
||||||
rendition.annotations.highlight(cfiRange, data, onHighlightClicked);
|
|
||||||
annotations.push({
|
|
||||||
cfiRange: cfiRange,
|
|
||||||
data: data
|
|
||||||
})
|
|
||||||
saveAnnotations()
|
|
||||||
document.querySelectorAll('.epubjs-hl.selected').forEach(function(other) {
|
|
||||||
other.classList.remove('selected')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
contents.window.getSelection().removeAllRanges();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue