Last active
July 16, 2023 03:48
-
-
Save WhiteCat6142/085b044f19b285fc01b58263836b5e8c to your computer and use it in GitHub Desktop.
Nostr-autoComplete
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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