Skip to content

Instantly share code, notes, and snippets.

@WhiteCat6142
Last active July 16, 2023 03:48
Show Gist options
  • Save WhiteCat6142/085b044f19b285fc01b58263836b5e8c to your computer and use it in GitHub Desktop.
Save WhiteCat6142/085b044f19b285fc01b58263836b5e8c to your computer and use it in GitHub Desktop.
Nostr-autoComplete
<!DOCTYPE html>
<html lang="ja">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<title>Nostr補完</title>
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/tarekraafat-autocomplete.js/10.2.7/css/autoComplete.min.css">
</head>
<body>
<h2>Nostr補完</h2>
<input id="autoComplete" value="@">
<ul id="autoComplete_list"></ul>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/tarekraafat-autocomplete.js/10.2.7/autoComplete.min.js"></script>
<script>
var nameList = ["@SnowCait", "@WhiteCat6142"];
var alterLIst = {
"@SnowCait": "npub1s02jksmr6tgmcksf3hnmue7pyzlm0sxwarh7lk8tdeprw2hjg6ysp7fxtw",
"@WhiteCat6142": "npub1dgmvrf3vhgz8k8xmjwl0x9kxv978nqtwx2uqzekyw8pshkmhu5nqxsllwf"
};
var autoCompletejs = new autoComplete({
data: {
src: nameList
},
resultsList: {
render: true
},
query: function (query) {
return query;//can replace
},
highlight: true,
maxResults: 20,
});
document.querySelector("#autoComplete").addEventListener("selection", function (event) {
console.log(event.detail);
document.querySelector("#autoComplete").value = "nostr:" + alterLIst[event.detail.selection.value];
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment