diff --git a/public/js/reader.js b/public/js/reader.js index 1aa1bd1..f227972 100644 --- a/public/js/reader.js +++ b/public/js/reader.js @@ -10,6 +10,7 @@ const readerComponent = () => { longPages: false, lastSavedPage: page, selectedIndex: 0, // 0: not selected; 1: the first page + margin: 30, /** * Initialize the component by fetching the page dimensions @@ -27,7 +28,6 @@ const readerComponent = () => { url: `${base_url}api/page/${tid}/${eid}/${i+1}`, width: d.width, height: d.height, - style: `margin-top: ${data.margin}px; margin-bottom: ${data.margin}px;` }; }); @@ -47,6 +47,11 @@ const readerComponent = () => { const mode = this.mode; this.updateMode(this.mode, page, nextTick); $('#mode-select').val(mode); + + const savedMargin = localStorage.getItem('margin'); + if (savedMargin) { + this.margin = savedMargin; + } }) .catch(e => { const errMsg = `Failed to get the page dimensions. ${e}`; @@ -277,6 +282,11 @@ const readerComponent = () => { entryChanged() { const id = $('#entry-select').val(); this.redirect(`${base_url}reader/${tid}/${id}`); + }, + + marginChanged() { + localStorage.setItem('margin', this.margin); + this.toPage(this.selectedIndex); } }; } diff --git a/src/config.cr b/src/config.cr index abacbb3..dc7e35c 100644 --- a/src/config.cr +++ b/src/config.cr @@ -20,7 +20,6 @@ class Config property plugin_path : String = File.expand_path "~/mango/plugins", home: true property download_timeout_seconds : Int32 = 30 - property page_margin : Int32 = 30 property disable_login = false property default_username = "" property auth_proxy_header_name = "" diff --git a/src/routes/api.cr b/src/routes/api.cr index 7d2af12..34e2857 100644 --- a/src/routes/api.cr +++ b/src/routes/api.cr @@ -612,7 +612,6 @@ struct APIRouter "width" => Int32, "height" => Int32, }], - "margin" => Int32?, } get "/api/dimensions/:tid/:eid" do |env| begin @@ -628,7 +627,6 @@ struct APIRouter send_json env, { "success" => true, "dimensions" => sizes, - "margin" => Config.current.page_margin, }.to_json rescue e send_json env, { diff --git a/src/views/reader.html.ecr b/src/views/reader.html.ecr index 0b4ee4d..9604c61 100644 --- a/src/views/reader.html.ecr +++ b/src/views/reader.html.ecr @@ -25,11 +25,11 @@ @@ -80,6 +80,7 @@ +
@@ -90,6 +91,13 @@
+
+ +
+ +
+
+