├── LICENSE ├── README.md └── src ├── kite.js ├── kite.min.js ├── msg.html └── test.html /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Danilo Lekovic 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
3 |
4 |
Hello world!
27 | ``` 28 | 29 | ### Get It Now 30 | 31 | Simply add this tag to the bottom of your HTML file. 32 | 33 | ```js 34 | 35 | ``` 36 | 37 | ### To-Do 38 | 39 | [x] Multiple files in one tag 40 | 41 | ### License 42 | 43 | This project is licensed under the permissive [MIT license](https://raw.githubusercontent.com/danilolekovic/kite/master/LICENSE). 44 | -------------------------------------------------------------------------------- /src/kite.js: -------------------------------------------------------------------------------- 1 | var elements = document.getElementsByTagName("kite"); 2 | 3 | function httpGet(address) { 4 | var xhr = new XMLHttpRequest(); 5 | xhr.open('GET', address, false); 6 | xhr.send(null); 7 | 8 | if (xhr.status === 200) { 9 | return xhr.responseText; 10 | } else { 11 | throw "kite: Could not fetch file: " + address; 12 | } 13 | } 14 | 15 | for (var i = 0; i < elements.length; i++) { 16 | var src = ""; 17 | 18 | if (elements[i].hasAttribute("src")) { 19 | if (elements[i].getAttribute("src").indexof(",") > -1) { 20 | files = elements[i].getAttribute("src").split(','); 21 | 22 | for (f in files) { 23 | str += httpGet(f); 24 | } 25 | } else { 26 | src += httpGet(elements[i].getAttribute("src")); 27 | } 28 | 29 | var htmlNode = document.createElement('span'); 30 | htmlNode.innerHTML = src; 31 | elements[i].parentNode.replaceChild(htmlNode, elements[i]); 32 | } else { 33 | throw "kite: " + elements[i] + " has no src location."; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/kite.min.js: -------------------------------------------------------------------------------- 1 | function httpGet(e){var t=new XMLHttpRequest;if(t.open("GET",e,!1),t.send(null),200===t.status)return t.responseText;throw"kite: Could not fetch file: "+e}for(var elements=document.getElementsByTagName("kite"),i=0;iTest
8 |