diff src/sync.coffee @ 4:f352c74a6a5b

remove typeof, corrected facebooks toESN entrys
author Mathias Gebbe <mgebbe@intevation.de>
date Fri, 06 Jun 2014 10:18:14 +0200
parents 98a070c98982
children af9f5b94c019
line wrap: on
line diff
--- a/src/sync.coffee	Thu Jun 05 18:02:25 2014 +0200
+++ b/src/sync.coffee	Fri Jun 06 10:18:14 2014 +0200
@@ -86,22 +86,21 @@
 
     if post.type is 'photo'
       parsed = "<img src='" + profilePicLink + "'></img> <a href='" + user.profileLink + "'>" + user.displayName + "</a> <a href='"+ post.link + "'> schreibt</a> via " + network + " am " + post.updated_time + ":<br>"
-      parsed += "<br>" + post.message if typeof post.message isnt "undefined"
+      parsed += "<br>" + post.message if post.message? and post.message isnt ""
       parsed += "<br><img src='" + post.picture + "'></img>"
 
     if post.type is 'link' or post.type is 'video'
       parsed = "<img src='" + profilePicLink + "'></img> <a href='" + user.profileLink + "'>" + user.displayName + "</a> <a href='https://www.facebook.com/" + post.id + "'> schreibt</a> via " + network + " am " + post.updated_time + ":<br>"
-      parsed += "<br>" + post.message if typeof post.message isnt "undefined"
-      parsed += "<br>" + post.description if typeof post.description isnt "undefined"
-      parsed +=  "<br><a href='" + post.link + "'>"+ post.link + "</a>" if typeof post.link isnt "undefined"
-      parsed += "<br><img src='" + post.picture + "'></img>" if typeof post.picture isnt "undefined"
-
+      parsed += "<br>" + post.message if post.message? and post.message isnt ""
+      parsed += "<br>" + post.description if post.description?
+      parsed +=  "<br><a href='" + post.link + "'>"+ post.link + "</a>" if post.link?
+      parsed += "<br><img src='" + post.picture + "'></img>" if post.picture?
 
     callback null, parsed
 
   if network is 'google'
     parsed = "<img src='" + post.actor.image.url + "'></img> <a href='" + post.actor.url + "'>" + post.actor.displayName + "</a> <a href='"+ post.object.url + "'> schreibt</a> via " + network + " am " + post.updated + ":<br><br>" + post.object.content
-    if typeof post.object.attachments isnt "undefined"
+    if not post.object.attachments?
       _.each post.object.attachments, (attachment) ->
 
         if attachment.objectType == "photo"
@@ -109,12 +108,12 @@
 
         if attachment.objectType == "article"
           parsed +=  "<br><a href='" + attachment.url + "'>"+ attachment.displayName + "</a>"
-          if typeof attachment.image isnt "undefined"
+          if not attachment.image?
             parsed += "<br><img src='" + attachment.image.url + "'></img>"
 
         if attachment.objectType == "video"
           parsed +=  "<br><a href='" + attachment.url + "'>"+ attachment.displayName + "</a>"
-          if typeof attachment.image isnt "undefined"
+          if not attachment.image?
             parsed += "<br><img src='" + attachment.image.url + "'></img>"
 
     callback null, parsed
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)