1 // QuanLib: eBook Library
2 // Copyright (C) 2017 by Christian Jaekl (cejaekl@yahoo.com)
6 // Global state information (yuck). TODO: refactor this to compartmentalize.
8 mousePos: { // Last known position of the mouse cursor
17 Browser.setOnMouseMove(onMouseMove);
19 BooksView.init(BooksModel);
20 PagingController.init(BooksModel);
21 SearchController.init(BooksModel);
23 if (Modernizr.fetch) {
24 console.log('quanweb: browser feature check: OK');
27 // If we cared about supporting older browsers (at this point, IE11 and Adroid 4.x's built-in browser,
28 // neither of which is due to receive security patch support for much longer), then we would insert a
29 // shim here to implement the fetch API. But, in this case, we don't and won't.
30 alert('Sorry, this page will not work in your browser.\nPlease use a recent version of Chrome, Edge or Firefox instead.');
36 // TODO: refactor this to compartmentalize more functionality.
38 function report(message) {
39 Browser.getElementById('books').innerHTML = message;
42 function onMouseMove(event) {
43 if (typeof event === 'undefined') {
50 if ( x === g_state.mousePos.x
51 && y === g_state.mousePos.y)
53 // No change from previous known position.
54 // Nothing to see (or do) here, move along.
58 // Remember current mouse (x,y) position
59 g_state.mousePos.x = x;
60 g_state.mousePos.y = y;
62 ToolTip.mouseMoved(x, y);
66 if (BooksModel.last < (BooksModel.count - 1)) {
67 PagingController.adjustPos(BooksModel.first + BooksModel.pageSize);
72 if (BooksModel.first > 0) {
73 PagingController.adjustPos(BooksModel.first - BooksModel.pageSize);
77 function onSlide(value) {
78 PagingController.adjustPos(value);
82 SearchController.onSearch();