Add best effort mapping of old settings to new settings
This commit is contained in:
+416
-12
@@ -988,6 +988,364 @@ exports.loadSettings = function loadSettings() {
|
||||
|
||||
// check if the json settings were populated
|
||||
if (json_settings != null) {
|
||||
// fix old deprecated settings from v1.01
|
||||
json_settings = fix_deprecated_setting(json_settings, 'title', 'shared_pages.page_title');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'coin', 'coin.name');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'symbol', 'coin.symbol');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'headerlogo', 'shared_pages.page_header.home_link_logo');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'favicon', 'shared_pages.favicon');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'homelink', 'shared_pages.page_header.home_link');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'logoheight', 'shared_pages.page_header.home_link_logo_height');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'sticky_header', 'shared_pages.page_header.sticky_header');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'sticky_footer', 'shared_pages.page_footer.sticky_footer');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'footer_height_desktop', 'shared_pages.page_footer.footer_height_desktop');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'footer_height_tablet', 'shared_pages.page_footer.footer_height_tablet');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'footer_height_mobile', 'shared_pages.page_footer.footer_height_mobile');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'social_link_percent_height_desktop', 'shared_pages.page_footer.social_link_percent_height_desktop');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'social_link_percent_height_tablet', 'shared_pages.page_footer.social_link_percent_height_tablet');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'social_link_percent_height_mobile', 'shared_pages.page_footer.social_link_percent_height_mobile');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'theme', 'shared_pages.theme');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'port', 'webserver.port');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'update_timeout', 'sync.update_timeout');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'check_timeout', 'sync.check_timeout');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'block_parallel_tasks', 'sync.block_parallel_tasks');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'use_rpc', 'api_cmds.use_rpc');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'confirmations', 'shared_pages.confirmations');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'display.api', 'api_page.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'display.markets', 'markets_page.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'display.richlist', 'richlist_page.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'display.search', 'shared_pages.page_header.show_search');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'display.movement', 'movement_page.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'display.network', 'network_page.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'display.masternodes', 'masternodes_page.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'display.masternodesdisplay.claim_address', 'claim_address_page.enabledmasternodes_page.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'display.claim_address_header_menu', 'claim_address_page.show_header_menu');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'display.page_header_bgcolor', 'shared_pages.page_header.bgcolor');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'display.page_footer_bgcolor', 'shared_pages.page_footer.bgcolor');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'display.table_header_bgcolor', 'shared_pages.table_header_bgcolor');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'display.networkpnl', 'shared_pages.page_header.panels.network_panel.display_order');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'display.difficultypnl', 'shared_pages.page_header.panels.difficulty_panel.display_order');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'display.masternodespnl', 'shared_pages.page_header.panels.masternodes_panel.display_order');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'display.coinsupplypnl', 'shared_pages.page_header.panels.coin_supply_panel.display_order');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'display.pricepnl', 'shared_pages.page_header.panels.price_panel.display_order');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'display.marketcappnl', 'shared_pages.page_header.panels.market_cap_panel.display_order');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'display.logopnl', 'shared_pages.page_header.panels.logo_panel.display_order');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'index.show_last_updated', 'index_page.show_last_updated');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'index.show_hashrate', 'shared_pages.show_hashrate');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'index.difficulty', 'shared_pages.difficulty');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'index.last_txs', 'api_page.public_apis.ext.getlasttxs.max_items_per_query');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'reward_page.show_last_updated', 'blockchain_specific.heavycoin.reward_page.show_last_updated');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'api.blockindex', 'api_page.sample_data.blockindex');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'api.blockhash', 'api_page.sample_data.blockhash');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'api.txhash', 'api_page.sample_data.txhash');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'api.address', 'api_page.sample_data.address');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'markets.default', 'markets_page.default_exchange.exchange_name');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'markets.market_dropdown_menu', 'markets_page.show_market_dropdown_menu');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'markets.market_select_visible', 'markets_page.show_market_select');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'richlist.distribution', 'richlist_page.wealth_distribution.show_distribution_chart');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'richlist.received', 'richlist_page.show_received_coins');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'richlist.balance', 'richlist_page.show_current_balance');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'movement.min_amount', 'movement_page.movement_table.min_amount');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'movement.low_flag', 'movement_page.movement_table.low_warning_flag');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'movement.high_flag', 'movement_page.movement_table.high_warning_flag');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'genesis_tx', 'transaction_page.genesis_tx');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'genesis_block', 'block_page.genesis_block');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'heavy', 'blockchain_specific.heavycoin.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'save_stats_after_sync_blocks', 'sync.save_stats_after_sync_blocks');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'txcount', 'api_page.public_apis.ext.getaddresstxs.max_items_per_query');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'txcount_per_page', 'address_page.history_table.items_per_page');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'show_sent_received', 'address_page.show_sent_received');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'supply', 'sync.supply');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'nethash', 'shared_pages.page_header.panels.network_panel.nethash');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'nethash_units', 'shared_pages.page_header.panels.network_panel.nethash_units');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'usecors', 'webserver.cors.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'corsorigin', 'webserver.cors.corsorigin');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'public_api.rpc.getdifficulty', 'api_page.public_apis.rpc.getdifficulty.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'public_api.rpc.getconnectioncount', 'api_page.public_apis.rpc.getconnectioncount.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'public_api.rpc.getblockcount', 'api_page.public_apis.rpc.getblockcount.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'public_api.rpc.getblockhash', 'api_page.public_apis.rpc.getblockhash.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'public_api.rpc.getblock', 'api_page.public_apis.rpc.getblock.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'public_api.rpc.getrawtransaction', 'api_page.public_apis.rpc.getrawtransaction.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'public_api.rpc.getnetworkhashps', 'api_page.public_apis.rpc.getnetworkhashps.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'public_api.rpc.getvotelist', 'api_page.public_apis.rpc.getvotelist.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'public_api.rpc.getmasternodecount', 'api_page.public_apis.rpc.getmasternodecount.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'public_api.rpc.getmaxmoney', 'blockchain_specific.heavycoin.public_apis.getmaxmoney.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'public_api.rpc.getmaxvote', 'blockchain_specific.heavycoin.public_apis.getmaxvote.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'public_api.rpc.getvote', 'blockchain_specific.heavycoin.public_apis.getvote.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'public_api.rpc.getphase', 'blockchain_specific.heavycoin.public_apis.getphase.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'public_api.rpc.getreward', 'blockchain_specific.heavycoin.public_apis.getreward.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'public_api.rpc.getsupply', 'blockchain_specific.heavycoin.public_apis.getsupply.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'public_api.rpc.getnextrewardestimate', 'blockchain_specific.heavycoin.public_apis.getnextrewardestimate.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'public_api.rpc.getnextrewardwhenstr', 'blockchain_specific.heavycoin.public_apis.getnextrewardwhenstr.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'public_api.ext.getmoneysupply', 'api_page.public_apis.ext.getmoneysupply.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'public_api.ext.getdistribution', 'api_page.public_apis.ext.getdistribution.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'public_api.ext.getaddress', 'api_page.public_apis.ext.getaddress.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'public_api.ext.getaddresstxs', 'api_page.public_apis.ext.getaddresstxs.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'public_api.ext.gettx', 'api_page.public_apis.ext.gettx.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'public_api.ext.getbalance', 'api_page.public_apis.ext.getbalance.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'public_api.ext.getlasttxs', 'api_page.public_apis.ext.getlasttxs.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'public_api.ext.getcurrentprice', 'api_page.public_apis.ext.getcurrentprice.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'public_api.ext.getbasicstats', 'api_page.public_apis.ext.getbasicstats.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'public_api.ext.getsummary', 'api_page.public_apis.ext.getsummary.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'public_api.ext.getnetworkpeers', 'api_page.public_apis.ext.getnetworkpeers.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'public_api.ext.getmasternodelist', 'api_page.public_apis.ext.getmasternodelist.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'public_api.ext.getmasternoderewards', 'api_page.public_apis.ext.getmasternoderewards.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'public_api.ext.getmasternoderewardstotal', 'api_page.public_apis.ext.getmasternoderewardstotal.enabled');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'api_cmds.heavies.getmaxmoney', 'blockchain_specific.heavycoin.api_cmds.getmaxmoney');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'api_cmds.heavies.getmaxvote', 'blockchain_specific.heavycoin.api_cmds.getmaxvote');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'api_cmds.heavies.getvote', 'blockchain_specific.heavycoin.api_cmds.getvote');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'api_cmds.heavies.getphase', 'blockchain_specific.heavycoin.api_cmds.getphase');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'api_cmds.heavies.getreward', 'blockchain_specific.heavycoin.api_cmds.getreward');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'api_cmds.heavies.getnextrewardestimate', 'blockchain_specific.heavycoin.api_cmds.getnextrewardestimate');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'api_cmds.heavies.getnextrewardwhenstr', 'blockchain_specific.heavycoin.api_cmds.getnextrewardwhenstr');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'api_cmds.heavies.getsupply', 'blockchain_specific.heavycoin.api_cmds.getsupply');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'api_cmds.masternode_count', 'api_cmds.getmasternodecount');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'wallet.user', 'wallet.username');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'wallet.pass', 'wallet.password');
|
||||
json_settings = fix_deprecated_setting(json_settings, 'social_links', 'shared_pages.page_footer.social_links');
|
||||
// check if social_links setting exists
|
||||
if (json_settings.shared_pages.page_footer.social_links != null) {
|
||||
// loop through the social links to look for and change image_url to image_path
|
||||
json_settings.shared_pages.page_footer.social_links.forEach(function(social_link) {
|
||||
// check if image_url exists
|
||||
if (social_link.image_url != null) {
|
||||
// copy image_url to image_path
|
||||
social_link.image_path = social_link.image_url;
|
||||
// delete the old setting
|
||||
delete social_link.image_url;
|
||||
}
|
||||
});
|
||||
}
|
||||
// fix old logo path
|
||||
if (json_settings.logo != null) {
|
||||
json_settings.logo = json_settings.logo.replace('/images/', '/img/');
|
||||
}
|
||||
json_settings = fix_deprecated_setting(json_settings, 'logo', 'shared_pages.logo');
|
||||
// check if old index.txs_per_page setting exists
|
||||
if (json_settings.index != null && json_settings.index.txs_per_page != null) {
|
||||
// fix parent elements to be sure there are no missing parents
|
||||
json_settings = ensure_parent_elements_exist(json_settings, 'index_page.transaction_table.items_per_page');
|
||||
json_settings = ensure_parent_elements_exist(json_settings, 'movement_page.movement_table.items_per_page');
|
||||
// copy old setting to new index setting
|
||||
json_settings.index_page.transaction_table.items_per_page = json_settings.index.txs_per_page;
|
||||
// copy old setting to new movement setting
|
||||
json_settings.movement_page.movement_table.items_per_page = json_settings.index.txs_per_page;
|
||||
// delete old setting
|
||||
delete json_settings.index.txs_per_page;
|
||||
}
|
||||
// fix parent elements to be sure there are no missing parents
|
||||
json_settings = ensure_parent_elements_exist(json_settings, 'richlist_page.burned_coins.addresses');
|
||||
// check if new burned_coins.addresses setting exists
|
||||
if (json_settings.richlist_page.burned_coins.addresses == null) {
|
||||
// initialize burned_coins.addresses as an empty array
|
||||
json_settings.richlist_page.burned_coins.addresses = [];
|
||||
}
|
||||
// check if old burned_coins setting exists
|
||||
if (json_settings.burned_coins != null) {
|
||||
// loop through old burned_coins
|
||||
json_settings.burned_coins.forEach(function(address) {
|
||||
// add new address string to burned_coins
|
||||
json_settings.richlist_page.burned_coins.addresses.push(address.address);
|
||||
});
|
||||
// delete old setting
|
||||
delete json_settings.burned_coins;
|
||||
}
|
||||
// fix parent elements to be sure there are no missing parents
|
||||
json_settings = ensure_parent_elements_exist(json_settings, 'shared_pages.page_footer.social_links');
|
||||
// check if new social_links setting exists
|
||||
if (json_settings.shared_pages.page_footer.social_links == null) {
|
||||
// initialize social_links as an empty array
|
||||
json_settings.shared_pages.page_footer.social_links = [];
|
||||
}
|
||||
// check if old github setting exists
|
||||
if (json_settings.github != null) {
|
||||
// add new object to social_links
|
||||
json_settings.shared_pages.page_footer.social_links.push({
|
||||
"enabled": (json_settings.display == null || json_settings.display.github == null ? false : json_settings.display.github),
|
||||
"tooltip_text": "Github",
|
||||
"url": "https://github.com/" + json_settings.github,
|
||||
"fontawesome_class": "fab fa-github",
|
||||
"image_path": ""
|
||||
});
|
||||
// delete old settings
|
||||
delete json_settings.github;
|
||||
delete json_settings.display.github;
|
||||
}
|
||||
// check if old discord setting exists
|
||||
if (json_settings.discord != null) {
|
||||
// add new object to social_links
|
||||
json_settings.shared_pages.page_footer.social_links.push({
|
||||
"enabled": (json_settings.display == null || json_settings.display.discord == null ? false : json_settings.display.discord),
|
||||
"tooltip_text": "Discord",
|
||||
"url": json_settings.discord,
|
||||
"fontawesome_class": "fab fa-discord",
|
||||
"image_path": ""
|
||||
});
|
||||
// delete old settings
|
||||
delete json_settings.discord;
|
||||
delete json_settings.display.discord;
|
||||
}
|
||||
// check if old telegram setting exists
|
||||
if (json_settings.telegram != null) {
|
||||
// add new object to social_links
|
||||
json_settings.shared_pages.page_footer.social_links.push({
|
||||
"enabled": (json_settings.display == null || json_settings.display.telegram == null ? false : json_settings.display.telegram),
|
||||
"tooltip_text": "Telegram",
|
||||
"url": "https://t.me/" + json_settings.telegram,
|
||||
"fontawesome_class": "fab fa-telegram",
|
||||
"image_path": ""
|
||||
});
|
||||
// delete old settings
|
||||
delete json_settings.telegram;
|
||||
delete json_settings.display.telegram;
|
||||
}
|
||||
// check if old reddit setting exists
|
||||
if (json_settings.reddit != null) {
|
||||
// add new object to social_links
|
||||
json_settings.shared_pages.page_footer.social_links.push({
|
||||
"enabled": (json_settings.display == null || json_settings.display.reddit == null ? false : json_settings.display.reddit),
|
||||
"tooltip_text": "Reddit",
|
||||
"url": "https://reddit.com/r/" + json_settings.reddit,
|
||||
"fontawesome_class": "fab fa-reddit",
|
||||
"image_path": ""
|
||||
});
|
||||
// delete old settings
|
||||
delete json_settings.reddit;
|
||||
delete json_settings.display.reddit;
|
||||
}
|
||||
// check if old youtube setting exists
|
||||
if (json_settings.youtube != null) {
|
||||
// add new object to social_links
|
||||
json_settings.shared_pages.page_footer.social_links.push({
|
||||
"enabled": (json_settings.display == null || json_settings.display.youtube == null ? false : json_settings.display.youtube),
|
||||
"tooltip_text": "YouTube",
|
||||
"url": json_settings.youtube,
|
||||
"fontawesome_class": "fab fa-youtube",
|
||||
"image_path": ""
|
||||
});
|
||||
// delete old settings
|
||||
delete json_settings.youtube;
|
||||
delete json_settings.display.youtube;
|
||||
}
|
||||
// check if old slack setting exists
|
||||
if (json_settings.slack != null) {
|
||||
// add new object to social_links
|
||||
json_settings.shared_pages.page_footer.social_links.push({
|
||||
"enabled": (json_settings.display == null || json_settings.display.slack == null ? false : json_settings.display.slack),
|
||||
"tooltip_text": "Slack",
|
||||
"url": json_settings.slack,
|
||||
"fontawesome_class": "fab fa-slack",
|
||||
"image_path": ""
|
||||
});
|
||||
// delete old settings
|
||||
delete json_settings.slack;
|
||||
delete json_settings.display.slack;
|
||||
}
|
||||
// check if old twitter setting exists
|
||||
if (json_settings.twitter != null) {
|
||||
// add new object to social_links
|
||||
json_settings.shared_pages.page_footer.social_links.push({
|
||||
"enabled": (json_settings.display == null || json_settings.display.twitter == null ? false : json_settings.display.twitter),
|
||||
"tooltip_text": "Twitter",
|
||||
"url": "https://twitter.com/" + json_settings.twitter,
|
||||
"fontawesome_class": "fab fa-twitter",
|
||||
"image_path": ""
|
||||
});
|
||||
// delete old settings
|
||||
delete json_settings.twitter;
|
||||
delete json_settings.display.twitter;
|
||||
}
|
||||
// check if old facebook setting exists
|
||||
if (json_settings.facebook != null) {
|
||||
// add new object to social_links
|
||||
json_settings.shared_pages.page_footer.social_links.push({
|
||||
"enabled": (json_settings.display == null || json_settings.display.facebook == null ? false : json_settings.display.facebook),
|
||||
"tooltip_text": "Facebook",
|
||||
"url": "https://www.facebook.com/" + json_settings.facebook,
|
||||
"fontawesome_class": "fab fa-facebook",
|
||||
"image_path": ""
|
||||
});
|
||||
// delete old settings
|
||||
delete json_settings.facebook;
|
||||
delete json_settings.display.facebook;
|
||||
}
|
||||
// check if old google+ setting exists
|
||||
if (json_settings.googleplus != null) {
|
||||
// add new object to social_links
|
||||
json_settings.shared_pages.page_footer.social_links.push({
|
||||
"enabled": (json_settings.display == null || json_settings.display.googleplus == null ? false : json_settings.display.googleplus),
|
||||
"tooltip_text": "Google+",
|
||||
"url": "https://plus.google.com/" + json_settings.googleplus,
|
||||
"fontawesome_class": "fab fa-google-plus",
|
||||
"image_path": ""
|
||||
});
|
||||
// delete old settings
|
||||
delete json_settings.googleplus;
|
||||
delete json_settings.display.googleplus;
|
||||
}
|
||||
// check if old bitcointalk setting exists
|
||||
if (json_settings.bitcointalk != null) {
|
||||
// add new object to social_links
|
||||
json_settings.shared_pages.page_footer.social_links.push({
|
||||
"enabled": (json_settings.display == null || json_settings.display.bitcointalk == null ? false : json_settings.display.bitcointalk),
|
||||
"tooltip_text": "Bitcointalk",
|
||||
"url": "https://bitcointalk.org/index.php?topic=" + json_settings.bitcointalk,
|
||||
"fontawesome_class": "fab fa-btc",
|
||||
"image_path": ""
|
||||
});
|
||||
// delete old settings
|
||||
delete json_settings.bitcointalk;
|
||||
delete json_settings.display.bitcointalk;
|
||||
}
|
||||
// check if old website setting exists
|
||||
if (json_settings.website != null) {
|
||||
// add new object to social_links
|
||||
json_settings.shared_pages.page_footer.social_links.push({
|
||||
"enabled": (json_settings.display == null || json_settings.display.website == null ? false : json_settings.display.website),
|
||||
"tooltip_text": "Website",
|
||||
"url": json_settings.website,
|
||||
"fontawesome_class": "fa fa-link",
|
||||
"image_path": ""
|
||||
});
|
||||
// delete old settings
|
||||
delete json_settings.website;
|
||||
delete json_settings.display.website;
|
||||
}
|
||||
// check if the old markets.enabled setting exists
|
||||
if (json_settings.markets != null && json_settings.markets.enabled != null) {
|
||||
// loop through enabled markets
|
||||
json_settings.markets.enabled.forEach(function(market) {
|
||||
// fix parent elements to be sure there are no missing parents
|
||||
json_settings = ensure_parent_elements_exist(json_settings, 'markets_page.exchanges.' + market + '.enabled');
|
||||
// enable the market via new setting
|
||||
json_settings.markets_page.exchanges[market].enabled = true;
|
||||
// check if the old markets.coin and markets.exchange settings exist
|
||||
if (json_settings.markets.coin != null && json_settings.markets.exchange != null) {
|
||||
// set the new setting trading_pairs
|
||||
json_settings.markets_page.exchanges[market].trading_pairs = [json_settings.markets.coin + '/' + json_settings.markets.exchange];
|
||||
// check if the default exchange trading pair is set
|
||||
if (json_settings.markets_page.default_exchange.trading_pair == null) {
|
||||
// fix parent elements to be sure there are no missing parents
|
||||
json_settings = ensure_parent_elements_exist(json_settings, 'markets_page.default_exchange.trading_pair');
|
||||
// set the default exchange trading pair
|
||||
json_settings.markets_page.default_exchange.trading_pair = json_settings.markets.coin + '/' + json_settings.markets.exchange;
|
||||
}
|
||||
}
|
||||
});
|
||||
// delete the old settings
|
||||
delete json_settings.markets.enabled;
|
||||
delete json_settings.markets.coin;
|
||||
delete json_settings.markets.exchange;
|
||||
}
|
||||
// delete old unused settings
|
||||
if (Object.byString(json_settings, 'address') != null) delete json_settings.address;
|
||||
if (Object.byString(json_settings, 'display') != null) delete json_settings.display;
|
||||
if (Object.byString(json_settings, 'index') != null) delete json_settings.index;
|
||||
if (Object.byString(json_settings, 'api') != null) delete json_settings.api;
|
||||
if (Object.byString(json_settings, 'markets') != null) delete json_settings.markets;
|
||||
if (Object.byString(json_settings, 'richlist') != null) delete json_settings.richlist;
|
||||
if (Object.byString(json_settings, 'movement') != null) delete json_settings.movement;
|
||||
|
||||
// loop through all settings from the settings.json file
|
||||
for (var current_setting in json_settings) {
|
||||
// merge settings from settings.json with the defaults from settings.js
|
||||
@@ -1005,6 +1363,53 @@ exports.loadSettings = function loadSettings() {
|
||||
}
|
||||
};
|
||||
|
||||
// define a function to fix deprecated settings
|
||||
fix_deprecated_setting = function(json_settings, old_path, new_path) {
|
||||
// check if the old setting exists
|
||||
if (Object.byString(json_settings, old_path) != null) {
|
||||
// old setting exists
|
||||
// check if the new setting exists
|
||||
if (Object.byString(json_settings, new_path) == null) {
|
||||
// new setting does not exist
|
||||
// get the old value
|
||||
var setting_value = Object.byString(json_settings, old_path);
|
||||
// remove the old setting
|
||||
eval('delete json_settings.' + old_path);
|
||||
// fix parent elements to be sure there are no missing parents
|
||||
json_settings = ensure_parent_elements_exist(json_settings, new_path);
|
||||
// set the new setting to the value of the old setting
|
||||
eval('json_settings' + fix_object_path(new_path) + ' = ' + JSON.stringify(setting_value));
|
||||
// show warning msg
|
||||
console.warn("Deprecated setting '" + old_path + "' has been mapped to the new location '" + new_path + "'. Be sure to make this change in settings.json as the old setting will be removed in a future release.");
|
||||
}
|
||||
}
|
||||
|
||||
return json_settings;
|
||||
}
|
||||
|
||||
// define a function to ensure json parent elements are not null
|
||||
ensure_parent_elements_exist = function(json_settings, path) {
|
||||
var split = path.split('.');
|
||||
// check if the setting has parent elements
|
||||
if (split.length > 1) {
|
||||
var running_path = '';
|
||||
// loop through the parent elements and create dummy containers for each non-existant parent setting
|
||||
for (i = 0; i < split.length - 1; i++) {
|
||||
// add to the running path
|
||||
running_path += (running_path == '' ? '' : '.') + split[i];
|
||||
// get the current setting value
|
||||
var current_value = Object.byString(json_settings, running_path)
|
||||
// check if this setting exists
|
||||
if (current_value == null || typeof current_value !== 'object') {
|
||||
// the setting does not exist or it is not an object, so overwrite the value with a dummy container for now
|
||||
eval('json_settings' + fix_object_path(running_path) + ' = {}');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return json_settings;
|
||||
}
|
||||
|
||||
// define a recursive function used to merge settings from different json objects
|
||||
merge_settings = function(json_settings, exceptions, current_setting, path) {
|
||||
// check if this is an object with more properties
|
||||
@@ -1092,18 +1497,17 @@ fix_object_path = function(path) {
|
||||
|
||||
/* Special thanks to Alnitak for the Object.byString function: https://stackoverflow.com/a/6491621/3038650 */
|
||||
Object.byString = function(o, s) {
|
||||
s = s.replace(/\[(\w+)\]/g, '.$1'); // convert indexes to properties
|
||||
s = s.replace(/^\./, ''); // strip a leading dot
|
||||
var a = s.split('.');
|
||||
for (var i = 0, n = a.length; i < n; ++i) {
|
||||
var k = a[i];
|
||||
if (k in o) {
|
||||
o = o[k];
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
return o;
|
||||
s = s.replace(/\[(\w+)\]/g, '.$1'); // convert indexes to properties
|
||||
s = s.replace(/^\./, ''); // strip a leading dot
|
||||
var a = s.split('.');
|
||||
for (var i = 0, n = a.length; i < n; ++i) {
|
||||
var k = a[i];
|
||||
if (typeof o === 'object' && o !== null && k in o)
|
||||
o = o[k];
|
||||
else
|
||||
return;
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
// populate settings
|
||||
|
||||
Reference in New Issue
Block a user