2
0

TwitterWall.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. smalltalk.addPackage('TwitterWall', {});
  2. smalltalk.addClass('Tweet', smalltalk.Widget, ['json'], 'TwitterWall');
  3. smalltalk.addMethod(
  4. unescape('_renderOn_'),
  5. smalltalk.method({
  6. selector: unescape('renderOn%3A'),
  7. category: 'not yet classified',
  8. fn: function (tr) {
  9. var self = this;
  10. var tdUser = nil;
  11. var tdMessage = nil;
  12. var img = nil;
  13. var a = nil;
  14. var pMessage = nil;
  15. var pDate = nil;
  16. tdUser = smalltalk.send(smalltalk.send(smalltalk.HTMLCanvas || HTMLCanvas, "_new", []), "_td", []);
  17. smalltalk.send(smalltalk.send(tdUser, "_element", []), "_id_", ["user"]);
  18. tdMessage = smalltalk.send(smalltalk.send(smalltalk.HTMLCanvas || HTMLCanvas, "_new", []), "_td", []);
  19. smalltalk.send(smalltalk.send(tdMessage, "_element", []), "_id_", ["messageBox"]);
  20. smalltalk.send(tr, "_append_", [tdUser]);
  21. smalltalk.send(tr, "_append_", [tdMessage]);
  22. img = smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.HTMLCanvas || HTMLCanvas, "_new", []), "_img", []), "_src_", [smalltalk.send(self['@json'], "_at_", ["profile_image_url"])]);
  23. smalltalk.send(smalltalk.send(img, "_element", []), "_title_", [smalltalk.send(self['@json'], "_at_", ["from_user"])]);
  24. smalltalk.send(smalltalk.send(img, "_element", []), "_longDesc_", [smalltalk.send(unescape("http%3A//twitter.com/"), "__comma", [smalltalk.send(self['@json'], "_at_", ["from_user"])])]);
  25. a = smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.HTMLCanvas || HTMLCanvas, "_new", []), "_a", []), "_href_", [smalltalk.send(unescape("http%3A//twitter.com/"), "__comma", [smalltalk.send(self['@json'], "_at_", ["from_user"])])]);
  26. smalltalk.send(a, "_append_", [img]);
  27. smalltalk.send(tdUser, "_append_", [a]);
  28. pMessage = smalltalk.send(smalltalk.send(smalltalk.HTMLCanvas || HTMLCanvas, "_new", []), "_p", []);
  29. smalltalk.send(smalltalk.send(pMessage, "_element", []), "_id_", ["message"]);
  30. smalltalk.send(pMessage, "_append_", [smalltalk.send(self['@json'], "_at_", ["text"])]);
  31. smalltalk.send(tdMessage, "_append_", [pMessage]);
  32. pDate = smalltalk.send(smalltalk.send(smalltalk.HTMLCanvas || HTMLCanvas, "_new", []), "_p", []);
  33. smalltalk.send(smalltalk.send(pDate, "_element", []), "_id_", ["date"]);
  34. smalltalk.send(pDate, "_append_", [smalltalk.send(self['@json'], "_at_", ["created_at"])]);
  35. smalltalk.send(tdMessage, "_append_", [pDate]);
  36. return self;
  37. },
  38. args: ["tr"],
  39. source: unescape('renderOn%3A%20tr%0A%0A%7C%20tdUser%20tdMessage%20img%20a%20pMessage%20pDate%20%7C%0AtdUser%20%3A%3D%20HTMLCanvas%20new%20td.%0AtdUser%20element%20id%3A%20%27user%27.%0AtdMessage%20%3A%3D%20HTMLCanvas%20new%20td.%0AtdMessage%20element%20id%3A%20%27messageBox%27.%0A%0Atr%20append%3A%20tdUser.%0Atr%20append%3A%20tdMessage.%0A%0Aimg%20%3A%3D%20HTMLCanvas%20new%20img%20src%3A%20%28json%20at%3A%20%27profile_image_url%27%29%20.%0Aimg%20element%20title%3A%20%28json%20at%3A%20%27from_user%27%29.%0Aimg%20element%20longDesc%3A%20%28%27http%3A//twitter.com/%27%2C%20%28json%20at%3A%20%27from_user%27%29%29.%0A%0Aa%20%3A%3D%20HTMLCanvas%20new%20a%20href%3A%20%28%27http%3A//twitter.com/%27%2C%20%28json%20at%3A%20%27from_user%27%29%29.%0Aa%20append%3A%20img.%0A%0AtdUser%20append%3A%20a.%0A%0ApMessage%20%3A%3D%20HTMLCanvas%20new%20p.%0ApMessage%20element%20id%3A%20%27message%27.%0ApMessage%20append%3A%20%28json%20at%3A%20%27text%27%29.%0AtdMessage%20append%3A%20pMessage.%0A%0ApDate%20%3A%3D%20HTMLCanvas%20new%20p.%0ApDate%20element%20id%3A%20%27date%27.%0ApDate%20append%3A%20%28json%20at%3A%20%27created_at%27%29.%0AtdMessage%20append%3A%20pDate.'),
  40. messageSends: ["td", "new", "id:", "element", "append:", "src:", "img", "at:", "title:", "longDesc:", unescape("%2C"), "href:", "a", "p"],
  41. referencedClasses: ["HTMLCanvas"]
  42. }),
  43. smalltalk.Tweet);
  44. smalltalk.addMethod(
  45. unescape('_json'),
  46. smalltalk.method({
  47. selector: unescape('json'),
  48. category: 'not yet classified',
  49. fn: function () {
  50. var self = this;
  51. return self['@json'];
  52. return self;
  53. },
  54. args: [],
  55. source: unescape('json%0A%5Ejson'),
  56. messageSends: [],
  57. referencedClasses: []
  58. }),
  59. smalltalk.Tweet);
  60. smalltalk.addMethod(
  61. unescape('_json_'),
  62. smalltalk.method({
  63. selector: unescape('json%3A'),
  64. category: 'not yet classified',
  65. fn: function (aJson) {
  66. var self = this;
  67. self['@json'] = aJson;
  68. return self;
  69. },
  70. args: ["aJson"],
  71. source: unescape('json%3A%20aJson%0Ajson%20%3A%3D%20aJson'),
  72. messageSends: [],
  73. referencedClasses: []
  74. }),
  75. smalltalk.Tweet);
  76. smalltalk.addMethod(
  77. unescape('_openAt_with_'),
  78. smalltalk.method({
  79. selector: unescape('openAt%3Awith%3A'),
  80. category: 'not yet classified',
  81. fn: function (tr, aJson) {
  82. var self = this;
  83. var tweet = nil;
  84. tweet = smalltalk.send(self, "_new", []);
  85. smalltalk.send(tweet, "_json_", [aJson]);
  86. smalltalk.send(tweet, "_renderOn_", [tr]);
  87. return tr;
  88. return self;
  89. },
  90. args: ["tr", "aJson"],
  91. source: unescape('openAt%3A%20tr%20with%3A%20aJson%0A%7C%20tweet%20%7C%0Atweet%20%3A%3D%20self%20new.%0Atweet%20json%3A%20aJson.%0Atweet%20renderOn%3A%20tr.%0A%5Etr'),
  92. messageSends: ["new", "json:", "renderOn:"],
  93. referencedClasses: []
  94. }),
  95. smalltalk.Tweet.klass);
  96. smalltalk.addClass('TwitterSearch', smalltalk.Object, ['queryString'], 'TwitterWall');
  97. smalltalk.addMethod(
  98. unescape('_success_'),
  99. smalltalk.method({
  100. selector: unescape('success%3A'),
  101. category: 'not yet classified',
  102. fn: function (tweets) {
  103. var self = this;
  104. var playground = nil;
  105. var table = nil;
  106. var tr = nil;
  107. playground = smalltalk.send(unescape("%23playground"), "_asJQuery", []);
  108. smalltalk.send(playground, "_empty", []);
  109. smalltalk.send(function (html) {table = smalltalk.send(html, "_table", []);smalltalk.send(smalltalk.send(table, "_element", []), "_id_", ["twitterwall"]);return smalltalk.send(tweets, "_do_", [function (tweet) {tr = smalltalk.send(html, "_tr", []);smalltalk.send(table, "_append_", [tr]);return smalltalk.send(smalltalk.Tweet || Tweet, "_openAt_with_", [tr, tweet]);}]);}, "_appendToJQuery_", [playground]);
  110. return self;
  111. },
  112. args: ["tweets"],
  113. source: unescape('success%3A%20tweets%0A%7C%20playground%20table%20tr%20%7C%0Aplayground%20%3A%3D%20%27%23playground%27%20asJQuery.%0Aplayground%20empty.%0A%20%5B%3Ahtml%20%7C%20%0A%09table%20%3A%3D%20html%20table.%0A%09table%20element%20id%3A%20%27twitterwall%27.%0A%0A%09tweets%20do%3A%20%5B%20%3Atweet%20%7C%20%0A%20%20%20%20%20%20%20%20%09%20%20%20tr%20%3A%3D%20html%20tr.%0A%09%20%20%20%20%20%20%20%20%20%20%20table%20append%3A%20tr.%0A%20%20%20%20%20%20%20%20%09%20%20%20Tweet%20openAt%3A%20tr%20with%3A%20tweet%0A%20%20%20%20%20%20%20%20%5D%0A%5D%20appendToJQuery%3A%20playground.'),
  114. messageSends: ["asJQuery", "empty", "appendToJQuery:", "table", "id:", "element", "do:", "tr", "append:", "openAt:with:"],
  115. referencedClasses: ["Tweet"]
  116. }),
  117. smalltalk.TwitterSearch);
  118. smalltalk.addMethod(
  119. unescape('_query'),
  120. smalltalk.method({
  121. selector: unescape('query'),
  122. category: 'not yet classified',
  123. fn: function () {
  124. var self = this;
  125. var result = nil;
  126. var queryString = nil;
  127. self['@queryString'] = smalltalk.send(smalltalk.send(smalltalk.send(unescape("%23searchQuery"), "_asJQuery", []), "_val", []), "_replace_with_", [unescape("%23"), unescape("%2523")]);
  128. result = smalltalk.send(typeof jQuery == "undefined" ? nil : jQuery, "_ajax_options_", [smalltalk.send(unescape("http%3A//search.twitter.com/search.json%3Frpp%3D5%26q%3D"), "__comma", [self['@queryString']]), smalltalk.HashedCollection._fromPairs_([smalltalk.send("type", "__minus_gt", ["GET"]), smalltalk.send("success", "__minus_gt", [function (tmp) {return smalltalk.send(self, "_success_", [smalltalk.send(tmp, "_results", [])]);}]), smalltalk.send("error", "__minus_gt", [function () {return smalltalk.send(typeof window == "undefined" ? nil : window, "_alert_", ["error"]);}]), smalltalk.send("dataType", "__minus_gt", ["jsonp"])])]);
  129. return self;
  130. },
  131. args: [],
  132. source: unescape('query%0A%7C%20result%20queryString%20%7C%0AqueryString%20%3A%3D%20%28%27%23searchQuery%27%20%20asJQuery%20val%29%20replace%3A%20%27%23%27%20with%3A%20%27%2523%27.%0Aresult%20%3A%3D%20jQuery%20%0A%09%09%09ajax%3A%20%27http%3A//search.twitter.com/search.json%3Frpp%3D5%26q%3D%27%2C%20queryString%0A%09%09%09options%3A%20%23%7B%0A%09%09%09%09%27type%27%20-%3E%20%27GET%27.%0A%09%09%09%09%27success%27%20-%3E%20%5B%20%3Atmp%20%7C%20self%20success%3A%20%28tmp%20results%29%5D.%0A%09%09%09%09%27error%27%20-%3E%20%5Bwindow%20alert%3A%20%27error%27%5D.%0A%09%09%09%09%27dataType%27%20-%3E%20%27jsonp%27%0A%09%09%09%7D.'),
  133. messageSends: ["replace:with:", "val", "asJQuery", "ajax:options:", unescape("%2C"), unescape("-%3E"), "success:", "results", "alert:"],
  134. referencedClasses: []
  135. }),
  136. smalltalk.TwitterSearch);