1export default class { 2 /** 3 * 4 * @param {("zone"|"component")} type 5 * @param id 6 */ 7 render(type, id) { 8 // place-holder for partial page rendering 9 // window.location.reload(); 10 // /* the real function needs testing 11 if (!this[type]) { 12 throw "type isn't supported render target" 13 } 14 const headers = new Headers(); 15 const headerKey = 'X-' + type.charAt(0).toUpperCase() + type.slice(1); 16 headers.append(headerKey, id); 17 18 fetch (window.location, { 19 headers: headers 20 }).then(res => { 21 res.text().then( 22 text => { 23 const template = document.createElement('div') 24 template.innerHTML = text; 25 this[type](id, template); 26 } 27 ); 28 }); 29 } 30 31 // noinspection JSUnusedGlobalSymbols called via this.render 32 zone(id, template) { 33 const elm = document.querySelector('[data-zone="' + id + '"]'); 34 if (elm) { 35 elm.innerHTML = ''; 36 elm.append(...template.childNodes); 37 } 38 } 39 40 // noinspection JSUnusedGlobalSymbols called via this.render 41 component(id, template) { 42 const elm = document.querySelector('[data-component="' + id + '"]'); 43 if (elm) { 44 elm.parentNode.insertBefore(template.firstElementChild, elm); 45 elm.remove(); 46 } 47 } 48}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.