Browse Source

Adds wildcards for chat.

master
Nero Ignis 5 years ago
parent
commit
9c3b9a0a63
  1. 27
      .idea/workspace.xml
  2. 11
      app.js
  3. 3
      index.html

27
.idea/workspace.xml

@ -6,7 +6,6 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="e3f098f0-e98c-435a-af04-d153c9525633" name="Default Changelist" comment=""> <list default="true" id="e3f098f0-e98c-435a-af04-d153c9525633" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app.css" beforeDir="false" afterPath="$PROJECT_DIR$/app.css" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app.js" beforeDir="false" afterPath="$PROJECT_DIR$/app.js" afterDir="false" /> <change beforePath="$PROJECT_DIR$/app.js" beforeDir="false" afterPath="$PROJECT_DIR$/app.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/index.html" beforeDir="false" afterPath="$PROJECT_DIR$/index.html" afterDir="false" /> <change beforePath="$PROJECT_DIR$/index.html" beforeDir="false" afterPath="$PROJECT_DIR$/index.html" afterDir="false" />
</list> </list>
@ -49,7 +48,7 @@
<workItem from="1597348092890" duration="8205000" /> <workItem from="1597348092890" duration="8205000" />
<workItem from="1597530844649" duration="131000" /> <workItem from="1597530844649" duration="131000" />
<workItem from="1597577497243" duration="3353000" /> <workItem from="1597577497243" duration="3353000" />
<workItem from="1597583294362" duration="5755000" /> <workItem from="1597583294362" duration="6287000" />
</task> </task>
<task id="LOCAL-00001" summary="Adds gitignore."> <task id="LOCAL-00001" summary="Adds gitignore.">
<created>1597348071361</created> <created>1597348071361</created>
@ -261,7 +260,14 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1597587291650</updated> <updated>1597587291650</updated>
</task> </task>
<option name="localTasksCounter" value="31" /> <task id="LOCAL-00031" summary="Adds settingsModal;&#10;Adds more saving;&#10;Disables saving welcomeBack messages;">
<created>1597589149291</created>
<option name="number" value="00031" />
<option name="presentableId" value="LOCAL-00031" />
<option name="project" value="LOCAL" />
<updated>1597589149291</updated>
</task>
<option name="localTasksCounter" value="32" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
@ -284,17 +290,18 @@
<MESSAGE value="Kara now saves the chat and her saved answers in localstorage." /> <MESSAGE value="Kara now saves the chat and her saved answers in localstorage." />
<MESSAGE value="Adds method to change saved username." /> <MESSAGE value="Adds method to change saved username." />
<MESSAGE value="Change button symbol." /> <MESSAGE value="Change button symbol." />
<option name="LAST_COMMIT_MESSAGE" value="Change button symbol." /> <MESSAGE value="Adds settingsModal;&#10;Adds more saving;&#10;Disables saving welcomeBack messages;" />
<option name="LAST_COMMIT_MESSAGE" value="Adds settingsModal;&#10;Adds more saving;&#10;Disables saving welcomeBack messages;" />
</component> </component>
<component name="WindowStateProjectService"> <component name="WindowStateProjectService">
<state x="278" y="2" width="800" height="718" key="#Plugins" timestamp="1597350105557"> <state x="278" y="2" width="800" height="718" key="#Plugins" timestamp="1597350105557">
<screen x="0" y="0" width="1366" height="720" /> <screen x="0" y="0" width="1366" height="720" />
</state> </state>
<state x="278" y="2" width="800" height="718" key="#Plugins/0.0.1366.720@0.0.1366.720" timestamp="1597350105557" /> <state x="278" y="2" width="800" height="718" key="#Plugins/0.0.1366.720@0.0.1366.720" timestamp="1597350105557" />
<state x="222" y="0" width="912" height="720" key="CommitChangelistDialog2" timestamp="1597587291601"> <state x="222" y="0" width="912" height="720" key="CommitChangelistDialog2" timestamp="1597589149240">
<screen x="0" y="0" width="1366" height="720" /> <screen x="0" y="0" width="1366" height="720" />
</state> </state>
<state x="222" y="0" width="912" height="720" key="CommitChangelistDialog2/0.0.1366.720@0.0.1366.720" timestamp="1597587291601" /> <state x="222" y="0" width="912" height="720" key="CommitChangelistDialog2/0.0.1366.720@0.0.1366.720" timestamp="1597589149240" />
<state x="466" y="118" width="424" height="490" key="FileChooserDialogImpl" timestamp="1597353496276"> <state x="466" y="118" width="424" height="490" key="FileChooserDialogImpl" timestamp="1597353496276">
<screen x="0" y="0" width="1366" height="720" /> <screen x="0" y="0" width="1366" height="720" />
</state> </state>
@ -311,18 +318,18 @@
<screen x="0" y="0" width="1366" height="720" /> <screen x="0" y="0" width="1366" height="720" />
</state> </state>
<state x="172" y="0" key="SettingsEditor/0.0.1366.720@0.0.1366.720" timestamp="1597530949459" /> <state x="172" y="0" key="SettingsEditor/0.0.1366.720@0.0.1366.720" timestamp="1597530949459" />
<state x="278" y="92" width="800" height="542" key="Vcs.Push.Dialog.v2" timestamp="1597587292665"> <state x="278" y="92" width="800" height="542" key="Vcs.Push.Dialog.v2" timestamp="1597589150364">
<screen x="0" y="0" width="1366" height="720" /> <screen x="0" y="0" width="1366" height="720" />
</state> </state>
<state x="278" y="92" width="800" height="542" key="Vcs.Push.Dialog.v2/0.0.1366.720@0.0.1366.720" timestamp="1597587292665" /> <state x="278" y="92" width="800" height="542" key="Vcs.Push.Dialog.v2/0.0.1366.720@0.0.1366.720" timestamp="1597589150364" />
<state x="0" y="0" width="616" height="720" key="find.popup" timestamp="1597346688624"> <state x="0" y="0" width="616" height="720" key="find.popup" timestamp="1597346688624">
<screen x="0" y="0" width="1366" height="720" /> <screen x="0" y="0" width="1366" height="720" />
</state> </state>
<state x="0" y="0" width="616" height="720" key="find.popup/0.0.1366.720@0.0.1366.720" timestamp="1597346688624" /> <state x="0" y="0" width="616" height="720" key="find.popup/0.0.1366.720@0.0.1366.720" timestamp="1597346688624" />
<state width="533" height="302" key="javadoc.popup.new" timestamp="1597585751908"> <state width="486" height="302" key="javadoc.popup.new" timestamp="1597589385567">
<screen x="0" y="0" width="1366" height="720" /> <screen x="0" y="0" width="1366" height="720" />
</state> </state>
<state width="533" height="302" key="javadoc.popup.new/0.0.1366.720@0.0.1366.720" timestamp="1597585751908" /> <state width="486" height="302" key="javadoc.popup.new/0.0.1366.720@0.0.1366.720" timestamp="1597589385567" />
<state x="347" y="155" key="run.anything.popup" timestamp="1597587322870"> <state x="347" y="155" key="run.anything.popup" timestamp="1597587322870">
<screen x="0" y="0" width="1366" height="720" /> <screen x="0" y="0" width="1366" height="720" />
</state> </state>

