-
Notifications
You must be signed in to change notification settings - Fork 1
/
sol-catalog-search-bak.js
34 lines (28 loc) · 1.07 KB
/
sol-catalog-search-bak.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import {getDefaults} from './utils/utils.js';
export class SolCatalogSearch extends HTMLElement {
constructor() {
super();
}
async connectedCallback(){
await getDefaults(this);
this.innerHTML = `
<input type="text" />
<button onclick="window.sol.catalogSearch(event)">search</button>
`;
this.querySelector('button').addEventListener('click',(event)=>{runSearch(event,this)});
this.querySelector('input').addEventListener('keypress',(event)=>{checkEnter(event,this)});
}
}
customElements.define("sol-catalog-search",SolCatalogSearch);
function checkEnter(event,element){
if(event.key==="Enter") return runSearch(event,element);
}
function runSearch(event,element){
event.preventDefault();
let source = element.source;
let view = element.view;
const currentLink = event.target;
const display = currentLink.closest('.sol-wrapper').querySelector('.sol-display');
const input = currentLink.parentNode.querySelector('input');
display.innerHTML=`<sol-catalog source="${source}" view="${view}" wanted="${input.value}"></sol-rdf>`;
}