Ext.require([
'Ext.form.*',
'Ext.layout.container.Column',
'Ext.window.MessageBox',
'Ext.fx.target.Element'
]);
Ext.onReady(function(){
var nsecm=false,nsefo=false,nseop=false,nseff=false,path='',options='',yahooe=false,yahooie=false,yahoo1=false,yahoo5=false,googlee=false,google1m=false,google5m=false,days=1,yahooreal=false;
var nsecmbndrpt=false,nserpt=false,nseex=false,mcxin=false,mcxcf=false,yahoof=false,ncdex=false,bsecm=false,bsein=false,nsein=false,nseetf=false,nsesme=false,nseeo=false,nseef=false;
var statesStore = Ext.create('Ext.data.ArrayStore', {
fields: ['a'],
data : Ext.example.options
});
var path = {
xtype: 'fieldset',
title: 'Output folder path',
layout: 'anchor',
collapsible: true,
collapsed: true,
items: [{
xtype: 'checkboxgroup',
cls: 'x-check-group-alt',
columns: 1,
items: [
{
xtype: 'textfield',
fieldLabel: 'Output folder path',
name: 'path',
width: 450,
labelWidth: 110,
id: 'path'
}
]
}]
};
var checkGroupBSE = {
xtype: 'fieldset',
title: 'BSE',
layout: 'anchor',
defaults: {
anchor: '100%',
labelStyle: 'padding-left:4px;'
},
collapsible: true,
collapsed: true,
items: [{
xtype: 'checkboxgroup',
cls: 'x-check-group-alt',
columns: 4,
items: [
{boxLabel: 'BSE Index', name: 'cb-horiz-9',id:'Bse_Index',listeners: {change: Bse_Index}},
{boxLabel: 'BSE Cash Market', name: 'cb-horiz-10',id:'Bse_Cash_Market',listeners: {change: Bse_Cash_Market}},
{boxLabel: 'NCDEX Futures', name: 'cb-horiz-11',id:'Ncdex_Futures',listeners: {change:Ncdex_Futures }}
]
}]
};
var checkGroupNSE = {
xtype: 'fieldset',
title: 'NSE',
layout: 'anchor',
defaults: {
anchor: '100%',
labelStyle: 'padding-left:4px;'
},
collapsible: true,
collapsed: true,
items: [{
xtype: 'checkboxgroup',
cls: 'x-check-group-alt',
columns: 4,
items: [
{boxLabel: 'NSE Cash Market', name: 'cb-horiz-1',checked: true,id:'Nse_Cash_Market',listeners: {change: Nse_Cash_Market}},
{boxLabel: 'NSE Equity Futures', name: 'cb-horiz-2',id:'Nse_Equity_Futures',listeners: {change: Nse_Equity_Futures}},
{boxLabel: 'NSE Equity Options', name: 'cb-horiz-3',id:'Nse_Equity_Options',listeners: {change: Nse_Equity_Options}},
{boxLabel: 'NSE Forex Futures', name: 'cb-horiz-4',id: 'Nse_Forex_Futures',listeners: {change: Nse_Forex_Futures}},
{boxLabel: 'NSE Forex Options', name: 'cb-horiz-5',id:'Nse_Forex_Options',listeners: {change: Nse_Forex_Options}},
{boxLabel: 'NSE SME', name: 'cb-horiz-6',id:'Nse_Sme',listeners: {change: Nse_Sme}},
{boxLabel: 'NSE ETF', name: 'cb-horiz-7',id:'Nse_Etf',listeners: {change: Nse_Etf}},
{boxLabel: 'NSE Index', name: 'cb-horiz-8',id:'Nse_Index',listeners: {change: Nse_Index}},
{boxLabel: 'NSE Reports', name: 'cb-horiz-17',id:'Nse_reports',listeners: {change:Nse_reports}},
{boxLabel: 'NSE Combined Reports', name: 'cb-horiz-18',id:'Nse_Combined_reports',listeners: {change:Nse_Combined_reports}}
]
}]
};
var checkGroupMCX = {
xtype: 'fieldset',
title: 'MCX',
layout: 'anchor',
defaults: {
anchor: '100%',
labelStyle: 'padding-left:4px;'
},
collapsible: true,
collapsed: true,
items: [{
xtype: 'checkboxgroup',
cls: 'x-check-group-alt',
columns: 4,
items: [
{boxLabel: 'MCX Index', name: 'cb-horiz-15',id:'MCX_Index',listeners: {change:MCX_Index}},
{boxLabel: 'MCX Commodity Futures', name: 'cb-horiz-14',id:'MCX_Commodity_Futures',listeners: {change:MCX_Commodity_Futures }},
{boxLabel: 'National Spot Exchange', name: 'cb-horiz-15',id:'National_Spot_Exchange',listeners: {change:National_Spot_Exchange}}
]
}]
};
var checkGroupYahoo = {
xtype: 'fieldset',
title: 'Yahoo',
layout: 'anchor',
defaults: {
anchor: '100%',
labelStyle: 'padding-left:4px;'
},
collapsible: true,
collapsed: true,
items: [{
xtype: 'checkboxgroup',
cls: 'x-check-group-alt',
columns: 4,
items: [
{boxLabel: 'Yahoo Fundamental', name: 'cb-horiz-12',id:'Yahoo_Fundamental',listeners: {change:Yahoo_Fundamental }},
{boxLabel: 'Yahoo EOD', name: 'cb-horiz-19',id:'Yahoo_EOD',listeners: {change:Yahoo_EOD}},
{boxLabel: 'Yahoo IEOD 5min', name: 'cb-horiz-20',id:'Yahoo_IEOD_5min',listeners: {change:Yahoo_IEOD_5min}},
{boxLabel: 'Yahoo IEOD 1min', name: 'cb-horiz-21',id:'Yahoo_IEOD_1min',listeners: {change:Yahoo_IEOD_1min}},
{boxLabel: 'Yahoo Realtime', name: 'cb-horiz-22',id:'Yahoo_Realtime',listeners: {change:Yahoo_Realtime}}
]
}]
};
var checkGroupGoogle = {
xtype: 'fieldset',
title: 'Google',
layout: 'anchor',
defaults: {
anchor: '100%',
labelStyle: 'padding-left:4px;'
},
collapsible: true,
collapsed: true,
items: [{
xtype: 'checkboxgroup',
cls: 'x-check-group-alt',
columns: 4,
items: [
{boxLabel: 'Google EOD', name: 'cb-horiz-19',id:'Google_EOD',listeners: {change:Google_EOD}},
{boxLabel: 'Google 1min IEOD', name: 'cb-horiz-20',id:'Google_1min_IEOD',listeners: {change:Google_1min_IEOD}},
{boxLabel: 'Google 5min IEOD', name: 'cb-horiz-21',id:'Google_5min_IEOD',listeners: {change:Google_5min_IEOD}},
]
},
{
xtype: 'combobox',
name: 'gd',
billingFieldName: 'gd',
fieldLabel: 'Days for google EOD',
id: 'google',
labelWidth:70,
width: 120,
store: statesStore,
editable: false,
valueField: 'a',
displayField: 'a',
typeAhead: true,
queryMode: 'local',
forceSelection: true,
value: '1'
}]
};
var checkGroupCS = {
xtype: 'fieldset',
title: 'Comming Soon',
layout: 'anchor',
defaults: {
anchor: '100%',
labelStyle: 'padding-left:4px;'
},
collapsible: true,
collapsed: true,
items: [{
xtype: 'checkboxgroup',
cls: 'x-check-group-alt',
columns: 4,
items: [
{boxLabel: 'BSE Equity Futures', name: 'cb-horiz-50',id:'BSE_Equity_Futures'},
{boxLabel: 'BSE Equity Options', name: 'cb-horiz-51',id:'BSE_Equity_Options'},
{boxLabel: 'MCX-SX Forex Futures', name: 'cb-horiz-52',id:'MCX_SX_Forex_Futures'},
{boxLabel: 'MCX-SX Forex Options', name: 'cb-horiz-53',id:'MCX_SX_Forex_Options'},
{boxLabel: 'MCX-SX Equity Indices', name: 'cb-horiz-54',id:'MCX_SX_Equity_Indices'},
{boxLabel: 'MCX-SX Equity Options', name: 'cb-horiz-55',id:'MCX_SX_Equity_Options'},
{boxLabel: 'MCX-SX Equity Futures', name: 'cb-horiz-56',id:'MCX_SX_Equity_Futures'},
{boxLabel: 'Mutual Funds NAV', name: 'cb-horiz-56',id:'Mutual_Funds_NAV'}
]
}]
};
var fp = Ext.create('Ext.FormPanel', {
title: 'Settings',
frame: true,
fieldDefaults: {
labelWidth: 110
},
width: 667,
renderTo:'form-ct',
bodyPadding: 10,
items: [
path,
checkGroupBSE,
checkGroupNSE,
checkGroupMCX,
checkGroupYahoo,
checkGroupGoogle,
checkGroupCS
],
buttons: [{
text: 'Save',
handler: function(){
var fs = require('fs');
path=$("#path-inputEl").val();
var drivePath = path.split('/')[0]+'/';
if(path!='')
{
if(fs.existsSync(drivePath.replace(/\s+/g, '')))
{
function savesetting(path)
{if(nseef)
options='Nse_Equity_Futures-'+options;
if(nseeo)
options='Nse_Equity_Options-'+options;
if(nseff)
options='Nse_Forex_Futures-'+options;
if(nsefo)
options='Nse_Forex_Options-'+options;
if(nsesme)
options='Nse_Sme-'+options;
if(nseetf)
options='Nse_Etf-'+options;
if(nsein)
options='Nse_Index-'+options;
if(bsein)
options='Bse_Index-'+options;
if(bsecm)
options='Bse_Cash_Market-'+options;
if(ncdex)
options='Ncdex_Futures-'+options;
if(yahoof)
options='Yahoo_Fundamental-'+options;
if(mcxcf)
options='MCX_Commodity_Futures-'+options;
if(mcxin)
options='MCX_Index-'+options;
if(nseex)
options='National_Spot_Exchange-'+options;
if(nserpt)
options='Nse_reports-'+options;
if(nsecmbndrpt)
options='Nse_Combined_reports-'+options;
if(yahooe)
options='Yahoo_EOD-'+options;
if(yahoo5)
options='Yahoo_IEOD_5min-'+options;
if(yahoo1)
options='Yahoo_IEOD_1min-'+options;
if(googlee)
options='Google_EOD-'+options;
if(google1m)
options='Google_1min_IEOD-'+options;
if(google5m)
options='Google_5min_IEOD-'+options;
if(yahooreal)
options='Yahoo_Realtime-'+options;
days=$("#google-inputEl").val();
savesettings(path,options,days)
}
fs.mkdir(path, 0777, function(err)
{
if(err)
{
if(fs.existsSync(path))
{
savesetting(path);
if(nsecmbndrpt)
{
Ext.Msg.alert('Message', '<font color="green">Settings are saved successfully.</font><br/><br/><small><b>Note:-</b>Combined Report may take few minutes to download.</small>', function(){
});
}
else
Ext.Msg.alert('Message', 'Settings are saved successfully.', function(){
});
}
else
{
Ext.Msg.alert('Message', '<font color="red">Cannot create directory. Please check output folder path.</font>');
}
}
else
{
savesetting(path);
if(nsecmbndrpt)
{
Ext.Msg.alert('Message', '<font color="green">Settings are saved successfully.</font><br/><br/><small><b>Note:-</b>Combined Report may take few minutes to download.</small>', function(){
});
}
else
Ext.Msg.alert('Message', '"'+path+'" <font color="green">directory created successfully and settings are saved successfully.</font>', function(){
});
}
});
options='';
}else
{
Ext.Msg.alert('Message', '"'+drivePath.replace(/\s+/g, '')+'" <font color="red">Drive not present. Please check path.</font>');
}
}
else
{
var w = Ext.Msg.alert({
title: 'Message',
msg: '<font color="red">Please select output folder path.</font>',
buttons: Ext.Msg.OK,
autoShow: false,
cls: 'msgbox'
});
options='';
}
}
},{
text: 'Reset',
handler: function(){
fp.getForm().reset();
}
}]
});
var win;
if(!win){
win = new Ext.Window({
applyTo : 'hello-win',
layout : 'fit',
title:'Note:',
width : 500,
border: 0,
id: 'tt',
closable: false,
height : 100,
closeAction :'hide',
html: '<div id="ttmsg"><ul><li>1. Output folder path Example: C:/data </li><li>2. Application will download & process data from web in this folder and generate output data.</li><li>3. Please make sure you have 4GB free on this drive.</li></ul></div>',
plain : true,
});
}
Ext.getCmp('path').getEl().on('mouseover', function()
{
win.show();
}
);
Ext.getCmp('path').getEl().on('click', function()
{
win.close();
}
);
Ext.getCmp('path').getEl().on('mouseout', function()
{
win.close();
}
);
$("#google-labelCell").css("width","125");
$("#google-inputCell").css("width","40px");
$("#google-labelEl").css("width","122px");
$("#google-bodyEl").css("float","left");
var cb = Ext.getCmp('Nse_Cash_Market');
cb.disable();
var cb1 = Ext.getCmp('BSE_Equity_Futures');
cb1.disable();
var cb11 = Ext.getCmp('BSE_Equity_Options');
cb11.disable();
var cb2 = Ext.getCmp('MCX_SX_Forex_Futures');
cb2.disable();
var cb3 = Ext.getCmp('MCX_SX_Forex_Options');
cb3.disable();
var cb4 = Ext.getCmp('MCX_SX_Equity_Indices');
cb4.disable();
var cb5 = Ext.getCmp('MCX_SX_Equity_Futures');
cb5.disable();
var cb6 = Ext.getCmp('MCX_SX_Equity_Options');
cb6.disable();
var cb7 = Ext.getCmp('Mutual_Funds_NAV');
cb7.disable();
getsettings();
function Yahoo_Realtime(field)
{
yahooreal=field.getValue();
}
function Google_EOD(field)
{
googlee=field.getValue();
}
function Google_1min_IEOD(field)
{
google1m=field.getValue();
}
function Google_5min_IEOD(field)
{
google5m=field.getValue();
}
function Yahoo_IEOD_1min(field)
{
yahoo1=field.getValue();
}
function Yahoo_IEOD_5min(field)
{
yahoo5=field.getValue();
}
function Yahoo_EOD(field)
{
yahooe=field.getValue();
}
function Nse_Cash_Market(field)
{
nsecm=field.getValue();
}
function Nse_Equity_Futures(field)
{
nseef=field.getValue();
}
function Nse_Equity_Options(field)
{
nseeo=field.getValue();
}
function Nse_Forex_Futures(field)
{
nseff=field.getValue();
}
function Nse_Forex_Options(field)
{
nsefo=field.getValue();
}
function Nse_Sme(field)
{
nsesme=field.getValue();
}
function Nse_Etf(field)
{
nseetf=field.getValue();
}
function Nse_Index(field)
{
nsein=field.getValue();
}
function Bse_Index(field)
{
bsein=field.getValue();
}
function Bse_Cash_Market(field)
{
bsecm=field.getValue();
}
function Ncdex_Futures(field)
{
ncdex=field.getValue();
}
function Yahoo_Fundamental(field)
{
yahoof=field.getValue();
}
function MCX_Commodity_Futures(field)
{
mcxcf=field.getValue();
}
function MCX_Index(field)
{
mcxin=field.getValue();
}
function National_Spot_Exchange(field)
{
nseex=field.getValue();
}
function Nse_reports(field)
{
nserpt=field.getValue();
}
function Nse_Combined_reports(field)
{
nsecmbndrpt=field.getValue();
}
});