mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-12 22:25:44 -04:00
Restore preferred snapshots view from localstorage
This commit is contained in:
parent
7db6b0a8a6
commit
8fca36a7cd
1 changed files with 30 additions and 4 deletions
|
@ -189,20 +189,46 @@
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function bindSnapshotViewsClick() {
|
function selectSnapshotListView(){
|
||||||
|
myStorage.setItem('currentSnapshotView', 'List');
|
||||||
|
redirectWithQuery("{% url 'admin:core_snapshot_changelist' %}");
|
||||||
|
};
|
||||||
|
|
||||||
|
function selectSnapshotGridView(){
|
||||||
|
myStorage.setItem('currentSnapshotView', 'Grid');
|
||||||
|
redirectWithQuery("{% url 'admin:grid' %}");
|
||||||
|
};
|
||||||
|
|
||||||
|
function setPreferredSnapshotView(view){
|
||||||
|
urlPath = window.location.pathname;
|
||||||
|
|
||||||
|
if((view==="Grid") && urlPath != "{% url 'admin:grid' %}"){
|
||||||
|
selectSnapshotGridView();
|
||||||
|
}
|
||||||
|
else if((view==="List") && urlPath != "{% url 'admin:core_snapshot_changelist' %}"){
|
||||||
|
selectSnapshotListView();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function setupSnapshotViews() {
|
||||||
|
myStorage = window.localStorage;
|
||||||
|
const preferredSnapshotView = localStorage.getItem('currentSnapshotView');
|
||||||
|
setPreferredSnapshotView(preferredSnapshotView);
|
||||||
|
|
||||||
$( document ).ready(function() {
|
$( document ).ready(function() {
|
||||||
|
|
||||||
$("#snapshotListView").click(function() {
|
$("#snapshotListView").click(function() {
|
||||||
redirectWithQuery("{% url 'admin:core_snapshot_changelist' %}");
|
selectSnapshotListView();
|
||||||
});
|
});
|
||||||
$("#snapshotGridView").click(function() {
|
$("#snapshotGridView").click(function() {
|
||||||
redirectWithQuery("{% url 'admin:grid' %}");
|
selectSnapshotGridView();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
$(function () {
|
$(function () {
|
||||||
fix_actions();
|
fix_actions();
|
||||||
bindSnapshotViewsClick();
|
setupSnapshotViews();
|
||||||
});
|
});
|
||||||
})(django.jQuery);
|
})(django.jQuery);
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue