mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-30 10:53:02 +01:00
Image reader, placeholder
This commit is contained in:
parent
baee52648d
commit
3edecf91f2
1 changed files with 26 additions and 3 deletions
|
@ -11,16 +11,39 @@
|
||||||
<label>Input Filter</label>
|
<label>Input Filter</label>
|
||||||
<input type="text" id="org-files" name="org-files" placeholder="null">
|
<input type="text" id="org-files" name="org-files" placeholder="null">
|
||||||
</form>
|
</form>
|
||||||
|
<output id="list"></output>
|
||||||
</body>
|
</body>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-yaml/4.1.0/js-yaml.min.js"> </script>
|
||||||
<script>
|
<script>
|
||||||
var filePicker = document.getElementById("filepicker");
|
var filePicker = document.getElementById("filepicker");
|
||||||
filePicker.addEventListener("change", () => {
|
filePicker.addEventListener("change", () => {
|
||||||
console.log(filePicker);
|
console.log(filePicker);
|
||||||
for (const file of filePicker.files) {
|
for (const file of filePicker.files) {
|
||||||
let url = URL.createObjectURL(file);
|
|
||||||
console.log(url);
|
if(!file.type.includes("yaml")) {
|
||||||
if (file.name) {
|
|
||||||
console.log(file);
|
console.log(file);
|
||||||
|
let url = URL.createObjectURL(file);
|
||||||
|
|
||||||
|
const reader = new FileReader();
|
||||||
|
|
||||||
|
// Closure to capture the file information.
|
||||||
|
reader.onload = (function(theFile) {
|
||||||
|
return function(e) {
|
||||||
|
// Render thumbnail.
|
||||||
|
var span = document.createElement('span');
|
||||||
|
span.innerHTML = ['<img class="thumb" src="', e.target.result,
|
||||||
|
'" title="', escape(theFile.name), '"/>'].join('');
|
||||||
|
document.getElementById('list').insertBefore(span, null);
|
||||||
|
};
|
||||||
|
})(file);
|
||||||
|
|
||||||
|
// Read in the image file as a data URL.
|
||||||
|
reader.readAsDataURL(file);
|
||||||
|
|
||||||
|
window.jsyaml.loadAll(url, function(doc) {
|
||||||
|
reader.readAsDataURL(url);
|
||||||
|
console.log(doc);
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue