Update.
This commit is contained in:
parent
2df92e809e
commit
1762191b03
src/snek
@ -4,7 +4,12 @@ class ChatInputComponent extends HTMLElement {
|
||||
autoCompletions = {
|
||||
"example 1": () => {},
|
||||
"example 2": () => {},
|
||||
};
|
||||
}
|
||||
hiddenCompletions = {
|
||||
"/starsRender": () => {
|
||||
app.rpc.starsRender(this.channelUid,this.value.replace("/starsRender ",""))
|
||||
}
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
@ -25,12 +30,15 @@ class ChatInputComponent extends HTMLElement {
|
||||
this._value = value || "";
|
||||
this.textarea.value = this._value;
|
||||
}
|
||||
|
||||
get allAutoCompletions() {
|
||||
return Object.assign({},this.autoCompletions,this.hiddenCompletions)
|
||||
}
|
||||
resolveAutoComplete() {
|
||||
let count = 0;
|
||||
let value = null;
|
||||
Object.keys(this.autoCompletions).forEach((key) => {
|
||||
if (key.startsWith(this.value)) {
|
||||
|
||||
Object.keys(this.allAutoCompletions).forEach((key) => {
|
||||
if (key.startsWith(this.value.split(" ")[0])) {
|
||||
count++;
|
||||
value = key;
|
||||
}
|
||||
@ -188,9 +196,10 @@ levenshteinDistance(a, b) {
|
||||
|
||||
this.textarea.addEventListener("keydown", (e) => {
|
||||
this.value = e.target.value;
|
||||
let autoCompletion = null;
|
||||
if (e.key === "Tab") {
|
||||
e.preventDefault();
|
||||
let autoCompletion = this.resolveAutoComplete();
|
||||
autoCompletion = this.resolveAutoComplete();
|
||||
if (autoCompletion) {
|
||||
e.target.value = autoCompletion;
|
||||
this.value = autoCompletion;
|
||||
@ -206,13 +215,13 @@ levenshteinDistance(a, b) {
|
||||
if (!message) {
|
||||
return;
|
||||
}
|
||||
|
||||
let autoCompletion = this.autoCompletions[message];
|
||||
if (autoCompletion) {
|
||||
this.value = "";
|
||||
let autoCompletionHandler = this.allAutoCompletions[this.value.split(" ")[0]];
|
||||
if (autoCompletionHandler) {
|
||||
autoCompletionHandler();
|
||||
this.value = "";
|
||||
this.previousValue = "";
|
||||
e.target.value = "";
|
||||
autoCompletion();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -157,6 +157,10 @@ app.ws.addEventListener("refresh", (data) => {
|
||||
app.starField.showNotify(data.message);
|
||||
setTimeout(() => window.location.reload(), 4000);
|
||||
});
|
||||
app.ws.addEventListener("stars_render", (data)=>{
|
||||
app.starField.renderWord(data.message, { rainbow: true, resolution: 8 });
|
||||
setTimeout(() => app.starField.shuffleAll(5000), 10000);
|
||||
})
|
||||
app.ws.addEventListener("deployed", (data) => {
|
||||
app.starField.renderWord("Deployed", { rainbow: true, resolution: 8 });
|
||||
setTimeout(() => app.starField.shuffleAll(5000), 10000);
|
||||
|
@ -380,7 +380,13 @@ class RPCView(BaseView):
|
||||
return {"pong": args}
|
||||
|
||||
|
||||
|
||||
async def stars_render(self, channel_uid, message):
|
||||
|
||||
for user in await self.get_online_users(channel_uid):
|
||||
try:
|
||||
await self.services.socket.send_to_user(user['uid'], dict(event="stars_render", data={"channel_uid": channel_uid, "message":message}))
|
||||
except Exception as ex:
|
||||
print(ex)
|
||||
|
||||
async def get(self):
|
||||
scheduled = []
|
||||
@ -407,7 +413,7 @@ class RPCView(BaseView):
|
||||
"message": "Finishing deployment"}
|
||||
}
|
||||
)
|
||||
await schedule(self.request.session.get("uid"),10,{"event": "deployed", "data": {
|
||||
await schedule(self.request.session.get("uid"),15,{"event": "deployed", "data": {
|
||||
"uptime": self.request.app.uptime}
|
||||
}
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user