# j-FileReader

> j-FileReader - jednoduché použití

Framework: jcomponent20
Product: jComponent 20 (jcomponent@20)
Language: cs
Content-SHA256: 2cfe8e14d333e8a85f5238f7d2604340ab2cee2ea5cbe68d8557ffc05ad5f2b8
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: components@910ed1a86f6e72b4f031d3ad0dc7844f9fc5cb8e
Review: not-recorded

- singleton
- Pouze pro textové soubory

__Metody__:
- `component.open(opt)` - otevřít souborový prohlížeč
	- `opt.multiple {Boolean}` umožňuje více souborů (podle předvolby: `false`)
	- `opt.accept {String}` umožňuje pouze specifikovaný typ obsahu (předvolený: `undefined`)
	- `opt.base64 {Boolean}` čte soubor v kódování Base64 (podle předvolby: `false`)
	- __NEW__: `opt.files {HTTP Files}` čte soubory např. z Drag & Drop
	- `opt.callback {Function(file)}` a callback
	- __NEW__: `opt.progress {Function(percentage, file)}` volitelné

```js
var opt = {};
opt.accept = 'text/*';
// opt.files = e.files;
opt.callback = function(file) {
	console.log(file);
};
SETTER('filereader/open', opt);
```

Použijte ji s `<ui-component name="filereader">`Pokud je součástka ještě nezačleněna, jComponent Stáhnout ji na první použití z adresy `DEF.fallback` a) The Componentator CDN dle předvolby. autor: Peter Širka. zdroj: Componentator Výrobce je autorizován, MIT licence.

```html example.html
<ui-component name="filereader"></ui-component>
<a href="javascript:fopen()">OPEN FILE</a>

<script>
	function fopen() {
		var opt = {};
		opt.accept = 'text/*';
		opt.callback = function(file) {
			$(document.body).append('<div><pre><code>{0}</code></pre></div>'.format(JSON.stringify(file, null, '    ').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;')));
		};
		SETTER('filereader/open', opt);
	}
</script>
```