11
app.js

@ -144,7 +144,13 @@ let kara = new Vue({
console.log(randomIndex); console.log(randomIndex);
console.log(answers[randomIndex]); console.log(answers[randomIndex]);
return answers[randomIndex]; return this.convertWildcards(answers[randomIndex]);
},
convertWildcards(message) {
message = message.replace('$name$', this.username);
message = message.replace('$botname$', this.name);
return message;
}, },
includesOneOf(phrases, wordsToSearch) { includesOneOf(phrases, wordsToSearch) {
let includes = false; let includes = false;
@ -288,8 +294,9 @@ let kara = new Vue({
}, },
setName(message) { setName(message) {
this.username = message.trim(); this.username = message.trim();
this.updateStorage(); this.settingsModal.username = this.username;
this.askedForName = false; this.askedForName = false;
this.updateStorage();
this.botMessage( this.botMessage(
this.oneOf([ this.oneOf([

3
index.html

@ -84,6 +84,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="responses">Responses</label> <label for="responses">Responses</label>
<small>(Wildcards: $username, $botname)</small>
<template v-for="(key, responseOption) in addModal.responses"> <template v-for="(key, responseOption) in addModal.responses">
<input type="text" v-model="addModal.responses[responseOption]" class="form-control response-input"> <input type="text" v-model="addModal.responses[responseOption]" class="form-control response-input">
</template> </template>
@ -100,7 +101,7 @@
</div> </div>
</div> </div>
<div class="modal fade" id="settingsModal" tabindex="-1" role="dialog" aria-labelledby="addModal" aria-hidden="true"> <div class="modal fade" id="settingsModal" tabindex="-1" role="dialog" aria-labelledby="settingsModal" aria-hidden="true">
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">

Loading…
Cancel
Save