1
0

TwitterSearch.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. smalltalk.addClass('TwitterSearch', smalltalk.Object, [], 'Examples');
  2. smalltalk.addMethod(
  3. unescape('_query_'),
  4. smalltalk.method({
  5. selector: unescape('query%3A'),
  6. category: 'not yet classified',
  7. fn: function (aQueryString) {
  8. var self = this;
  9. var result = nil;
  10. 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", [aQueryString]), smalltalk.Dictionary._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"])])]);
  11. return self;
  12. },
  13. args: ["aQueryString"],
  14. source: unescape('query%3A%20aQueryString%0A%7C%20result%20%7C%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%20aQueryString%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.%20%20'),
  15. messageSends: ["ajax:options:", unescape("%2C"), unescape("-%3E"), "success:", "results", "alert:"],
  16. referencedClasses: []
  17. }),
  18. smalltalk.TwitterSearch);
  19. smalltalk.addMethod(
  20. unescape('_success_'),
  21. smalltalk.method({
  22. selector: unescape('success%3A'),
  23. category: 'not yet classified',
  24. fn: function (tweets) {
  25. var self = this;
  26. var wall = nil;
  27. var table = nil;
  28. var tr = nil;
  29. wall = unescape("%23playground");
  30. table = smalltalk.send(smalltalk.send(smalltalk.HTMLCanvas || HTMLCanvas, "_onJQuery_", [smalltalk.send(wall, "_asJQuery", [])]), "_table", []);
  31. smalltalk.send(smalltalk.send(table, "_element", []), "_id_", ["twitterwall"]);
  32. smalltalk.send(tweets, "_do_", [function (tweet) {tr = smalltalk.send(smalltalk.send(smalltalk.HTMLCanvas || HTMLCanvas, "_new", []), "_tr", []);smalltalk.send(table, "_append_", [tr]);return smalltalk.send(smalltalk.Tweet || Tweet, "_openAt_with_", [tr, tweet]);}]);
  33. return self;
  34. },
  35. args: ["tweets"],
  36. source: unescape('success%3A%20tweets%0A%7C%20wall%20table%20tr%20%7C%0Awall%20%3A%3D%20%27%23playground%27.%0Atable%20%3A%3D%20%28HTMLCanvas%20onJQuery%3A%20%28wall%20asJQuery%29%29%20%20table.%0Atable%20element%20id%3A%20%27twitterwall%27.%0A%0Atweets%20do%3A%20%5B%20%3Atweet%20%7C%20%0A%20%20%20%20%20%20%20%20%20%20%20tr%20%3A%3D%20HTMLCanvas%20new%20tr.%0A%20%20%20%20%20%20%20%20%20%20%20table%20append%3A%20tr.%0A%20%20%20%20%20%20%20%20%20%20%20Tweet%20openAt%3A%20tr%20with%3A%20tweet%0A%20%20%20%20%20%20%20%20%20%20%20%5D.'),
  37. messageSends: ["table", "onJQuery:", "asJQuery", "id:", "element", "do:", "tr", "new", "append:", "openAt:with:"],
  38. referencedClasses: [smalltalk.HTMLCanvas,smalltalk.nil]
  39. }),
  40. smalltalk.TwitterSearch);