/********************************
<Shubha Downloader, It downloads end of day pricing data from publicly available sites and converts it different formats....>
Copyright (C) 2013 Shubhalabha.in
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
***********************************/
function savesettings(path,options,days,format,event,yahoohr,yahoomin,googlehr,googlemin)
{
var csv = require('ya-csv');
var fs =require('fs');
//if(fs.existsSync('settings.csv'))
{
fs.writeFile('settings.csv','datafolder,'+path+'\noptions,'+options+'\ndays,'+days+'\nformat,'+format+'\nevent,'+event+'\nyahoohr,'+yahoohr+'\nyahoomin,'+yahoomin+'\ngooglehr,'+googlehr+'\ngooglemin,'+googlemin+'\n' , function (err) {
if(err){document.getElementById("om").innerHTML+="<br/>"+err;}
var opPath= "";
var reader = csv.createCsvFileReader('settings.csv',{'separator': ','});
reader.addListener('data', function(data)
{
if(data[0]=='datafolder')
{
opPath = data[1];
}
if(data[0]=='event')
{
if(data[1].search('Delete_All_Events')>=0)
{
// delete events file
if(fs.existsSync(opPath+'/events/CA_ALL_FORTHCOMING.csv'))
{
fs.unlinkSync(opPath+'/events/CA_ALL_FORTHCOMING.csv');
}
if(fs.existsSync(opPath+'/events/BM_All_Forthcoming.csv'))
{
fs.unlinkSync(opPath+'/events/BM_All_Forthcoming.csv');
}
}
}
});
});
}
/*else
{
fs.writeFile('settings.csv','datafolder,'+path+'\noptions,'+options+'\n' , function (err) {
if(err){document.getElementById("om").innerHTML+="<br/>"+err;}
});
/* fs.appendFileSync('html/settings1.csv', 'options,'+options+'\n','UTF-8', function(err){
if(err);
console.log('\n'+err);
});
var reader = csv.createCsvFileReader('html/lastupdate.csv',{'separator': ','});
reader.addListener('data', function(data)
{
if(data[0]=='datafolder'){
}
});*/
//}
}
function getsettings()
{
var csv = require('ya-csv');
var fs =require('fs');
if(fs.existsSync('settings.csv')){
var reader = csv.createCsvFileReader('settings.csv',{'separator': ','});
reader.addListener('data', function(data)
{
if(data[0]=='datafolder'){
$("#path-inputEl").val(data[1]);
}
if(data[0]=='options')
{
if(data[1].search('Nse_Forex_Futures')>=0)
{
Ext.getCmp("Nse_Forex_Futures").setValue(true);
}
if(data[1].search('Nse_Cash_Market')>=0)
{
Ext.getCmp("Nse_Cash_Market").setValue(true);
}
if(data[1].search('Nse_Equity_Futures')>=0)
{
Ext.getCmp("Nse_Equity_Futures").setValue(true);
}
if(data[1].search('Nse_Equity_Options')>=0)
{
Ext.getCmp("Nse_Equity_Options").setValue(true);
}
if(data[1].search('Nse_Forex_Futures')>=0)
{
Ext.getCmp("Nse_Forex_Futures").setValue(true);
}
if(data[1].search('Nse_Forex_Options')>=0)
{
Ext.getCmp("Nse_Forex_Options").setValue(true);
}
if(data[1].search('Nse_Sme')>=0)
{
Ext.getCmp("Nse_Sme").setValue(true);
}
if(data[1].search('Nse_Etf')>=0)
{
Ext.getCmp("Nse_Etf").setValue(true);
}
if(data[1].search('Nse_Index')>=0)
{
Ext.getCmp("Nse_Index").setValue(true);
}
if(data[1].search('Bse_Index')>=0)
{
Ext.getCmp("Bse_Index").setValue(true);
}
if(data[1].search('Bse_Cash_Market')>=0)
{
Ext.getCmp("Bse_Cash_Market").setValue(true);
}
if(data[1].search('Ncdex_Futures')>=0)
{
Ext.getCmp("Ncdex_Futures").setValue(true);
}
if(data[1].search('Yahoo_Fundamental')>=0)
{
Ext.getCmp("Yahoo_Fundamental").setValue(true);
}
if(data[1].search('MCX_Commodity_Futures')>=0)
{
Ext.getCmp("MCX_Commodity_Futures").setValue(true);
}
if(data[1].search('MCX_Index')>=0)
{
Ext.getCmp("MCX_Index").setValue(true);
}
if(data[1].search('National_Spot_Exchange')>=0)
{
Ext.getCmp("National_Spot_Exchange").setValue(true);
}
if(data[1].search('Nse_reports')>=0)
{
Ext.getCmp("Nse_reports").setValue(true);
}
if(data[1].search('Nse_Combined_reports')>=0)
{
Ext.getCmp("Nse_Combined_reports").setValue(true);
}
if(data[1].search('Yahoo_EOD')>=0)
{
Ext.getCmp("Yahoo_EOD").setValue(true);
}
if(data[1].search('Yahoo_IEOD_5min')>=0)
{
Ext.getCmp("Yahoo_IEOD_5min").setValue(true);
}
if(data[1].search('Yahoo_IEOD_1min')>=0)
{
Ext.getCmp("Yahoo_IEOD_1min").setValue(true);
}
/****************google data*******************/
if(data[1].search('Google_EOD')>=0)
{
Ext.getCmp("Google_EOD").setValue(true);
}
if(data[1].search('Google_1min_IEOD')>=0)
{
Ext.getCmp("Google_1min_IEOD").setValue(true);
}
if(data[1].search('Google_5min_IEOD')>=0)
{
Ext.getCmp("Google_5min_IEOD").setValue(true);
}
if(data[1].search('Yahoo_Realtime')>=0)
{
Ext.getCmp("Yahoo_Realtime").setValue(true);
}
}
if(data[0]=='days')
{
Ext.getCmp("google").setValue(data[1]);
}
if(data[0]=='yahoohr')
{
Ext.getCmp("yahoohr").setValue(data[1]);
}
if(data[0]=='yahoomin')
{
Ext.getCmp("yahoomin").setValue(data[1]);
}
if(data[0]=='googlehr')
{
Ext.getCmp("googlehr").setValue(data[1]);
}
if(data[0]=='googlemin')
{
Ext.getCmp("googlemin").setValue(data[1]);
}
if(data[0]=='format')
{
if(data[1].search('AmiBroker')>=0)
{
Ext.getCmp("amibroker").setValue(true);
}
if(data[1].search('Advanced_Get')>=0)
{
Ext.getCmp("advancedget").setValue(true);
}
if(data[1].search('FChart')>=0)
{
Ext.getCmp("fchart").setValue(true);
}
if(data[1].search('MetaStock')>=0)
{
Ext.getCmp("metastock").setValue(true);
}
if(data[1].search('Ninja')>=0)
{
Ext.getCmp("ninja").setValue(true);
}
}
if(data[0]=='event')
{
if(data[1].search('Corporate_Events')>=0)
{
Ext.getCmp("Corporate_Events").setValue(true);
}
if(data[1].search('Board_Meetings')>=0)
{
Ext.getCmp("Board_Meetings").setValue(true);
}
if(data[1].search('Delete_All_Events')>=0)
{
Ext.getCmp("Delete_All_Events").setValue(true);
}
}
});
}
}