HypeM.js
Go to the documentation of this file.
1 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
2 Components.utils.import("resource://app/jsmodules/sbLibraryUtils.jsm");
3 Components.utils.import("resource://app/jsmodules/sbProperties.jsm");
4 
5 const Cc = Components.classes;
6 const Ci = Components.interfaces;
7 const Cr = Components.results;
8 
9 const DESCRIPTION = "mashTape Provider: Hype Machine Provider";
10 const CID = "{ad43af30-7a1c-11dd-ad8b-0800200c9a66}";
11 const CONTRACTID = "@songbirdnest.com/mashTape/provider/rss/HypeM;1";
12 
13 // XPCOM constructor for our Yahoo News mashTape provider
14 function HypeM() {
15  this.wrappedJSObject = this;
16  Components.utils.import("resource://mashtape/mtUtils.jsm");
17 }
18 
19 HypeM.prototype.constructor = HypeM;
20 HypeM.prototype = {
22  classID: Components.ID(CID),
24  QueryInterface: XPCOMUtils.generateQI([Ci.sbIMashTapeRSSProvider,
25  Ci.sbIMashTapeProvider]),
26 
27  providerName: "Hype Machine",
28  providerUrl: "http://hypem.com",
29  providerType: "rss",
30  providerIcon: "chrome://mashtape/content/tabs/hypem.png",
31 
32  query: function(searchTerms, updateFn) {
33  var req = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]
34  .createInstance(Ci.nsIXMLHttpRequest);
35  var url = "http://hypem.com/feed/search/" + searchTerms + "/1/feed.xml";
36  mtUtils.log("HypeM", "URL:" + url);
37  req.open("GET", url, true);
38  req.provider = this;
39  req.updateFn = updateFn;
40  req.onreadystatechange = function() {
41  if (this.readyState != 4)
42  return;
43  if (this.status == 200) {
44  var x = new XML(this.responseText.replace(
45  /<\?xml version="1.0" encoding="[uU][tT][fF]-8"\?>/, ""));
46 
47  var results = new Array();
48  for each (var entry in x..item) {
49  var item = {
50  title: entry.title,
51  time: Date.parse(entry.pubDate),
52  provider: this.provider.providerName,
53  providerUrl: this.provider.providerUrl,
54  url: entry.link,
55  content: entry.description,
56  }
57  results.push(item);
58  }
59 
60  results.wrappedJSObject = results;
61  this.updateFn.wrappedJSObject.update(CONTRACTID, results);
62  } else if (this.status == 404) {
63  this.updateFn.wrappedJSObject.update(CONTRACTID, null);
64  }
65  }
66  req.send(null);
67  },
68 }
69 
70 var components = [HypeM];
71 function NSGetModule(compMgr, fileSpec) {
72  return XPCOMUtils.generateModule([HypeM]);
73 }
74 
classDescription entry
Definition: FeedWriter.js:1427
sbDeviceFirmwareAutoCheckForUpdate prototype contractID
sbOSDControlService prototype QueryInterface
sbDeviceFirmwareAutoCheckForUpdate prototype classDescription
version(170)
const Cr
Definition: HypeM.js:7
const CID
Definition: HypeM.js:10
function HypeM()
Definition: HypeM.js:14
const Ci
Definition: HypeM.js:6
const Cc
Definition: HypeM.js:5
return null
Definition: FeedWriter.js:1143
function url(spec)
function NSGetModule(compMgr, fileSpec)
Definition: HypeM.js:71
sbDeviceFirmwareAutoCheckForUpdate prototype classID
const DESCRIPTION
Definition: HypeM.js:9
const CONTRACTID
Definition: HypeM.js:11