Tweet.js 5.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. smalltalk.addClass('Tweet', smalltalk.Widget, ['json'], 'Examples');
  2. smalltalk.addMethod(
  3. unescape('_renderOn_'),
  4. smalltalk.method({
  5. selector: unescape('renderOn%3A'),
  6. category: 'not yet classified',
  7. fn: function (tr) {
  8. var self = this;
  9. var tdUser = nil;
  10. var tdMessage = nil;
  11. var img = nil;
  12. var a = nil;
  13. var pMessage = nil;
  14. var pDate = nil;
  15. tdUser = smalltalk.send(smalltalk.send(smalltalk.HTMLCanvas || HTMLCanvas, "_new", []), "_td", []);
  16. smalltalk.send(smalltalk.send(tdUser, "_element", []), "_id_", ["user"]);
  17. tdMessage = smalltalk.send(smalltalk.send(smalltalk.HTMLCanvas || HTMLCanvas, "_new", []), "_td", []);
  18. smalltalk.send(smalltalk.send(tdMessage, "_element", []), "_id_", ["messageBox"]);
  19. smalltalk.send(tr, "_append_", [tdUser]);
  20. smalltalk.send(tr, "_append_", [tdMessage]);
  21. img = smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.HTMLCanvas || HTMLCanvas, "_new", []), "_img", []), "_src_", [smalltalk.send(self['@json'], "_at_", ["profile_image_url"])]);
  22. smalltalk.send(smalltalk.send(img, "_element", []), "_title_", [smalltalk.send(self['@json'], "_at_", ["from_user"])]);
  23. smalltalk.send(smalltalk.send(img, "_element", []), "_longDesc_", [smalltalk.send(unescape("http%3A//twitter.com/"), "__comma", [smalltalk.send(self['@json'], "_at_", ["from_user"])])]);
  24. 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"])])]);
  25. smalltalk.send(a, "_append_", [img]);
  26. smalltalk.send(tdUser, "_append_", [a]);
  27. pMessage = smalltalk.send(smalltalk.send(smalltalk.HTMLCanvas || HTMLCanvas, "_new", []), "_p", []);
  28. smalltalk.send(smalltalk.send(pMessage, "_element", []), "_id_", ["message"]);
  29. smalltalk.send(pMessage, "_append_", [smalltalk.send(self['@json'], "_at_", ["text"])]);
  30. smalltalk.send(tdMessage, "_append_", [pMessage]);
  31. pDate = smalltalk.send(smalltalk.send(smalltalk.HTMLCanvas || HTMLCanvas, "_new", []), "_p", []);
  32. smalltalk.send(smalltalk.send(pDate, "_element", []), "_id_", ["date"]);
  33. smalltalk.send(pDate, "_append_", [smalltalk.send(self['@json'], "_at_", ["created_at"])]);
  34. smalltalk.send(tdMessage, "_append_", [pDate]);
  35. return self;
  36. },
  37. args: ["tr"],
  38. 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.'),
  39. messageSends: ["td", "new", "id:", "element", "append:", "src:", "img", "at:", "title:", "longDesc:", unescape("%2C"), "href:", "a", "p"],
  40. referencedClasses: [smalltalk.HTMLCanvas]
  41. }),
  42. smalltalk.Tweet);
  43. smalltalk.addMethod(
  44. unescape('_json'),
  45. smalltalk.method({
  46. selector: unescape('json'),
  47. category: 'not yet classified',
  48. fn: function () {
  49. var self = this;
  50. return self['@json'];
  51. return self;
  52. },
  53. args: [],
  54. source: unescape('json%0A%5Ejson'),
  55. messageSends: [],
  56. referencedClasses: []
  57. }),
  58. smalltalk.Tweet);
  59. smalltalk.addMethod(
  60. unescape('_json_'),
  61. smalltalk.method({
  62. selector: unescape('json%3A'),
  63. category: 'not yet classified',
  64. fn: function (aJson) {
  65. var self = this;
  66. self['@json'] = aJson;
  67. return self;
  68. },
  69. args: ["aJson"],
  70. source: unescape('json%3A%20aJson%0Ajson%20%3A%3D%20aJson'),
  71. messageSends: [],
  72. referencedClasses: []
  73. }),
  74. smalltalk.Tweet);
  75. smalltalk.addMethod(
  76. unescape('_openAt_with_'),
  77. smalltalk.method({
  78. selector: unescape('openAt%3Awith%3A'),
  79. category: 'not yet classified',
  80. fn: function (tr, aJson) {
  81. var self = this;
  82. var tweet = nil;
  83. tweet = smalltalk.send(self, "_new", []);
  84. smalltalk.send(tweet, "_json_", [aJson]);
  85. smalltalk.send(tweet, "_renderOn_", [tr]);
  86. return tr;
  87. return self;
  88. },
  89. args: ["tr", "aJson"],
  90. 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'),
  91. messageSends: ["new", "json:", "renderOn:"],
  92. referencedClasses: []
  93. }),
  94. smalltalk.Tweet.klass);