Skip to content

Commit

Permalink
Version 2.0
Browse files Browse the repository at this point in the history
Added dynamic NIFTY50 list fetching
Also added support for custom symbol names
  • Loading branch information
virresh committed Jun 1, 2018
1 parent 468c8aa commit d599b72
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 13 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ Usage:
Clone the repository and load the unpacked extension in chrome
OR
Download the zip for one of the releases and load that as unpacked extension
For e.g : https://github.com/virresh/NSEIntradayShortcut/archive/1.0.zip
For e.g : https://github.com/virresh/NSEIntradayShortcut/archive/2.0.zip
(This extension is not released onto webstore chrome extension, please create an issue if you feel it should be there)


ScreenShots:

Version 2:
![image three](meta/three.png)

Version one :
![image one](meta/one.png)
![image two](meta/two.png)
1 change: 1 addition & 0 deletions js/jquery-csv.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 36 additions & 10 deletions js/main.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
symList = ['','ADANIPORTS' ,'ASIANPAINT' ,'AXISBANK' ,'BAJAJ-AUTO' ,'BAJFINANCE' ,'BAJAJFINSV' ,'BPCL' ,'BHARTIARTL' ,'INFRATEL' ,'CIPLA' ,'COALINDIA' ,'DRREDDY' ,'EICHERMOT' ,'GAIL' ,'GRASIM' ,'HCLTECH' ,'HDFCBANK' ,'HEROMOTOCO' ,'HINDALCO' ,'HINDPETRO' ,'HINDUNILVR' ,'HDFC' ,'ITC' ,'ICICIBANK' ,'IBULHSGFIN' ,'IOC' ,'INDUSINDBK' ,'INFY' ,'KOTAKBANK' ,'LT' ,'LUPIN' ,'M&M' ,'MARUTI' ,'NTPC' ,'ONGC' ,'POWERGRID' ,'RELIANCE' ,'SBIN' ,'SUNPHARMA' ,'TCS' ,'TATAMOTORS' ,'TATASTEEL' ,'TECHM' ,'TITAN' ,'UPL' ,'ULTRACEMCO' ,'VEDL' ,'WIPRO' ,'YESBANK' ,'ZEEL']
symList = [];

function getGraphURL(symbol) {
preurl= 'https://www.nseindia.com/charts/webtame/webchart.jsp?CDSymbol=';
posturl = '&Segment=CM&Series=EQ&CDExpiryMonth=&FOExpiryMonth=&IRFExpiryMonth=&CDDate1=&CDDate2=&PeriodType=2&Periodicity=1&Template=tame_intraday_getQuote_closing_redgreen.jsp';
return preurl + symbol + posturl;
}

function populateNifty50() {
symList = [''];
$.ajax({
url: "https://www.nseindia.com/content/indices/ind_nifty50list.csv",
dataType: 'text',
cache: false
}).done(function(csvAsString){
var result = $.csv.toArrays(csvAsString);
syindex = result[0].indexOf('Symbol');
console.log("Initialised !");
var i;
for (i = 1; i < result.length; i++) {
symList.push(result[i][syindex]);
}
for (i = 0; i < symList.length; i++) {
op = document.createElement("option");
t = document.createTextNode(symList[i]);
op.appendChild(t);
selectList.appendChild(op);
}
// console.log(syindex);
// console.log(symList);
});
}

function loadURI(){
ind = selectList.selectedIndex;
console.log(selectList.selectedIndex);
Expand All @@ -15,20 +40,21 @@ function loadURI(){
}
}

function loadURIfromText(){
ind = document.getElementById("sel2").value;
if (ind!='') {
chrome.tabs.update(null, {url: getGraphURL(ind.toUpperCase())});
window.close();
}
}

function ready() {
populateNifty50();
selectList = document.getElementById("sel1");
selectList.selectedIndex = -1;
document.getElementById("openChart").addEventListener("click", loadURI);
document.getElementById("openChart2").addEventListener("click", loadURIfromText);
document.getElementById("sel1").addEventListener("change", loadURI);
var i;
for (i = 0; i < symList.length; i++) {
op = document.createElement("option");
t = document.createTextNode(symList[i]);
op.appendChild(t);
selectList.appendChild(op);
}
console.log("Initialised !");
}

console.log(symList);
document.addEventListener("DOMContentLoaded", ready);
3 changes: 3 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"48": "icon48.png",
"128": "icon128.png" },
"author": "Viresh Gupta",
"permissions": [
"https://www.nseindia.com/*"
],
"browser_action": {
"default_popup": "popup.html",
"default_icon": "icon48.png"
Expand Down
Binary file added meta/three.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 10 additions & 2 deletions popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,24 @@
<body style="min-width:500px; margin: 20px;">
<div class="container">
<h4>Shortcuts to NIFTY 50 Intraday Graphs</h4>
<form>
<form style="padding-bottom: 10px;">
<div class="form-group">
<label for="sel1">Select a NIFTY50 from below:</label>
<select class="form-control" id="sel1"></select>
</div>
<button type="button" class="btn" id="openChart">Open Chart !</button>
<button type="button" class="btn" id="openChart">Open Chart from list !</button>
</form>
<form style="padding-top: 10px;">
<div class="form-group">
<label for="sel2">Or enter a SYMBOL Below</label>
<input class="form-control" id="sel2"></input>
</div>
<button type="submit" class="btn" id="openChart2">Open From Symbol !</button>
</form>
</div>
<script src="js/jQuery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery-csv.min.js"></script>
<script src="js/main.js"></script>
</body>
</html>

0 comments on commit d599b72

Please sign in to comment.