Permalink
Browse files

add negative and positive column

  • Loading branch information...
1 parent ac66d98 commit a043fbc89edc37878f6740c3082e00ec3eaae8e0 Todd Fisher committed Aug 25, 2010
Showing with 39 additions and 7 deletions.
  1. +17 −1 public/css/style.css
  2. +4 −1 public/index.html
  3. +18 −5 public/js/display.js
View
@@ -1,4 +1,20 @@
#tweets ul { list-style:none; }
#tweets li .profile { float:left; position:relative; margin-right:5px; }
#tweets li .profile strong { position:absolute; bottom:-17px; left: 0px;}
-#tweets li { height:80px; width: 800px; clear:both; border-top:1px solid #ccc; padding-top:10px; }
+#tweets li { height:80px; width: 350px; clear:both; border-top:1px solid #ccc; padding-top:10px; }
+
+#tweets {
+ position: relative;
+ width:900px;
+}
+#tweets .positives {
+ float:left;
+ width:400px;
+}
+#tweets .negatives {
+ float:left;
+ width:400px;
+}
+#tweets h2 {
+ text-align:center;
+}
View
@@ -15,7 +15,10 @@
<div id="tweet-face" style="width:320px;height:320px;float:right;"></div>
<div id="tweet-avg"></div>
<div id="mood-graph" style="width:850px;height:250px"></div>
- <div id="tweets"></div>
+ <div id="tweets">
+ <div class="positives"><h2>Positives</h2><div class="target"></div></div>
+ <div class="negatives"><h2>Negatives</h2><div class="target"></div></div>
+ </div>
<script type="text/javascript">
View
@@ -53,28 +53,41 @@ function updateTweets(tracker) {
var ypoints = [lastScore];
var xpoints = [];
+ var positives = [];
+ var negatives = [];
+ var unsure = [];
+
for (var i = 0, len = tweets.length; i < len; ++i) {
var tweet = tweets[i];
if (tweet.score > 0) {
avg += parseFloat(tweet.score);
c++;
- out.push("<li><span class='profile'><strong>" + tweet.score + "</strong>" + twitter_image(tweet) + "</span>" + twitter_profile(tweet) + twitterify(tweet) + "</li>");
+ if (tweet.score >= 5) {
+ positives.push("<li><span class='profile'><strong>" + tweet.score + "</strong>" + twitter_image(tweet) + "</span>" + twitter_profile(tweet) + twitterify(tweet) + "</li>");
+ }
+ else {
+ negatives.push("<li><span class='profile'><strong>" + tweet.score + "</strong>" + twitter_image(tweet) + "</span>" + twitter_profile(tweet) + twitterify(tweet) + "</li>");
+ }
ypoints.push(parseFloat(tweet.score));
xpoints.push(i);
}
else {
- out.push("<li><span class='profile'><strong>n/a</strong>" + twitter_image(tweet) + "</span>" + twitter_profile(tweet) + twitterify(tweet) + "</li>");
+ unsure.push("<li><span class='profile'><strong>n/a</strong>" + twitter_image(tweet) + "</span>" + twitter_profile(tweet) + twitterify(tweet) + "</li>");
}
}
- out = out.reverse().join('');
+ positives = positives.reverse().join('');
+ negatives = negatives.reverse().join('');
+ unsure = unsure.reverse().join('');
+
lastScore = ypoints[ypoints.length-1];
ypoints.push(9);
ypoints.push(1);
avg /= c;
- $("#tweets").html("<ul>" + out + "</ul>");
- $("#tweet-avg").html("Average score: " + avg + ", for '<strong>On tweeter now</strong>'"); //+ search + "</strong>'");
+ $("#tweets .positives .target").html("<ul>" + positives + "</ul>");
+ $("#tweets .negatives .target").html("<ul>" + negatives + "</ul>");
+ $("#tweet-avg").html("Average score: " + avg.toFixed(2) + ", for '<strong>On tweeter now</strong>'"); //+ search + "</strong>'");
paper.clear();
var lines = paper.g.linechart(20, 10, 850, 220, xpoints, ypoints, {axis: "0 0 1 1",symbol: "o", smooth: true, nostroke:false});

0 comments on commit a043fbc

Please sign in to comment.