| 662 | } |
| 663 | |
| 664 | onSpecFileChange(e) { |
| 665 | this.setAttribute('spec-file', this.shadowRoot.getElementById('spec-file').value); |
| 666 | const specFile = e.target.files[0]; |
| 667 | const reader = new FileReader(); |
| 668 | reader.onload = () => { |
| 669 | try { |
| 670 | const specObj = JSON.parse(reader.result); |
| 671 | this.loadSpec(specObj); |
| 672 | this.shadowRoot.getElementById('spec-url').value = ''; |
| 673 | } catch { |
| 674 | console.error('RapiDoc: Unable to read or parse json'); // eslint-disable-line no-console |
| 675 | } |
| 676 | }; |
| 677 | // Read the Text file |
| 678 | reader.readAsText(specFile); |
| 679 | } |
| 680 | |
| 681 | onFileLoadClick() { |
| 682 | this.shadowRoot.getElementById('spec-file').click(); |