Skip to content

Commit

Permalink
Add sentiment analysis and statistics component and functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Internev committed Jan 19, 2017
2 parents ff632dd + 5e7c313 commit 033152c
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 31 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.LSOverride

node_modules/
database/

logs
*.logs
Expand All @@ -17,3 +18,11 @@ client/dist/

.floo
.flooignore

.idea/*

editor/editor

cert.pem
certMaker
key.pem
Binary file added client/assets/audio/Growth-Mindset-Hypnosis.mp3
Binary file not shown.
8 changes: 1 addition & 7 deletions client/js/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default {
doc: ''
};
docsave.docData.docs = [];
editor.changeQuill('');
editor.quill.deleteText(0);
},

// The object to be passed as a body for authentication requests
Expand All @@ -124,11 +124,6 @@ export default {
return eValidate.validate(email);
},

verifyUsername(un) {
// Must contain at least one symbol
return un.match(/^[A-Za-z0-9]+$/) ? false : true;
},

verifyPassword(pw) {
// Minimum 8 characters at least 1 Alphabet, 1 Number and 1 Special Character:
// FishyTreat1!
Expand All @@ -153,4 +148,3 @@ export default {
return dec;
}
}

2 changes: 1 addition & 1 deletion client/js/docsave.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default {
return obj;
}
})
editor.changeQuill('');
editor.quill.deleteText(0);
})
.catch((err) => {
console.error(err)
Expand Down
12 changes: 7 additions & 5 deletions client/js/editor.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

// import Quill from 'quill'
import {Quill} from '../js/sentiment_blots.js'
import docsave from './docsave.js'
Expand Down Expand Up @@ -75,19 +76,20 @@ module.exports = {
})
},

quillOn(doc, t) {
quillOn(context, doc) {
this.quill.on('text-change', () => {
let text = this.quill.getText()
let stats = this.textStats(text)
context.time = stats.display
context.count = stats.length

docsave.docData.currentDoc.doc = text;
t.time = stats.display
t.count = stats.length
})
},

changeQuill(data) {
data = data || ''; // This allows us to delete the entire thing with an empty string
this.quill.setContents(JSON.parse(data), 'user');
data = JSON.parse(data) || ''; // This allows us to delete the entire thing with an empty string

this.quill.setContents(data, 'user');
}
}
11 changes: 7 additions & 4 deletions client/js/navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ module.exports = {

saveAs(name) {
if (this.docName !== '') {
let stringIt = editor.quill.getContents();
// saveDoc makes the actual call to the database with the data
let prepDoc = {
username: auth.user.data.username,
name: this.docName,
doc: auth.encrypt(JSON.stringify(editor.quill.getContents()))
doc: auth.encrypt(JSON.stringify(stringIt))
}
// fixDups adds a number to the saved doc in order to ensure all docs
// have unique names
Expand All @@ -42,11 +43,13 @@ module.exports = {

save() {
// save updates the form that is currently loaded
let stringIt = editor.quill.getContents();

let assembleData = {
id: docsave.docData.currentDoc.id,
username: auth.user.data.username,
name: docsave.docData.currentDoc.name,
doc: auth.encrypt(JSON.stringify(editor.quill.getContents()))
doc: auth.encrypt(JSON.stringify(stringIt))
}
docsave.updateDoc(this, assembleData);
},
Expand All @@ -56,7 +59,7 @@ module.exports = {
name: '',
doc: ''
};
editor.changeQuill('');
editor.quill.deleteText(0);
},

deleteDoc() {
Expand All @@ -77,4 +80,4 @@ module.exports = {
this.isSignupShowing = false;
this.isLoginShowing = false;
}
}
}
1 change: 1 addition & 0 deletions client/styles/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ body{
background-color: #444;
border-radius: 3px;
color: #fff;

}

/*Sentiment highlights.*/
Expand Down
5 changes: 2 additions & 3 deletions client/vue-components/main_content.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<videocomponent id="video" :wsrtc="wsrtc" :uri="uri"></videocomponent>
</div>

<div class="doc-info" v-if="count > 0">
<div class="doc-info">
<div>{{ count }} words</div>
<div>{{ time }} read</div>
</div>
Expand Down Expand Up @@ -75,11 +75,10 @@
editor.doc = connection.get('docs', this.uri);
// New quill
editor.makeQuill();
editor.quillOn(editor.doc, this);
editor.quillOn(this, editor.doc);
editor.docSubscribe(editor.quill, editor.doc);
this.quill = editor.quill
console.log(this.quill)
},
data() {
return {
Expand Down
2 changes: 1 addition & 1 deletion client/vue-components/navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,4 @@
.saving-as{
width: 100%;
}
</style>
</style>
7 changes: 2 additions & 5 deletions client/vue-components/signin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@
password: this.credentials.password.trim(),
timestamp: Date.now()
};
if (!auth.verifyUsername(credentials.username)) {
this.error = 'Invalid username!';
return;
}
if (!auth.verifyPassword(credentials.password)) {
this.error = 'Invalid password!'
return;
Expand Down Expand Up @@ -84,4 +81,4 @@
background-color: rgb(0, 0, 0);
color: rgb(246, 246, 246);
}
</style>
</style>
7 changes: 2 additions & 5 deletions client/vue-components/signup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@
avatar: this.credentials.avatar,
membersince: Date.now()
};
if (!auth.verifyUsername(credentials.username)) {
this.error = 'Username must contain at least one symbol';
return;
}
if (!auth.verifyEmail(credentials.email)) {
this.error = 'Invalid email';
return
Expand Down Expand Up @@ -85,4 +82,4 @@
background-color: rgb(0, 0, 0);
color: rgb(246, 246, 246);
}
</style>
</style>

0 comments on commit 033152c

Please sign in to comment.