Results 1 to 6 of 6

This is a discussion on Reloading toolstrip within the Plugins Development section, part of the Chrome Plugins category: I have a very simple toolstrip, the text of which is being generated by an external application (a music player). ...


  1. #1
    eriqjaffe is offline Junior Member
    Join Date
    Oct 2009
    Posts
    6

    Default Reloading toolstrip

    I have a very simple toolstrip, the text of which is being generated by an external application (a music player).

    I'd like to get Chrome to automatically refresh the toolstrip on a scheduled basis (say, every 3 seconds or so). I've tried "<META HTTP-EQUIV="Refresh" CONTENT="3">", sticking "window.location.reload()" in body.onload, etc.

    All of this works when I open the toolstrip.html up as a regular html document, but it never reloads as an extension (I can reload it manually, but that kind of defeats the purpose). Any tips on how I can make this work? I'd be willing to have the application write to a plain text or XML file which the extension can read, as long as it updates itself.

    Thanks!

  2. #2
    Waha's Avatar
    Waha is offline Senior Member
    Join Date
    Apr 2009
    Location
    Oregon
    Posts
    788

    Default

    You can have the external application write to another file in your extension's folder, and have your toolstrip AJAX download that file periodically and write the data to its body.

    That's the only thing I can think of.
    ~ Projects ~
    Specialized: Carapass Auction Watcher, Kongregate Chat
    Libraries: bliplib
    Tools: manifest syntax highlighting & snippits
    ~ Happy to make extensions for pay too ;D ~
    Portfolio: Search and Share

  3. #3
    eriqjaffe is offline Junior Member
    Join Date
    Oct 2009
    Posts
    6

    Default

    Thanks, I got it working with some AJAX/XMLHttpRequest goodness.

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <script type="text/javascript">
    var http = createRequestObject();
    function createRequestObject() {
       var objAjax;
       var browser = navigator.appName;
       if(browser == "Microsoft Internet Explorer"){
          objAjax = new ActiveXObject("Microsoft.XMLHTTP");
       }else{
          objAjax = new XMLHttpRequest();
       }
       return objAjax;
    }
    
    function getNewContent(){
       http.open('get','mm_output.txt');
       http.onreadystatechange = updateNewContent;
       http.send(null);
       return false;
    }
    
    function updateNewContent(){
       if(http.readyState == 4){
          document.getElementById('activity').innerHTML = http.responseText;
       }
    }
    </script>
    </head>
    <body onload="getNewContent();setInterval('getNewContent()',1000 )">
    <div class="toolstrip-button" id="activity"></div>
    </body>
    </html>

  4. #4
    Waha's Avatar
    Waha is offline Senior Member
    Join Date
    Apr 2009
    Location
    Oregon
    Posts
    788

    Default

    Looks good, though I don't think you'll need to check if you user's using Internet Explorer or not. ;]
    ~ Projects ~
    Specialized: Carapass Auction Watcher, Kongregate Chat
    Libraries: bliplib
    Tools: manifest syntax highlighting & snippits
    ~ Happy to make extensions for pay too ;D ~
    Portfolio: Search and Share

  5. #5
    eriqjaffe is offline Junior Member
    Join Date
    Oct 2009
    Posts
    6

    Default

    Heh, I suppose you're right, at that.

  6. #6
    eriqjaffe is offline Junior Member
    Join Date
    Oct 2009
    Posts
    6

    Default

    Oh, and just in case anybody here uses MediaMonkey and has any interest...

    http://eriqjaffe.50webs.com/testext.crx

    ...and the MediaMonkey script that generates the test file in the first place:

    http://eriqjaffe.50webs.com/chromeoutput.mmip

    The Chrome extension itself should be fairly agnostic - it just reads a file called "mm_output.txt" located in the extension's directory. That being said, you should be able to easily adapt it to work with any media player as long as the player can be made to write information about the currently playing song to a file (and, optionally, copy the cover art to the "cover.jpg" file).

Similar Threads

  1. [Ext] Toolstrip Address Bar
    By pcki11 in forum Chrome Plugins
    Replies: 14
    Last Post: 07-04-2011, 04:20 PM
  2. Toolstrip help
    By dabomb4eve in forum Plugins Development
    Replies: 4
    Last Post: 09-12-2009, 10:02 AM
  3. settings for toolstrip
    By libia in forum Plugins Development
    Replies: 3
    Last Post: 08-25-2009, 08:56 PM
  4. Toolstrip Order?
    By devilslackey in forum Chrome Plugins
    Replies: 1
    Last Post: 06-11-2009, 07:48 PM
  5. XML Files Not Reloading
    By Ziggy in forum Bugs and Vulnerabilities
    Replies: 0
    Last Post: 04-12-2009, 04:57 PM

Posting Permissions

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