Results 1 to 8 of 8

Thread: Any Javascript gurus out there?

  1. #1
    Join Date
    Nov 2005
    Location
    Lincolnshire, UK
    Beans
    1,461
    Distro
    Ubuntu 10.04 Lucid Lynx

    Any Javascript gurus out there?

    For some time now I have been using the "Howto: Create a Handy "Search Ubuntu Forums" Bookmarklet" posted by PierreDeKat.

    This useful Firefox bookmarklet uses javascript to produce a data entry box for a search term, and then searches the Ubuntu Forums for corresponding results.

    Unfortunately, since upgrading to Firefox 10, this seems to have stopped working.

    Are there any helpful javascript gurus out there willing to help get this working again?

    ps. I have edited versions of the command line for different forums and they have all stopped working as well - so it isn't that my command is corrupted.

  2. #2
    Join Date
    Aug 2008
    Location
    Brazil
    Beans
    12,497
    Distro
    Ubuntu Studio 12.04 Precise Pangolin

    Re: Any Javascript gurus out there?

    Open a text editor and paste the following in it:

    Code:
    <SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/" xmlns:os="http://a9.com/-/spec/opensearch/1.1/">
    <os:ShortName>Ubuntu Forums</os:ShortName>
    <os:Description>Search Ubuntu Forums using Google</os:Description>
    <os:InputEncoding>UTF-8</os:InputEncoding>
    <os:Image width="16" height="16">data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABoUlEQVQ4jZ2TP0tcQRTFj8XjvdEV2by5YxEwqSRpN4H9EhpsNmAjvjedhQpaWNj6DYQQLNKlEEnjG62CIJI3Axb5AhGFiJ9AVFBOCt3sM7vrn1yYZpjzm7lnzgWeUR6y7mGOS+gPjx7mO0TMoiZtvEAbz/16MzweYBhg6GG+9xd+eZ2wGKnTJru0in9XFs8HyLaHuQgQ21tMDHBH79Gln5hFDdrkpgNJLmnV8vnHwSnm0fveAJfO0glZ6Gt+S98yiyeYRU3OxpPM1VYFdsIWavfFm6ixkDM6IXf0Kb8OjXZdYJONCmS1vfmKuVri2mCDhRzRCenq0z1fOKPGmCdXd4D9O4A6pFVkrn6yeLFIJ+Rm+rKvyVa1mKsV5vHifwECpOUhKx66DXh6CweojwWYq9ssyP6zTQyQjXaYSshqd3//fOMP6IkSabOEnvSQrbY4wJzsQWrdgEqQSuhGgNxURJceZvlwOJ06gO4dJKAT5QDZrYhZQubp9DadXLDoE+VqfQaiEmnTQxY8zNzvGT1+a7CQTvcfpoeKTtZZ6GMWnXH+A8hSGPIYT+bNAAAAAElFTkSuQmCC</os:Image>
    <SearchForm>http://www.google.com/search</SearchForm>
    <os:Url type="text/html" method="GET" template="http://www.google.com/search">
      <os:Param name="sitesearch" value="ubuntuforums.org"/>
      <os:Param name="q" value="{searchTerms}"/>
    </os:Url>
    </SearchPlugin>

    Save it as google-ubuntu.xml in the Firefox profile folder inside the "searchplugins" folder. The location should be something like this:

    Code:
    /home/you/.mozilla/firefox/xxxxxxx.default/searchplugins/google-ubuntu.xml
    Restart Firefox.

  3. #3
    Join Date
    Nov 2005
    Location
    Lincolnshire, UK
    Beans
    1,461
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Any Javascript gurus out there?

    Many thanks for that lovinglinux. Your code seems to work OK as it does produce a Google search of Ubuntu Forums, after entering a term in the search engine box at the top of the Firefox screen.

    However, this functionality is slightly different to my original query which produced a javascript data entry box in the middle of the screen. This javascript box (and resulting query) was generated by a single line of code in a Firefox bookmark...
    Code:
    javascript:Qr=document.getSelection();if(!Qr){void(Qr=prompt('Keywords...',''))};if(Qr)location.href='http://www.google.com/search?hl=en&suggon=0&as_q='+escape(Qr)+'&as_epq=&as_oq=&as_eq=&num=10&lr=&as_filetype=&ft=i&as_sitesearch=ubuntuforums.org&as_qdr=all&as_rights=&as_occt=any&cr=&as_nlo=&as_nhi=&safe=off'
    This used to work reliably but, after upgrading to Firefox 10, no longer produces the javascript entry box.

    Any ideas?

  4. #4
    Join Date
    Aug 2008
    Location
    Brazil
    Beans
    12,497
    Distro
    Ubuntu Studio 12.04 Precise Pangolin

    Re: Any Javascript gurus out there?

    I just tested the bookmarklet and it still works. You need to first select the text you want to search, then click the bookmarklet.

  5. #5
    Join Date
    Nov 2005
    Location
    Lincolnshire, UK
    Beans
    1,461
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Any Javascript gurus out there?

    Quote Originally Posted by lovinglinux View Post
    I just tested the bookmarklet and it still works. You need to first select the text you want to search, then click the bookmarklet.
    You are quite right - it does work as you have suggested, producing the appropriate Google search results from site:ubuntuforums.org.

    However, the way the bookmarklet originally worked was to generate a grey dialog box in the middle of the screen into which a search term could be entered. This is the javascript feature that is no longer working. The resulting Google search still appears to be working correctly as you have demonstrated.

    So, the problem seems to be with the initial part of the string containing the javascript commands. Unfortunately, this is not my area of expertise.
    Code:
    eg.
    javascript:Qr=document.getSelection();if(!Qr){void(Qr=prompt('Keywords...',''))}...etc.
    How can this be tweaked to produce the grey dialog box again?

  6. #6
    Join Date
    Aug 2008
    Location
    Brazil
    Beans
    12,497
    Distro
    Ubuntu Studio 12.04 Precise Pangolin

    Re: Any Javascript gurus out there?

    I don't get it how is that different from using the search bar?

    Btw, I am moving your thread to the Programming Talk thread.

  7. #7
    Join Date
    Aug 2008
    Location
    Brazil
    Beans
    12,497
    Distro
    Ubuntu Studio 12.04 Precise Pangolin

    Re: Any Javascript gurus out there?

    This still works in Firefox:

    Code:
    prompt('Keywords...','')
    So, the problem must be somewhere else. I will take a look at the code and try to fix it later. I can't do it right now.

    BTW, it works perfectly on Opera.
    Last edited by lovinglinux; March 16th, 2012 at 01:26 AM.

  8. #8
    Join Date
    Nov 2005
    Location
    Lincolnshire, UK
    Beans
    1,461
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Any Javascript gurus out there?

    Quote Originally Posted by lovinglinux View Post
    I don't get it how is that different from using the search bar?
    It probably isn't.

    I appreciate that your xml code appears to do the same thing. I am just concerned that something has changed with Firefox/Javascript and it would be good to restore the original javascript functionality.

    Quote Originally Posted by lovinglinux View Post
    ...BTW, it works perfectly on Opera.
    Agreed.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •