Browse Source

Adds modal to add answers.

master
Nero Ignis 5 years ago
parent
commit
6078c4874e
  1. 24
      .idea/workspace.xml
  2. 6
      app.css
  3. 24
      app.js
  4. 42
      index.html

24
.idea/workspace.xml

@ -6,7 +6,9 @@
<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" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -46,7 +48,7 @@
<workItem from="1597346228730" duration="1851000" /> <workItem from="1597346228730" duration="1851000" />
<workItem from="1597348092890" duration="8205000" /> <workItem from="1597348092890" duration="8205000" />
<workItem from="1597530844649" duration="131000" /> <workItem from="1597530844649" duration="131000" />
<workItem from="1597577497243" duration="1451000" /> <workItem from="1597577497243" duration="3353000" />
</task> </task>
<task id="LOCAL-00001" summary="Adds gitignore."> <task id="LOCAL-00001" summary="Adds gitignore.">
<created>1597348071361</created> <created>1597348071361</created>
@ -230,7 +232,14 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1597577694274</updated> <updated>1597577694274</updated>
</task> </task>
<option name="localTasksCounter" value="27" /> <task id="LOCAL-00027" summary="Move answers to data.">
<created>1597578975715</created>
<option name="number" value="00027" />
<option name="presentableId" value="LOCAL-00027" />
<option name="project" value="LOCAL" />
<updated>1597578975715</updated>
</task>
<option name="localTasksCounter" value="28" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
@ -249,17 +258,18 @@
<MESSAGE value="Test commit." /> <MESSAGE value="Test commit." />
<MESSAGE value="Remove DB method call." /> <MESSAGE value="Remove DB method call." />
<MESSAGE value="Refactor and added todo." /> <MESSAGE value="Refactor and added todo." />
<option name="LAST_COMMIT_MESSAGE" value="Refactor and added todo." /> <MESSAGE value="Move answers to data." />
<option name="LAST_COMMIT_MESSAGE" value="Move answers to data." />
</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="1597577694214"> <state x="222" y="0" width="912" height="720" key="CommitChangelistDialog2" timestamp="1597578975663">
<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="1597577694214" /> <state x="222" y="0" width="912" height="720" key="CommitChangelistDialog2/0.0.1366.720@0.0.1366.720" timestamp="1597578975663" />
<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>
@ -276,10 +286,10 @@
<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="1597577695094"> <state x="278" y="92" width="800" height="542" key="Vcs.Push.Dialog.v2" timestamp="1597578976661">
<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="1597577695094" /> <state x="278" y="92" width="800" height="542" key="Vcs.Push.Dialog.v2/0.0.1366.720@0.0.1366.720" timestamp="1597578976661" />
<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>

6
app.css

@ -55,6 +55,10 @@ body {
background-color: #515960; background-color: #515960;
} }
#kara-banner .btn { #kara-banner .btn, .add-response-input-button {
margin-top: -0.3em; margin-top: -0.3em;
} }
.response-input {
margin-bottom: 3px;
}

24
app.js

@ -8,6 +8,13 @@ let kara = new Vue({
templates: { templates: {
initialGreeting: "Hi! I'm Kara. :)" initialGreeting: "Hi! I'm Kara. :)"
}, },
addModal: {
includeAll: false,
keywords: '',
responses: [
'Answer #1'
]
},
answers: [ answers: [
{ {
includeAll: false, includeAll: false,
@ -116,6 +123,7 @@ let kara = new Vue({
return includesAllPhrases; return includesAllPhrases;
}, },
cleanupMessage(message) { cleanupMessage(message) {
message = message.toLowerCase();
return message.replace('?', '') return message.replace('?', '')
.replace('!', '') .replace('!', '')
.replace('.', '') .replace('.', '')
@ -141,7 +149,6 @@ let kara = new Vue({
.replace('…', ''); .replace('…', '');
}, },
getAnswer(message) { getAnswer(message) {
message = message.toLowerCase();
message = this.cleanupMessage(message); message = this.cleanupMessage(message);
let phrases = message.split(' '); let phrases = message.split(' ');
let answer = undefined; let answer = undefined;
@ -167,6 +174,21 @@ let kara = new Vue({
} }
return 'I don\'t know what to say..'; return 'I don\'t know what to say..';
},
addResponseToInput() {
this.addModal.responses.push('');
},
addNewResponseContainer() {
let includeAll = this.addModal.includeAll;
let keywords = this.cleanupMessage(this.addModal.keywords).split(',');
let responses = this.addModal.responses;
console.log(this.addModal.responses);
this.answers.push({
includeAll: includeAll,
keywords: keywords,
responses: responses
});
} }
} }
}) })

42
index.html

@ -13,6 +13,9 @@
<div class="container-fluid" id="kara"> <div class="container-fluid" id="kara">
<h5 id="kara-banner"> <h5 id="kara-banner">
<div class="float-right"> <div class="float-right">
<div class="btn btn-sm btn-secondary" @click="scrollDown()" data-toggle="modal" data-target="#addModal">
<i>+</i>
</div>
<div class="btn btn-sm btn-secondary" @click="scrollDown()"> <div class="btn btn-sm btn-secondary" @click="scrollDown()">
<i class="fas fa-chevron-down"></i> <i class="fas fa-chevron-down"></i>
</div> </div>
@ -60,8 +63,47 @@
v-on:keyup.enter="sendMessage()" v-on:keyup.enter="sendMessage()"
required autofocus> required autofocus>
</div> </div>
<div class="modal fade" id="addModal" tabindex="-1" role="dialog" aria-labelledby="addModal" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Add</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="form-group">
<label for="includeAll">Message must include all search-terms</label>
<input type="checkbox" id="includeALl" v-model="addModal.includeAll">
</div>
<div class="form-group">
<label for="keywords">Keywords (separated with comma)</label>
<input type="text" id="keywords" v-model="addModal.keywords" class="form-control">
</div>
<div class="form-group">
<label for="responses">Responses</label>
<template v-for="(key, responseOption) in addModal.responses">
<input type="text" v-model="addModal.responses[responseOption]" class="form-control response-input">
</template>
<div class="float-right">
<button class="btn-sm btn-success" @click="addResponseToInput">+</button>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" data-dismiss="modal" @click="addNewResponseContainer">Add</button>
</div>
</div>
</div>
</div>
</div> </div>
<script src="https://kit.fontawesome.com/b54a4cceff.js" crossorigin="anonymous"></script> <script src="https://kit.fontawesome.com/b54a4cceff.js" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<script src="https://code.jquery.com/jquery-3.5.1.js"> <script src="https://code.jquery.com/jquery-3.5.1.js">
</script> </script>

Loading…
Cancel
Save