wepub

Check-in [3f780220b4]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Tap to adjust font size.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256:3f780220b41cd150de1776d2692d4971959269c998ba475d9c8c2309cd04b3c7
User & Date: ajv-899-334-8894@vsta.org 2017-04-06 04:01:42
Context
2017-06-24
04:32
Add UI for font size up/down, smooth scroll, save font size for book. check-in: 5d74a2880e user: ajv-899-334-8894@vsta.org tags: master, trunk
2017-04-06
04:01
Tap to adjust font size. check-in: 3f780220b4 user: ajv-899-334-8894@vsta.org tags: master, trunk
2016-11-24
17:12
Flatten extended code points. TBD if we should lean on UTF8. check-in: 959a164154 user: ajv-899-334-8894@vsta.org tags: master, trunk
Changes
Hide Diffs Unified Diffs Show Whitespace Changes Patch

Changes to get.py.

152
153
154
155
156
157
158
159

160
161
162
163
164
165
166
            head = "%s chapter %d" % (nm, chapnum)
            buf = self.build_header(head)
            buf += '<script src="/js/reader.js"></script>\n'
            if chapnum > 0:
                buf += '<a href="%d">Previous Chapter</a>\n' % \
                 (chapnum-1,)
            buf += '<div id="textview"\n'
            buf += '  style="color: white; background: black; width: 100%;">\n'

            buf += chore.utils.uncharenc(chap.read())
            buf += '</div>\n'
            if chapnum < len(book.chapters)-1:
                buf += '<a href="%d">Next Chapter</a>\n' % \
                 (chapnum+1,)
            doc.close()
            buf += '<script>reading("%s", "%s", "%s");</script>\n' % \







|
>







152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
            head = "%s chapter %d" % (nm, chapnum)
            buf = self.build_header(head)
            buf += '<script src="/js/reader.js"></script>\n'
            if chapnum > 0:
                buf += '<a href="%d">Previous Chapter</a>\n' % \
                 (chapnum-1,)
            buf += '<div id="textview"\n'
            buf += '  style="color: white; background: black;'
            buf += '  width: 100%; font-size: 14px;">\n'
            buf += chore.utils.uncharenc(chap.read())
            buf += '</div>\n'
            if chapnum < len(book.chapters)-1:
                buf += '<a href="%d">Next Chapter</a>\n' % \
                 (chapnum+1,)
            doc.close()
            buf += '<script>reading("%s", "%s", "%s");</script>\n' % \

Changes to js/reader.js.

10
11
12
13
14
15
16



17
18
19
20
21
22
23
..
87
88
89
90
91
92
93
























94
95
96
97
98
99
100
101
102
103



104
105
106
107
108
109
110
var docname = null;

// Section number
var secnum = null;

// Web element with text content which scrolls
var pane = null;




// Wrappers for XMLHttpRequest
function xhr_get(url, fn) {
    var req = new XMLHttpRequest();
    req.open("GET", url);
    req.onreadystatechange = function() {
        // Ignore progress/errors
................................................................................
        st.pos = parseFloat(d.scrollTop) / parseFloat(d.scrollHeight);

        // Send it over
        xhr_put_json("/state.json?doc=" + encodeURIComponent(docname),
            JSON.stringify(st), null);
    }
}

























// On page load, configure to track this user for this scrollable
//  text content of this document.  If there's a saved position,
//  scroll to it.
function reading(arg_who, arg_doc, arg_pane) {
    // Save for future
    who = arg_who;
    docname = arg_doc;
    pane = document.getElementById(arg_pane);




    // Calculate section number
    var url = document.URL;
    var slidx = url.lastIndexOf('/');
    if (slidx > 0) {
        secnum = parseInt(url.slice(slidx+1));
    }








>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>










>
>
>







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
..
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
var docname = null;

// Section number
var secnum = null;

// Web element with text content which scrolls
var pane = null;

// Current font size
var curSize = 14;

// Wrappers for XMLHttpRequest
function xhr_get(url, fn) {
    var req = new XMLHttpRequest();
    req.open("GET", url);
    req.onreadystatechange = function() {
        // Ignore progress/errors
................................................................................
        st.pos = parseFloat(d.scrollTop) / parseFloat(d.scrollHeight);

        // Send it over
        xhr_put_json("/state.json?doc=" + encodeURIComponent(docname),
            JSON.stringify(st), null);
    }
}

// They tapped the screen.
//
// First pass, upper half shrinks text, lower grows.
function tapped(ev) {
    // When we changed font size, our scroll position has to be refreshed
    //  to be the same portion of the new scrollable size.
    var d = document.scrollingElement;
    var pos = parseFloat(d.scrollTop) / parseFloat(d.scrollHeight);

    // Shrink for upper tap, grow for lower
    var coord = ev.screenY;
    if (coord < window.innerHeight/2) {
        if (curSize > 4) {
            curSize -= 2;
        }
    } else {
        curSize += 2;
    }
    pane.style.fontSize = curSize.toString() + "px";

    // Now reposition based on new scrollHeight
    d.scrollTop = d.scrollHeight * pos;
}

// On page load, configure to track this user for this scrollable
//  text content of this document.  If there's a saved position,
//  scroll to it.
function reading(arg_who, arg_doc, arg_pane) {
    // Save for future
    who = arg_who;
    docname = arg_doc;
    pane = document.getElementById(arg_pane);

    // Tap handler
    pane.onclick = tapped;

    // Calculate section number
    var url = document.URL;
    var slidx = url.lastIndexOf('/');
    if (slidx > 0) {
        secnum = parseInt(url.slice(slidx+1));
    }