Skip to content

Commit

Permalink
Add open button to read file
Browse files Browse the repository at this point in the history
  • Loading branch information
matze committed Jun 17, 2024
1 parent f13fcd0 commit 82350d8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Added

- Open button to read local file into input.


## 2.4.3

Expand Down
2 changes: 1 addition & 1 deletion templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</head>
<body>
<header>
<span id="nav-title"><a href="{{ base_path.path() }}"><button>home</button></a></span>
<span id="nav-title"><a href="{{ base_path.path() }}"><button>home</button></a></span>
<nav>
<ul>
{% block nav %}{% endblock %}
Expand Down
17 changes: 17 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@
ev.preventDefault();
}

function openFile() {
let input = document.createElement("input");
input.type = "file";
input.onchange = ev => {
const item = ev.target.files[0];

let textarea = document.getElementById('text');
item.text().then((value) => textarea.value = value);
};

input.click();
}

function filterLangs(ev) {
ev.preventDefault();
let langs = document.getElementById("langs");
Expand All @@ -40,6 +53,10 @@
</script>
{% endblock %}

{% block nav %}
<li><button onclick="openFile()">open</button></li>
{% endblock %}

{%- block content -%}
<form action="{{ base_path.path() }}" method="post">
<div class="container">
Expand Down

0 comments on commit 82350d8

Please sign in to comment.