add forward and back button instead of just up
This commit is contained in:
parent
424653b67c
commit
ea07f04a34
|
@ -33,6 +33,10 @@
|
||||||
<div class="flex-col outer-container">
|
<div class="flex-col outer-container">
|
||||||
<div class="flex-row">
|
<div class="flex-row">
|
||||||
<div class="nav-btn-group">
|
<div class="nav-btn-group">
|
||||||
|
<button class="pf-c-button pf-m-secondary" id="nav-back-btn"><i class="fas fa-arrow-left"></i></button>
|
||||||
|
<div class="horizontal-spacer"></div>
|
||||||
|
<button class="pf-c-button pf-m-secondary" id="nav-forward-btn"><i class="fas fa-arrow-right"></i></button>
|
||||||
|
<div class="horizontal-spacer"></div>
|
||||||
<button class="pf-c-button pf-m-secondary" id="nav-up-dir-btn"><i class="fas fa-arrow-up"></i></button>
|
<button class="pf-c-button pf-m-secondary" id="nav-up-dir-btn"><i class="fas fa-arrow-up"></i></button>
|
||||||
<div class="horizontal-spacer"></div>
|
<div class="horizontal-spacer"></div>
|
||||||
<button class="pf-c-button pf-m-secondary" id="nav-refresh-btn"><i class="fas fa-sync"></i></button>
|
<button class="pf-c-button pf-m-secondary" id="nav-refresh-btn"><i class="fas fa-sync"></i></button>
|
||||||
|
|
|
@ -82,6 +82,9 @@ class NavEntry {
|
||||||
path_str() {
|
path_str() {
|
||||||
return "/" + this.path.join('/');
|
return "/" + this.path.join('/');
|
||||||
}
|
}
|
||||||
|
parent_dir() {
|
||||||
|
return this.path.slice(0, this.path.length - 1);
|
||||||
|
}
|
||||||
show() {
|
show() {
|
||||||
document.getElementById("nav-contents-view").appendChild(this.dom_element);
|
document.getElementById("nav-contents-view").appendChild(this.dom_element);
|
||||||
}
|
}
|
||||||
|
@ -253,6 +256,7 @@ class NavDir extends NavEntry {
|
||||||
class NavWindow {
|
class NavWindow {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.path_stack = [new NavDir("/", this)];
|
this.path_stack = [new NavDir("/", this)];
|
||||||
|
this.path_stack_index = this.path_stack.length - 1;
|
||||||
this.selected_entry = this.pwd();
|
this.selected_entry = this.pwd();
|
||||||
this.entries = [];
|
this.entries = [];
|
||||||
this.window = document.getElementById("nav-contents-view");
|
this.window = document.getElementById("nav-contents-view");
|
||||||
|
@ -281,21 +285,29 @@ class NavWindow {
|
||||||
this.show_selected_properties();
|
this.show_selected_properties();
|
||||||
}
|
}
|
||||||
pwd() {
|
pwd() {
|
||||||
return this.path_stack[this.path_stack.length - 1];
|
return this.path_stack[this.path_stack_index];
|
||||||
}
|
}
|
||||||
cd(new_dir) {
|
cd(new_dir) {
|
||||||
|
this.path_stack.length = this.path_stack_index + 1;
|
||||||
this.path_stack.push(new_dir);
|
this.path_stack.push(new_dir);
|
||||||
|
this.path_stack_index = this.path_stack.length - 1;
|
||||||
this.refresh().catch(() => {
|
this.refresh().catch(() => {
|
||||||
this.path_stack.pop();
|
this.path_stack.pop();
|
||||||
this.refresh();
|
this.refresh();
|
||||||
window.alert(new_dir.path_str() + " is inaccessible.");
|
window.alert(new_dir.path_str() + " is inaccessible.");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
up() {
|
back() {
|
||||||
if(this.path_stack.length > 1)
|
this.path_stack_index = Math.max(this.path_stack_index - 1, 0);
|
||||||
this.path_stack.pop();
|
|
||||||
this.refresh();
|
this.refresh();
|
||||||
}
|
}
|
||||||
|
forward() {
|
||||||
|
this.path_stack_index = Math.min(this.path_stack_index + 1, this.path_stack.length - 1);
|
||||||
|
this.refresh();
|
||||||
|
}
|
||||||
|
up() {
|
||||||
|
this.cd(new NavDir(this.pwd().parent_dir()));
|
||||||
|
}
|
||||||
show_selected_properties() {
|
show_selected_properties() {
|
||||||
this.selected_entry.show_properties();
|
this.selected_entry.show_properties();
|
||||||
}
|
}
|
||||||
|
@ -418,6 +430,8 @@ class NavWindow {
|
||||||
let nav_window = new NavWindow();
|
let nav_window = new NavWindow();
|
||||||
|
|
||||||
function set_up_buttons() {
|
function set_up_buttons() {
|
||||||
|
document.getElementById("nav-back-btn").addEventListener("click", nav_window.back.bind(nav_window));
|
||||||
|
document.getElementById("nav-forward-btn").addEventListener("click", nav_window.forward.bind(nav_window));
|
||||||
document.getElementById("nav-up-dir-btn").addEventListener("click", nav_window.up.bind(nav_window));
|
document.getElementById("nav-up-dir-btn").addEventListener("click", nav_window.up.bind(nav_window));
|
||||||
document.getElementById("nav-refresh-btn").addEventListener("click", nav_window.refresh.bind(nav_window));
|
document.getElementById("nav-refresh-btn").addEventListener("click", nav_window.refresh.bind(nav_window));
|
||||||
document.getElementById("nav-mkdir-btn").addEventListener("click", nav_window.mkdir.bind(nav_window));
|
document.getElementById("nav-mkdir-btn").addEventListener("click", nav_window.mkdir.bind(nav_window));
|
||||||
|
|
Loading…
Reference in New Issue