0

Using jQuery and Strophoe JS libraries in a widget

I'm using some 3rd party JavaScript libraries (strophe which seems to depend on jQuery) - I see the following error in the logs
CODE
WE 00:00:02:007: [T:3226] ReferenceError: window is not defined (strophe.js: Line 3539)


That part of the JS file reads something like
CODE
}
...
})(function () {
window.Strophe = arguments[0];
window.$build = arguments[1];
window.$msg = arguments[2];
window.$iq = arguments[3];
window.$pres = arguments[4];
});


There were other references to window but they looked like they were mostly to identify XHR creation and XMLDOM creation depending on the browser (IE specific cases i.e.) and I removed those. My guess is that it's because Strophe and jQuery were written for the browser and there is no window in the context of the widget environment. Is there something that I can do to port these over for Yahoo TV Widgets? I guess it's worth mentioning that I'm not very familiar with JavaScript!

by
2 Replies
  • You are correct that there is no 'window' object in the TV widgets. The top level DOM element is 'widget'. There is really no easy way to port libraries that are intended for browsers to the TV, other than pulling the code out that you specifically need and porting that over. You obviously won't need to abstract the browser implementations, so all code related to that can be stripped out.
    0
  • QUOTE (waxyzwaxyz@... @ Mar 25 2010, 08:25 PM) <{POST_SNAPBACK}>
    Is there something that I can do to port these over for Yahoo TV Widgets? I guess it's worth mentioning that I'm not very familiar with JavaScript!

    Hi,

    My suggestion is to read the docs and get to know the KONtx framework. The time you would spend porting another library you could be putting towards getting up and running with your widget.

    Check out the sample widgets to get started. I think you'll find that the KONtx framework fulfills most if not all of your needs. If there are controls you feel are lacking or have suggestions on future features, we want to hear them. We have a small (but growing!) active forum. Also, check out this post here.

    Another thing, unless there's a really compelling reason for doing so, I just don't see the point in porting a library geared towards working in a browser environment to a completely different platform for which there is already an active framework. You would also then be supporting that ported library yourself.

    - Ben
    0

Recent Posts

in Getting Started / Beginners - Yahoo! TV Widgets