Browse Source

Add lastmessage;

master
stingl 5 years ago
parent
commit
75cea484a9
  1. 24
      .idea/workspace.xml
  2. 12
      app.js
  3. 2
      index.html

24
.idea/workspace.xml

@ -52,7 +52,7 @@ @@ -52,7 +52,7 @@
<workItem from="1597530844649" duration="131000" />
<workItem from="1597577497243" duration="3353000" />
<workItem from="1597583294362" duration="11703000" />
<workItem from="1600432025720" duration="2181000" />
<workItem from="1600432025720" duration="2553000" />
</task>
<task id="LOCAL-00001" summary="Adds gitignore.">
<created>1597348071361</created>
@ -320,7 +320,14 @@ @@ -320,7 +320,14 @@
<option name="project" value="LOCAL" />
<updated>1597611480915</updated>
</task>
<option name="localTasksCounter" value="39" />
<task id="LOCAL-00039" summary="Add notes;">
<created>1600434244194</created>
<option name="number" value="00039" />
<option name="presentableId" value="LOCAL-00039" />
<option name="project" value="LOCAL" />
<updated>1600434244194</updated>
</task>
<option name="localTasksCounter" value="40" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@ -351,17 +358,19 @@ @@ -351,17 +358,19 @@
<MESSAGE value="Adds setting for themes" />
<MESSAGE value="Fix error with new messages." />
<MESSAGE value="Add fix for username detection." />
<option name="LAST_COMMIT_MESSAGE" value="Add fix for username detection." />
<MESSAGE value="Add notes;" />
<option name="LAST_COMMIT_MESSAGE" value="Add notes;" />
</component>
<component name="WindowStateProjectService">
<state x="278" y="2" width="800" height="718" key="#Plugins" timestamp="1597350105557">
<screen x="0" y="0" width="1366" height="720" />
</state>
<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="1597611480863">
<screen x="0" y="0" width="1366" height="720" />
<state x="312" y="0" width="912" height="720" key="CommitChangelistDialog2" timestamp="1600434243677">
<screen x="0" y="0" width="1920" height="1160" />
</state>
<state x="222" y="0" width="912" height="720" key="CommitChangelistDialog2/0.0.1366.720@0.0.1366.720" timestamp="1597611480863" />
<state x="312" y="0" key="CommitChangelistDialog2/0.0.1920.1160/-1920.0.1920.1040@0.0.1920.1160" timestamp="1600434243677" />
<state x="466" y="118" width="424" height="490" key="FileChooserDialogImpl" timestamp="1597353496276">
<screen x="0" y="0" width="1366" height="720" />
</state>
@ -378,10 +387,11 @@ @@ -378,10 +387,11 @@
<screen x="0" y="0" width="1366" height="720" />
</state>
<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="1597611482295">
<screen x="0" y="0" width="1366" height="720" />
<state x="391" y="148" width="800" height="542" key="Vcs.Push.Dialog.v2" timestamp="1600434249548">
<screen x="0" y="0" width="1920" height="1160" />
</state>
<state x="278" y="92" width="800" height="542" key="Vcs.Push.Dialog.v2/0.0.1366.720@0.0.1366.720" timestamp="1597611482295" />
<state x="391" y="148" key="Vcs.Push.Dialog.v2/0.0.1920.1160/-1920.0.1920.1040@0.0.1920.1160" timestamp="1600434249548" />
<state x="0" y="0" width="616" height="720" key="find.popup" timestamp="1597346688624">
<screen x="0" y="0" width="1366" height="720" />
</state>

12
app.js

@ -2,6 +2,7 @@ let kara = new Vue({ @@ -2,6 +2,7 @@ let kara = new Vue({
el: '#kara',
data: {
messages: [],
lastMessage: null,
name: 'Kara',
chatbox: null,
isTyping: false,
@ -83,6 +84,7 @@ let kara = new Vue({ @@ -83,6 +84,7 @@ let kara = new Vue({
},
userMessage(body) {
this.addMessage(body, false);
this.lastMessage = body;
this.updateStorage();
},
@ -124,7 +126,7 @@ let kara = new Vue({ @@ -124,7 +126,7 @@ let kara = new Vue({
setTimeout(() => {
// Check commands
if (this.checkForCommands(message, 'note')) {
if (this.checkForCommands(message, ['note', 'nt'])) {
let noteToSave = this.checkForCommands(message, 'note');
this.saveNote(noteToSave);
} else if (this.checkForCommands(message, 'clear')) {
@ -331,6 +333,7 @@ let kara = new Vue({ @@ -331,6 +333,7 @@ let kara = new Vue({
localStorage.setItem('messages', JSON.stringify(this.messages));
localStorage.setItem('answers', JSON.stringify(this.answers));
localStorage.setItem('notes', JSON.stringify(this.notes));
localStorage.setItem('lastMessage', JSON.stringify(this.lastMessage));
},
getSavedData() {
let savedName = localStorage.getItem('name');
@ -347,10 +350,13 @@ let kara = new Vue({ @@ -347,10 +350,13 @@ let kara = new Vue({
this.messages = savedMessages ? savedMessages : [];
let savedAnswers = JSON.parse(localStorage.getItem('answers'));
this.answers = savedAnswers ? savedAnswers : this.answers;
this.answers = savedAnswers ? savedAnswers : [];
let savedNotes = JSON.parse(localStorage.getItem('notes'));
this.notes = savedNotes ? savedNotes : this.notes;
this.notes = savedNotes ? savedNotes : [];
let savedLastMessage = JSON.parse(localStorage.getItem('lastMessage'));
this.lastMessage = savedLastMessage ? savedLastMessage : null;
this.scrollDown();
},

2
index.html

@ -64,6 +64,8 @@ @@ -64,6 +64,8 @@
type="text"
v-model="chatbox"
v-on:keyup.enter="sendMessage()"
v-on:keyup.38="chatbox = lastMessage"
v-on:keyup.40="chatbox = ''"
required autofocus>
</div>

Loading…
Cancel
Save