Permalink
Browse files

Fix on the algorithm

  • Loading branch information...
1 parent de72e8b commit d9eeca452527607f686e903f5c061b80669e2062 Penn Su committed Jul 9, 2014
@@ -1,5 +1,5 @@
#Last build type
-#Tue, 08 Jul 2014 22:12:58 -0700
+#Tue, 08 Jul 2014 22:34:12 -0700
build.last.target=debug
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,5 @@
#Last build type
-#Tue, 08 Jul 2014 22:13:05 -0700
+#Tue, 08 Jul 2014 22:34:19 -0700
build.last.target=debug
@@ -7,6 +7,7 @@ input.MessageBox {
.wide-as-needed {
overflow: scroll;
white-space: nowrap;
+ padding-bottom: 10px;
}
.chat-as-needed {
overflow-y: scroll;
@@ -140,6 +141,10 @@ ion-scroll.Mainmessages.scroll-view.ionic-scroll {
margin-top: 30px;
}
+::-webkit-scrollbar {
+ display: none;
+}
+
/* chat CSS*/
body { padding-top:30px; }
.widget .panel-body { padding:0px; }
@@ -264,10 +269,9 @@ ul li { padding-left: 0px; }
span.personTimestamp {
float: right;
- font-size: 7px;
+ font-size: 5px;
position: relative;
- bottom: -14px;
- right: -13px;
+ bottom: -13px;
color: rgb(204, 53, 53);
}
@@ -297,7 +301,6 @@ a.avatar { color: transparent; } /* IE fix: removes blue border */
div.mainPerson {
text-align: center;
width: 100px;
- vertical-align: middle;
display: inline-block;
background:url(http://www.american.edu/uploads/profiles/large/chris_palmer_profile_11.jpg) no-repeat;
height:100px;
@@ -1,7 +1,23 @@
angular.module('starter.services', [])
-.factory("Dictionary", function ($http) {
- return $http.get('https://spreadsheets.google.com/feeds/list/1PkvNQsLl6s5L8JUA_mbbv1nAwDtYVPxCVIqZYunUErw/od6/public/values?alt=json');
+.factory("Dictionary", function ($q, $http) {
+ var defer = $q.defer();
+ $http.get('https://spreadsheets.google.com/feeds/list/1PkvNQsLl6s5L8JUA_mbbv1nAwDtYVPxCVIqZYunUErw/od6/public/values?alt=json').success(function (data) {
+ var dict = {};
+ data.feed.entry.forEach(function (entry) {
+ var spicewordKeys = Object.keys(entry).filter(function (key) {
+ return key.indexOf('spiceword') > -1;
+ });
+
+ dict[entry['gsx$original']['$t']] = spicewordKeys.map(function (key) {
+ return entry[key]['$t'];
+ }).filter(function (value) {
+ return value.length > 0;
+ });
+ });
+ defer.resolve(dict);
+ });
+ return defer.promise;
})
.factory("Spicer", function ($firebase, Dictionary, $http) {
@@ -10,29 +26,20 @@ angular.module('starter.services', [])
var probWS = 0.5;
- probObjs.$on('value', function (wrapper) {
+ probObjs.$on('child_changed', function (wrapper) {
probWS = parseInt(wrapper.snapshot.value['probWS']);
});
var dict = {};
- Dictionary.success(function (data) {
- data.feed.entry.forEach(function (entry) {
- var spicewordKeys = Object.keys(entry).filter(function (key) {
- return key.indexOf('spiceword') > -1;
- });
-
- dict[entry['gsx$original']['$t']] = spicewordKeys.map(function (key) {
- return entry[key]['$t'];
- }).filter(function (value) {
- return value.length > 0;
- });
- });
+ Dictionary.then(function (data) {
+ dict = data;
});
return function (message) {
var words = message.split(' ');
var spiceWords = words.map(function (word) {
- if (Math.random() >= probWS && dict[word]) {
+ //if (Math.random() > (1.0-probWS) && dict[word]) {
+ if (dict[word]) {
return dict[word][Math.floor(Math.random() * (dict[word].length-1))]
} else {
return word;
@@ -11,6 +11,7 @@
<div ng-class="{bubble: message.created_by == userId, bubble2: message.created_by != userId}">
<br>
<span class="personSay">{{message.content}}</span>
+ <span class="personSay">{{message.spiced_content}}</span>
<span class="personTimestamp">{{message.created_at | timestamp}}</span>
</div>
</li>
View
@@ -26,8 +26,16 @@ angular.module('starter.services', [])
var probWS = 0.5;
+ probObjs.$on('value', function (wrapper) {
+ probWS = parseInt(wrapper.snapshot.value['probWS']);
+ console.log('new probWS');
+ console.log(probWS);
+ });
+
probObjs.$on('child_changed', function (wrapper) {
probWS = parseInt(wrapper.snapshot.value['probWS']);
+ console.log('new probWS');
+ console.log(probWS);
});
var dict = {};
@@ -38,7 +46,8 @@ angular.module('starter.services', [])
return function (message) {
var words = message.split(' ');
var spiceWords = words.map(function (word) {
- if (Math.random() > (1.0-probWS) && dict[word]) {
+ //if (dict[word]) {
+ if (Math.floor(Math.random() * 10) <= Math.floor(probWS * 10) && dict[word]) {
return dict[word][Math.floor(Math.random() * (dict[word].length-1))]
} else {
return word;
@@ -11,6 +11,7 @@
<div ng-class="{bubble: message.created_by == userId, bubble2: message.created_by != userId}">
<br>
<span class="personSay">{{message.content}}</span>
+ <span class="personSay" style="color: red;">{{message.spiced_content}}</span>
<span class="personTimestamp">{{message.created_at | timestamp}}</span>
</div>
</li>

0 comments on commit d9eeca4

Please sign in to comment.