2
0

TwitterSearch.deploy.js 1.7 KB

1234567891011121314151617181920212223242526272829303132
  1. smalltalk.addClass('TwitterSearch', smalltalk.Object, [], 'Examples');
  2. smalltalk.addMethod(
  3. '_query_',
  4. smalltalk.method({
  5. selector: 'query:',
  6. fn: function (aQueryString) {
  7. var self = this;
  8. var result = nil;
  9. 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"])])]);
  10. return self;
  11. }
  12. }),
  13. smalltalk.TwitterSearch);
  14. smalltalk.addMethod(
  15. '_success_',
  16. smalltalk.method({
  17. selector: 'success:',
  18. fn: function (tweets) {
  19. var self = this;
  20. var wall = nil;
  21. var table = nil;
  22. var tr = nil;
  23. wall = unescape("%23playground");
  24. table = smalltalk.send(smalltalk.send(smalltalk.HTMLCanvas || HTMLCanvas, "_onJQuery_", [smalltalk.send(wall, "_asJQuery", [])]), "_table", []);
  25. smalltalk.send(smalltalk.send(table, "_element", []), "_id_", ["twitterwall"]);
  26. 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]);}]);
  27. return self;
  28. }
  29. }),
  30. smalltalk.TwitterSearch);