Commits

Rune Halvorsen  committed cca362d

Use unbose for creating tweet elements

  • Participants
  • Parent commits 1650393

Comments (0)

Files changed (1)

File geist/templates/index.tpl

 <!doctype html>
-
 <link rel="stylesheet" href="/static/style.css" />
 <script src="/static/unbose.js"></script>
 <script>
     else if (!pending_request) {
         get_tweets();
     }
-
 }
 
 function get_tweets() {
 function rs_handler() {
     conn = this;
     if (conn.readyState == 4) {
-//opera.postError(conn.responseText)
         on_tweets(JSON.parse(conn.responseText), conn);
     }
 }
 function on_tweets(data) {
     pending_request = false;
     pending_tweets = pending_tweets.concat(data.tweets);
-opera.postError(pending_tweets.length)
-    on_timer();
 }
 
 function render_tweet(tweet) {
         ol.removeChild(ol.childNodes[ol.childNodes.length-1]);
     }
 
-    var li = document.createElement("li");
+    var li = $.fromZen("li.tweet>img+span.screen_name+span.text")
+    li.find("img").attr("src", tweet.user.profile_image_url);
+    li.find(".screen_name").text(tweet.user.screen_name + ": ");
+    li.find(".text").text(tweet.text);
 
+    li.style("background-color", tweet.user.profile_background_color);
+    li.style("color", tweet.user.profile_text_color);
 
-    var name = document.createElement("span");
-    name.className = "screen_name";
-    name.textContent = tweet.user.screen_name + " (mood: " + tweet.mood  + "): ";
-
-    var text = document.createElement("span");
-    text.textContent = tweet.text;
-    var img = document.createElement("img");
-    img.src = tweet.user.profile_image_url;
-
-    li.appendChild(img);
-    li.appendChild(name);
-    li.appendChild(text);
-
-    li.style.backgroundColor = tweet.user.profile_background_color;
-    li.style.color = tweet.user.profile_text_color;
-
-    if (ol.firstChild) {
-        ol.insertBefore(li, ol.firstChild);
-    }
-    else {
-        ol.appendChild(li);
-    }
+    $("#tweets").insert(li);
 }
 
 window.onload = on_timer;
 
-
 </script>
 <h1>Tweets</h1>
 <ol id="tweets"></ol>