| <!-- The <text-src> custom element declaration. |
| |
| Displays text loaded from a URL in the same way an image |
| loads and displays from a URL. |
| |
| Attributes: |
| src - The URL to read the text from. |
| |
| Events: |
| None. |
| |
| Methods: |
| None. |
| --> |
| |
| <dom-module id="text-src"> |
| <style> |
| .output { |
| margin: 0; |
| padding: 0; |
| background: white; |
| color: darkgreen; |
| width: 56em; |
| overflow-x: auto; |
| font-family: monospace; |
| font-size: 13px; |
| } |
| </style> |
| <template> |
| <pre class=output>[[ _text ]]</pre> |
| </template> |
| </dom-module> |
| |
| <script> |
| Polymer({ |
| is: "text-src", |
| |
| properties: { |
| src: { |
| type: String, |
| value: "", |
| reflectToAttribute: true, |
| observer: "srcChange", |
| }, |
| _text: { |
| type: String, |
| value: "", |
| } |
| }, |
| |
| srcChange: function() { |
| if (this.src == "") { |
| return |
| } |
| sk.get(this.src).then(function(text) { |
| this._text = text; |
| }.bind(this)).catch(function() { |
| this._text = ""; |
| }.bind(this)); |
| }, |
| |
| }); |
| </script> |