Pata NSE Stocks Widget [RETIRED]

Originally posted on 2012-09-01T15:06:00Z at http://theonlinekenyan.com/2012/09/pata-nse-stocks-widget.html

UPDATE: The NSE API project is currently suspended, hence the widget is retired until further notice.

The Pata NSE Stocks widget is a small web application I wrote that allows users to embed NSE Stocks in their websites/blogs. It is based on the NSE API (currently suspended) I wrote last week.

A look at the Pata NSE Stocks widget

The widget should load above. It requires javascript to load and loads after the rest of the page has finished loading.

Playing well with others

The widget has been optimized to play well with your page and other plugins, addons or widgets you may have.
  • Content First - The widget only loads after the rest of the page has loaded
  • Graceful degradation - If the user has not enabled javascript, the widget fails silently. It does not load the iframe, ensuring the user doesn't notice it.
  • Security - Since it's written in javascript, an iframe provides a safe sandbox for code execution
  • Performant - Reduces HTTP Request by using inline CSS in the called iframe.

How to use the Pata NSE Stocks Widget (Option 1)

Copy the line below and paste it where you want the widget to display: [html]<div id='theOK-EoDS'>&nbps</div>[/html] Please not that you can only display one widget per web page. As in, just insert this once. The &nbps is for CMSs like wordpress which strip out blank DIVs in posts. Copy the code below and paste it into the <body>tag, (adviseably just before the end </bold>) or in your <head> tag. [html] <script type='text/javascript'> /*The script that loads the iframe, can be inserted in the head tag - waits for page to load */ ( function (){ window.onload = function(){ document.getElementById('theOK-EoDS').innerHTML = "<iframe " + " src='https://theonlinekenyan-apps.appspot.com/iframe/pata-nse/pata-stocks.html'" + " frameborder='0' style='width:300px; height:320px' title='Pata NSE Stocks'" + " type='text/html' allowFullScreen ></iframe>"; }; })(); </script> [/html] I advice using the first option (above), but if you're unable to use it, you can use the option below.

Option 2: Iframe

Simply insert the iframe below where you'll want it to load. [html] <iframe style="width: 300px; height: 320px;" title="Pata NSE Stocks" src="https://theonlinekenyan-apps.appspot.com/iframe/pata-nse/pata-stocks.html" frameborder="0" width="320" height="240"> </iframe> [/html] That's all. If the widget doesn't show; please check that you have javascript enabled. Otherwise, tweet me any issues. I recommend only using the widget if your site does not allow you to run javascript.

Updates

  • NSE Kenya Stocks Google Gadget - The Pata NSE Stocks widget can be found as a iGoogle gadget here.

Bug Fixes

  • 01 - 03 September 2012 - NSE API: Pata Stocks widgets should now pick the current day's end of stocks instead of starting at yesterday's