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