diff options
-rw-r--r-- | backend.php | 46 | ||||
-rw-r--r-- | js/read.js | 6 | ||||
-rw-r--r-- | read.html | 15 |
3 files changed, 11 insertions, 56 deletions
diff --git a/backend.php b/backend.php index 1a4acdc..b6e840c 100644 --- a/backend.php +++ b/backend.php @@ -67,52 +67,6 @@ break; - case "setsetting": - $key_map = [ - "fontSize" => "font_size", - "fontFamily" => "font_family", - "lineHeight" => "line_height" - ]; - - print $key; - - $key = $key_map[$_REQUEST["key"]]; - $value = db_escape_string($_REQUEST["value"]); - - if ($key && $value) { - db_query($link, "UPDATE epube_settings SET $key = '$value' WHERE owner = '$owner'"); - } - - break; - - case "getsettings": - - $settings = [ - "fontSize" => "16", - "fontFamily" => "Georgia", - "lineHeight" => "100", - ]; - - $result = db_query($link, "SELECT * FROM epube_settings WHERE owner = '$owner' LIMIT 1"); - - if (db_num_rows($result) != 0) { - - $line = db_fetch_assoc($result); - - $settings["fontSize"] = (int)$line["font_size"]; - $settings["fontFamily"] = $line["font_family"]; - $settings["lineHeight"] = (int)$line["line_height"]; - - } else { - db_query($link, "INSERT INTO epube_settings (owner, font_family, font_size, line_height) VALUES - ('$owner', '".$settings["fontFamily"]."','".$settings["fontSize"]."','".$settings["lineHeight"]."')"); - - } - - print json_encode($settings); - - break; - case "getpagination": $bookid = db_escape_string($_REQUEST["id"]); @@ -66,7 +66,7 @@ function lmargin(incr) { var cur = parseInt(window.book.settings.styles.lineHeight.replace("%", "")); var size = cur + incr; - $.post("backend.php", { op: "setsetting", key: "lineHeight", value: size }); + localStorage["epube:lineHeight"] = size; window.book.setStyle("lineHeight", size + "%"); @@ -75,7 +75,7 @@ function lmargin(incr) { function apply_font(elem) { var font = elem[elem.selectedIndex].value; - $.post("backend.php", { op: "setsetting", key: "fontFamily", value: font }); + localStorage["epube:fontFamily"] = font; window.book.setStyle("fontFamily", font); @@ -84,7 +84,7 @@ function zoom(incr) { var cur = parseInt(window.book.settings.styles.fontSize.replace("px", "")); var size = cur + incr; - $.post("backend.php", { op: "setsetting", key: "fontSize", value: size }); + localStorage["epube:fontSize"] = size; window.book.setStyle("fontSize", size + "px"); @@ -165,13 +165,14 @@ book.open(book_url); - $.get("backend.php", { op: "getsettings" }, function(data) { - console.log(data); - - book.setStyle("fontSize", data.fontSize + "px"); - book.setStyle("fontFamily", data.fontFamily); - book.setStyle("lineHeight", data.lineHeight + "%"); - }); + var settings = { + fontSize: localStorage['epube:fontSize'] ? localStorage['epube:fontSize'] : '16px', + fontFamily: localStorage['epube:fontFamily'] ? localStorage['epube:fontFamily'] : 'Georgia', + lineHeight: localStorage['epube:lineHeight'] ? localStorage['epube:lineHeight'] : '140%' }; + + book.setStyle("fontSize", settings.fontSize + "px"); + book.setStyle("fontFamily", settings.fontFamily); + book.setStyle("lineHeight", settings.lineHeight + "%"); //styles: { fontSize: '24px', lineHeight: '130%', fontFamily: 'Georgia' } |