9/7 11:14:09p Node 1 !javascript c:\sbbs\xtrn\solar\alco-solar.js line 275:ã> typeError: sfi.trim is not a functionãã> So, my first question is, is the trim() function valid in JavaScript 1.8.5?ã> I'm guessing it is because it's been working inããYes, it's a valid method on a String object.ã ã> What I find interesting is that the error flagged on a trim() on line 275,ã> but was OK with the trim() on line 270: timestamp.trim(). ããIn this case 'timestamp' is really just another String, since you're justãgrabbing the text from the feed and not turning it into a Number or Dateãobject, so that makes sense.ããMy best guess is that the 'solarflux' value was absent when this person fetchedãthe feed, or that they failed to fetch the feed altogether. On line 80, ifã'solardata.solarflux' is undefined, 'sfi' gets set to 0, a Number, which doesãnot have the '.trim()' method. Wrap that 0 in quotes on line 80 and thisãparticular problem should go away.ããAlso, if you wanted to, you could also shorten things a bit by doing somethingãlike:ããvar sfi = solardata.solarflux || '0';ãvar sfi_int = parseInt(sfi);ãvar ai = solardata.aindex || 'No Data';ã// etc.ããThat would be like a shorter version of:ããvar sfi = (typeof solardata.solarflux == 'undefined' ? '0' :ãsolardata.solarflux);ããWhich is a shorter version of:ããvar sfi = solardata.solarflux;ãif (sfi == undefined) {ã var sfi = '0';ã}ãã---ãechicken ãelectronic chicken bbs - bbs.electronicchicken.com - 416-273-7230ã þ Synchronet þ electronic chicken bbs - bbs.electronicchicken.comã
Sysop: | Karloch |
---|---|
Location: | Madrid, Spain |
Users: | 54 |
Nodes: | 8 (0 / 8) |
Uptime: | 129:42:25 |
Calls: | 700 |
Files: | 17,895 |
D/L today: |
128 files (60,769K bytes) |
Messages: | 66,010 |