summaryrefslogtreecommitdiffstats
path: root/theme/javascript/state.js
blob: 5fde20f642b38d7d29f42f3c8000242a3b48e88d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
var $ = require('jquery');
var url = require('url');
var path = require('path');

var state = {};

state.update = function(dom) {
    var $book = $(dom.find('.book'));

    state.$book = $book;
    state.level = $book.data('level');
    state.basePath = $book.data('basepath');
    state.revision = $book.data('revision');
    state.filepath = $book.data('filepath');

    // Absolute url to the root of the book
    state.root = url.resolve(
        location.protocol+'//'+location.host,
        path.dirname(path.resolve(location.pathname, state.basePath))
    );
};

state.update($);

module.exports = state;