Skip to content

Commit

Permalink
chore: draft: mostly done vanilla with options, cache and querying
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-lebleu committed Feb 28, 2024
1 parent fdacb47 commit f046f81
Show file tree
Hide file tree
Showing 5 changed files with 394 additions and 220 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ tests/report
src/vendors/*

# Do not push dist
dist/
dist/

api/
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"js": "webpack",
"cypress:open": "cypress open",
"cypress:run": "cypress run --browser chrome ./cypress",
"start": "webpack serve"
"start": "webpack serve --hot"
},
"repository": {
"type": "git",
Expand Down
45 changes: 35 additions & 10 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
</div>

<script type="text/javascript">
<!-- TODO Keep data- attributes, and let ability to choose that or options object. If data-, support all attributes -->
function ready(fn) {
if (document.readyState !== 'loading') {
fn();
Expand All @@ -50,24 +49,50 @@
document.addEventListener('DOMContentLoaded', fn);
};
ready(() => {
kompleter.init({
id: 'auto-complete',
dataSource: 'files/kompleter.json',
store: {
type: 'localStorage',
duration: 5000
const input = document.getElementById('auto-complete');
console.log(input);

const dataSource = {
url: 'http://localhost:3000/api',
queryString: {
keys: {
term: 'q',
limit: 'limit',
offset: 'offset',
perPage: 'perPage',
},
values: {
limit: 100,
offset: 0,
perPage: 10,
}
},
filterOn: 'Name',
fieldsToDisplay: [
'Name',
'CountryCode',
'Population'
],
propertyToValue: null,
};

const options = {
animation: {
type: 'fadeIn',
duration: 500
}
});
},
cache: 5000
};


// Way 1
input.kompleter(dataSource, options, { onKeyup: (value) => { console.log('cb.onKeyup ', value); }, onSelect: (value) => { console.log('cb.onSelect', value); }, onError: (value) => { console.log('cb.onError ', value); } })

// Way 2
// kompleter(input, options);

// Way 3
// kompleter('auto-complete', options);

});
</script>

Expand Down
Loading

0 comments on commit f046f81

Please sign in to comment.