Skip to content

Commit

Permalink
Remember sidebar width between sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
amykyta3 committed Oct 7, 2022
1 parent 8bfade7 commit dfa2e40
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 20 deletions.
38 changes: 19 additions & 19 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<style>
html{box-sizing:border-box}*,*:before,*:after{box-sizing:inherit}
</style>
<link rel="stylesheet" href="css/normalize.css?v=2.8.0">
<link rel="stylesheet" href="css/layout.css?v=2.8.0">
<link rel="stylesheet" href="css/theme.css?v=2.8.0">
<link rel="stylesheet" href="css/normalize.css?v=2.9.0">
<link rel="stylesheet" href="css/layout.css?v=2.9.0">
<link rel="stylesheet" href="css/theme.css?v=2.9.0">
<link rel="icon" type="image/png" href="favicon.png">
<script>
var BUILD_TS = 1665116151;
var BUILD_TS = 1665117258;
</script>
<script async src="https://cdn.jsdelivr.net/npm/mathjax@2/MathJax.js"></script>
<script type="text/x-mathjax-config">
Expand All @@ -24,20 +24,20 @@
extensions: ["MathMenu.js", "MathZoom.js"]
});
</script>
<script src="js/progressbar.min.js?v=2.8.0" type="text/javascript"></script>
<script src="js/sha1.js?v=2.8.0" type="text/javascript"></script>
<script src="data/data_index.js?ts=1665116151" type="text/javascript"></script>
<script src="search/bkt_index.js?ts=1665116151" type="text/javascript"></script>
<script src="js/ral.js?v=2.8.0" type="text/javascript"></script>
<script src="js/main.js?v=2.8.0" type="text/javascript"></script>
<script src="js/nav.js?v=2.8.0" type="text/javascript"></script>
<script src="js/sidebar.js?v=2.8.0" type="text/javascript"></script>
<script src="js/index_edit.js?v=2.8.0" type="text/javascript"></script>
<script src="js/field_testers.js?v=2.8.0" type="text/javascript"></script>
<script src="js/search.js?v=2.8.0" type="text/javascript"></script>
<script src="js/address_search.js?v=2.8.0" type="text/javascript"></script>
<script src="js/path_search.js?v=2.8.0" type="text/javascript"></script>
<script src="js/content_search.js?v=2.8.0" type="text/javascript"></script>
<script src="js/progressbar.min.js?v=2.9.0" type="text/javascript"></script>
<script src="js/sha1.js?v=2.9.0" type="text/javascript"></script>
<script src="data/data_index.js?ts=1665117258" type="text/javascript"></script>
<script src="search/bkt_index.js?ts=1665117258" type="text/javascript"></script>
<script src="js/ral.js?v=2.9.0" type="text/javascript"></script>
<script src="js/main.js?v=2.9.0" type="text/javascript"></script>
<script src="js/nav.js?v=2.9.0" type="text/javascript"></script>
<script src="js/sidebar.js?v=2.9.0" type="text/javascript"></script>
<script src="js/index_edit.js?v=2.9.0" type="text/javascript"></script>
<script src="js/field_testers.js?v=2.9.0" type="text/javascript"></script>
<script src="js/search.js?v=2.9.0" type="text/javascript"></script>
<script src="js/address_search.js?v=2.9.0" type="text/javascript"></script>
<script src="js/path_search.js?v=2.9.0" type="text/javascript"></script>
<script src="js/content_search.js?v=2.9.0" type="text/javascript"></script>
</head>

<body class="pack-h" onload="onPageLoad()">
Expand Down Expand Up @@ -97,7 +97,7 @@
<div class="main stretchy limit-h"></div>
<footer class="main limit-h">
<hr/>
Generated by PeakRDL-html v2.8.0
Generated by PeakRDL-html v2.9.0
</footer>
</div>

Expand Down
6 changes: 6 additions & 0 deletions docs/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,12 @@ function toBigInt(str) {
}
}

function page_specific_key(key){
var url = new URL(window.location.href);
key = url.origin + url.pathname + "::" + key;
return key;
}

//==============================================================================
// Compatibility Workarounds
//==============================================================================
Expand Down
11 changes: 11 additions & 0 deletions docs/js/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ class Sidebar {

// Create and expand nodes up to the current selected ID
this.expand_to_id(first_id);

// restore sidebar width from previous session
var sb_width = localStorage.getItem(page_specific_key("sb_width"));
if(sb_width != null){
var sb_el = document.getElementById("_SBContents");
sb_el.style.width = sb_width;
}
}

static expand_to_id(id){
Expand Down Expand Up @@ -212,6 +219,10 @@ class Sidebar {
static #onResizeMouseUp(e) {
window.removeEventListener('mousemove', this.#mousemove_cb);
window.removeEventListener('mouseup', this.#mouseup_cb);

// remember sidebar width
var sb_el = document.getElementById("_SBContents");
localStorage.setItem(page_specific_key("sb_width"), sb_el.style.width);
}

static show() {
Expand Down
2 changes: 1 addition & 1 deletion src/peakrdl_html/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.8.0"
__version__ = "2.9.0"
6 changes: 6 additions & 0 deletions src/peakrdl_html/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,12 @@ function toBigInt(str) {
}
}

function page_specific_key(key){
var url = new URL(window.location.href);
key = url.origin + url.pathname + "::" + key;
return key;
}

//==============================================================================
// Compatibility Workarounds
//==============================================================================
Expand Down
11 changes: 11 additions & 0 deletions src/peakrdl_html/static/js/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ class Sidebar {

// Create and expand nodes up to the current selected ID
this.expand_to_id(first_id);

// restore sidebar width from previous session
var sb_width = localStorage.getItem(page_specific_key("sb_width"));
if(sb_width != null){
var sb_el = document.getElementById("_SBContents");
sb_el.style.width = sb_width;
}
}

static expand_to_id(id){
Expand Down Expand Up @@ -212,6 +219,10 @@ class Sidebar {
static #onResizeMouseUp(e) {
window.removeEventListener('mousemove', this.#mousemove_cb);
window.removeEventListener('mouseup', this.#mouseup_cb);

// remember sidebar width
var sb_el = document.getElementById("_SBContents");
localStorage.setItem(page_specific_key("sb_width"), sb_el.style.width);
}

static show() {
Expand Down

0 comments on commit dfa2e40

Please sign in to comment.