| 1 |
# vim:fileencoding=utf-8 |
| 2 |
# License: GPL v3 Copyright: 2019, Kovid Goyal <kovid at kovidgoyal.net> |
| 3 |
# noqa: eol-semicolon |
| 4 |
from __python__ import bound_methods, hash_literals |
| 5 |
|
| 6 |
from read_book.globals import current_spine_item |
| 7 |
|
| 8 |
|
| 9 |
def elem_for_ref(refnum): |
| 10 |
refnum = int(refnum) |
| 11 |
return document.getElementsByTagName('p')[refnum - 1] |
| 12 |
|
| 13 |
|
| 14 |
def start_reference_mode(): |
| 15 |
si = current_spine_item().index |
| 16 |
for i, p in enumerate(document.getElementsByTagName('p')): |
| 17 |
p.dataset.calibreRefNum = f'{si}.{i + 1}' |
| 18 |
document.body.classList.add('calibre-reference-mode') |
| 19 |
|
| 20 |
|
| 21 |
def end_reference_mode(): |
| 22 |
document.body.classList.remove('calibre-reference-mode') |