I've written another plugin for requesting the stock quotes using the yahoo-finance site.
There are already several stock quotes plugins, so I don't know if its worth including this, but the difference with the others is related to Ronans remark (see "[DQSD-Users] Ticker-tape functionality for DQSD").
 
Instead of opening a new browser-window, it requests the info from the site and displays the results in a small popup-window. It also is able to request multiple symbols and display the result in one popup-window. If you fill-in the variable defaultystks in localprefs.js, using ystks without arguments shows info on these symbols.
 
Does this approach make any sense?
 
regards,
Frank
 
 
<search function="ystks">
  <name>Yahoo Finance Stock Quotes</name>
  <description>Use Yahoo Finance to get stock quotes by symbols.<br />
    <div class="helpboxDescLabels">Example:</div>
    <table class="helpboxDescTable">
  		<tr><td>ystks MSFT SUNW</td></tr>
  	</table>
  </description>
  <category>Finance</category>
  <link>http://finance.yahoo.com/</link>
  <contributor>Frank Van Belle</contributor>
  <script><![CDATA[
 
var defaultystks; 
  
function ystks(q)
{
  var gYSTKSpopw=null;
  var hdr = "";
  var style = "";
  var ftr = "</table></td></tr></table>";
  var body = ""
  var rpos = "<tr><td class=pos><a href='http://finance.yahoo.com' onmouseup=parent.openDocument('http://finance.yahoo.com/q?s=$1&d=t')>$1</a></td><td class=pos>$2</td><td class=pos>$5</td><td class=pos>$9</td><td class=pos>$6</td><td class=pos>$8 - $7</td></tr>";
  var rneg = "<tr><td class=neg><a href='http://finance.yahoo.com' onmouseup=parent.openDocument('http://finance.yahoo.com/q?s=$1&d=t')>$1</a></td><td class=neg>$2</td><td class=neg>$5</td><td class=neg>$9</td><td class=neg>$6</td><td class=neg>$8 - $7</td></tr>";
  var reF = /\"(.*)\",(.*),\"(.*)\",\"(.*)\",(.*),(.*),(.*),(.*),(.*),\"(.*)\"/;
  style = "<style>"
  style += "TD.hdr{background-color:silver ; FONT-FAMILY: Arial;FONT-SIZE: 8pt; FONT-WEIGHT: bold; TEXT-ALIGN: center}"
  style += "TD.pos{color:forestgreen ; background-color:#ffffff ; FONT-FAMILY: Arial;FONT-SIZE: 8pt; TEXT-ALIGN: center}"
  style += "TD.neg{color:red ; background-color:#ffffff ; FONT-FAMILY: Arial;FONT-SIZE: 8pt; TEXT-ALIGN: center}"
  style += "</style>";
  hdr = "<table border=0 cellPadding=0 cellSpacing=0 width=100%><tr><td>" + style + "<table border=1 cellpadding=2 cellspacing=0 width=100%>";
  hdr += "<tr><td class=hdr>Symbol</td><td class=hdr>Last Trade</td><td class=hdr>Change</td><td class=hdr>Volume</td><td class=hdr>Open</td><td class=hdr>Days's Range</td></tr>";

  xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  if (q != "")
  {
    aq = q.split(" ");
  }
  else
  {
    if (defaultystks != null)
    {
      aq = defaultystks.split(" ");
    }
    else
    {
      openSearchWindow("http://finance.yahoo.com";);
      return true;
    }
  }
  ifq = 0;
  for(var j = 0; j < aq.length; j++) 
  {
    if (aq[j] != "")
    {
      xmlHttp.open("GET", "http://finance.yahoo.com/d/quotes.csv?f=sl1d1t1c1ohgvn&e=.csv&s="; + (aq[j]).toUpperCase(), false);
      xmlHttp.send();
      qr=xmlHttp.responseText;
      if (bPLF = reF.test(qr))
    	{
        ifq++;
    	  change = RegExp.$5;
        if (change.charAt(0)=='-')
        {
          body += (qr).replace(reF,rneg);
        }
        else
        {
          body += (qr).replace(reF,rpos);
        }
    	}
    }
  }

	gYSTKSpopw = window.createPopup();
	gYSTKSpopw.document.body.innerHTML = hdr + body + ftr;
	gYSTKSpopw.document.body.style.border = "outset 2px";
  gYSTKSpopw.show(0, -(ifq*20+25), document.body.clientWidth, ifq*20+25, document.body);
  xmlHttp = null;
}
    
  ]]></script>
</search>

Reply via email to