Thank you! It works:). I also had to remove the ; sign from the end of the
string.

On Thu, Jan 14, 2010 at 1:21 PM, Daniel Wagner-Hall <dawag...@gmail.com>wrote:

> Their feed starts off with: var cirip =
>
> I would suggest you write a regex which cuts off the start of the
> string up to (and including) the = sign.  The alternative is eval-ing
> the responseText, but that is much less safe.
>
> On Thu, Jan 14, 2010 at 6:03 AM, Ildiko Pocsai
> <ildiko.pocsa...@gmail.com> wrote:
> > Hi!
> > I'm trying to modify the code form this
> > tutorial:
> http://sites.google.com/site/hackathoninabox/chrome/extensions/tutorial
>  for
> > another blog. Here is my code (I tried to modify v2 from source):
> > // timeline attributes
> >       var timeline;
> >       var template;
> >       var link;
> >       var image;
> >       var author;
> >       var content;
> >       var req; // request object
> >       var tweets; // all currently fetched tweets
> >       onload = setTimeout(init, 0); // workaround for
> http://crbug.com/24467
> >       // initialize timeline template
> >       function init() {
> >         timeline = document.getElementById('timeline');
> >         template = xpath('//o...@id="template"]/li', document);
> >         link = xpath('//d...@class="thumbnail"]/a', template);
> >         image = xpath('img', link);
> >         author = xpath('//d...@class="text"]/a', template);
> >         content = xpath('//d...@class="text"]/span', template);
> >         getTweets();
> >       }
> >       // fetch timeline from server
> >       function getTweets() {
> >         req = new XMLHttpRequest();
> >         req.open('GET',
> > 'http://www.cirip.ro/statuses/public_timeline.json');
> >         req.onload = processTweets;
> >         req.send();
> >       }
> >       // process new batch of tweets
> >       function processTweets() {
> >
> >         var res = JSON.parse(req.responseText);
> >         tweets = res.concat(tweets);
> >         update();
> >       }
> >       // update display
> >       function update() {
> >         var user;
> >         var url;
> >         var item;
> >         for (var i in tweets) {
> >           user = tweets[i].user;
> >           url = 'http://www.cirip.ro/u/' + user.username;
> >           // thumbnail
> >           link.title = user.name;
> >           link.href = openInNewTab(url);
> >           image.src = user.profile_image_url;
> >           image.alt = user.name;
> >           // text
> >           author.href = openInNewTab(url);
> >           author.innerHTML = user.name;
> >           content.innerHTML = linkify(tweets[i].text);
> >           // copy node and update
> >           item = template.cloneNode(true);
> >           timeline.appendChild(item);
> >         }
> >       }
> > The request is made and req.responseText is returned correctly, however
> when
> > I use var res = JSON.parse(req.responseText); the execution of the script
> > stops. Can somebody tell me what is the matter with the returned
> > responseText that causes the parser to fail? (the original example is for
> > twitter and for it works perfectly)
> > Thanks,
> > Ildi
> > On Wed, Jan 13, 2010 at 6:41 PM, PhistucK <phist...@gmail.com> wrote:
> >>
> >> I do not think you have to manipulate any DOM for that, you just send
> the
> >> getSelection() value to the popup page.
> >> And yes, that is the only way to do it, you cannot access the content of
> a
> >> tab with any API chrome presents, you can only do so with content script
> >> (hence the name).
> >> ☆PhistucK
> >>
> >>
> >> On Wed, Jan 13, 2010 at 18:03, Petty <m...@paulgriffinpetty.com> wrote:
> >>>
> >>> Brian --
> >>>
> >>> Seems like (and please correct me if I'm off) that I'd need to inject
> >>> a JavaScript file into the tab and set some var to getSelection on
> >>> every mouseup (assuming that's feasable on view-source) so the
> >>> Extension's popup.html could then grab that variable updated value to
> >>> pop into my form.
> >>>
> >>> If that's right, okay ... But since the Extension already works on
> >>> tabs this seems a little arduous.  I'm hopeful that this can be done
> >>> without DOM manipulation.
> >>>
> >>> In case it helps I'm including the contents of files from my
> >>> implementation below.
> >>>
> >>> Also, here the URL to the actual extension:
> >>> http://gush.es/extras/gushes_chrome_ext/gushes.crx
> >>>
> >>> Thanks for your help;
> >>>
> >>> Paul
> >>>
> >>> On Jan 13, 2:52 am, Brian Kennish <bkenn...@chromium.org> wrote:
> >>> > On Mon, Jan 11, 2010 at 8:32 PM, Petty <m...@paulgriffinpetty.com>
> >>> > wrote:
> >>> > > I'm actually just trying to use window.getSelection() on a tab that
> >>> > > has a view-source: displayed so that raw HTML can be posted through
> a
> >>> > > form in a Chrome extension's popup window.
> >>> >
> >>> > > I have it working for 'normal' window / tab displays but
> getSelection
> >>> > > () returns nothing on view-source: tabs.
> >>> >
> >>> > I created this test content script and it works fine on
> "view-source:"
> >>> > pages:
> >>> >
> >>> >   onmouseup = function() { alert(getSelection()); };
> >>> >
> >>> > Give it a try.
> >>>
> >>> --
> >>> You received this message because you are subscribed to the Google
> Groups
> >>> "Chromium-extensions" group.
> >>> To post to this group, send email to
> >>> chromium-extensi...@googlegroups.com.
> >>> To unsubscribe from this group, send email to
> >>> chromium-extensions+unsubscr...@googlegroups.com<chromium-extensions%2bunsubscr...@googlegroups.com>
> .
> >>> For more options, visit this group at
> >>> http://groups.google.com/group/chromium-extensions?hl=en.
> >>>
> >>>
> >>>
> >>
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "Chromium-extensions" group.
> >> To post to this group, send email to
> chromium-extensi...@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> chromium-extensions+unsubscr...@googlegroups.com<chromium-extensions%2bunsubscr...@googlegroups.com>
> .
> >> For more options, visit this group at
> >> http://groups.google.com/group/chromium-extensions?hl=en.
> >>
> >
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Chromium-extensions" group.
> > To post to this group, send email to
> chromium-extensi...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > chromium-extensions+unsubscr...@googlegroups.com<chromium-extensions%2bunsubscr...@googlegroups.com>
> .
> > For more options, visit this group at
> > http://groups.google.com/group/chromium-extensions?hl=en.
> >
> >
>
--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-extensi...@googlegroups.com.
To unsubscribe from this group, send email to chromium-extensions+unsubscr...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/chromium-extensions?hl=en.

Reply via email to