diff options
Diffstat (limited to 'python/Dawn/static')
| -rw-r--r-- | python/Dawn/static/dawn.js | 77 |
1 files changed, 29 insertions, 48 deletions
diff --git a/python/Dawn/static/dawn.js b/python/Dawn/static/dawn.js index 2ff9402d..5b76d69d 100644 --- a/python/Dawn/static/dawn.js +++ b/python/Dawn/static/dawn.js @@ -89,72 +89,53 @@ $(function() { }); $('#swap_type').change(function() { var to_hide, to_show; + const hide = (arr) => arr.forEach(id => { + document.getElementById(id) + .parentElement + .parentElement + .style.display = 'none'; + }); + const show = (arr) => arr.forEach(id => { + document.getElementById(id) + .parentElement + .parentElement + .style.display = 'block'; + }); switch ($(this).val()) { + case 'CD_BASKET_TRANCHE': case 'CD_INDEX_TRANCHE': case 'BESPOKE': - to_show = ['orig_attach', 'orig_detach', 'initial_margin_percentage', - 'index_ref', 'corr_attach', 'corr_detach']; - to_show.forEach(function(id) { - $('#' + id).parent().parent().css('display', 'block'); - }); - $('#orig_attach').parent().parent().css('display', 'block'); - $('#orig_detach').parent().parent().css('display', 'block'); - $('#clearing_facility').parent().parent().css('display', 'none'); + show(['orig_attach', 'orig_detach', 'initial_margin_percentage', + 'index_ref', 'corr_attach', 'corr_detach']); + hide(['clearing_facility', 'account_code']); $('#clearing_facility').val(''); - $('#initial_margin_percentage').parent().parent().css('display', 'block'); - $('#account_code').parent().parent().css('display', 'none'); $('#portfolio').val('TRANCHE'); break; case 'CD_INDEX': - to_hide = ['orig_attach', 'orig_detach', 'initial_margin_percentage', - 'corr_attach', 'corr_detach', 'index_ref']; - to_hide.forEach(function(id) { - $('#' + id).parent().parent().css('display', 'none'); - }); - $('#clearing_facility').parent().parent().css('display', 'block'); + hide(['orig_attach', 'orig_detach', 'initial_margin_percentage', + 'index_ref', 'corr_attach', 'corr_detach']); + show(['clearing_facility', 'account_code']); $('#clearing_facility').val('ICE-CREDIT'); - $('#account_code').parent().parent().css('display', 'block'); $('#folder').change(); break; case 'ABS_CDS': - to_hide = ['orig_attach', 'orig_detach', - 'corr_attach', 'corr_detach', 'index_ref']; - to_hide.forEach(function(id) { - $('#' + id).parent().parent().css('display', 'none'); - }); - $('#initial_margin_percentage').parent().parent().css('display', 'block'); - $('#clearing_facility').parent().parent().css('display', 'none'); + hike(['orig_attach', 'orig_detach', + 'index_ref', 'corr_attach', 'corr_detach', + 'clearing_facility']); + show(['initial_margin_percentage']); $('#clearing_facility').val(''); $('#portfolio').val('MORTGAGES'); break; - case 'CD_BASKET_TRANCHE': - to_show = ['orig_attach', 'orig_detach', 'initial_margin_percentage', - 'corr_attach', 'corr_detach', 'index_ref']; - to_show.forEach(function(id) { - $('#' + id).parent().parent().css('display', 'block'); - }); - $('#clearing_facility').parent().parent().css('display', 'none'); - $('#clearing_facility').val(''); - $('#portfolio').val('TRANCHE'); - break; case 'SWAPTION': - to_hide = ['fixed_rate', 'index_ref', 'security_desc', - 'corr_attach', 'corr_detach']; - to_hide.forEach(function(id) { - $('#' + id).parent().parent().css('display', 'none'); - }); + hide(['fixed_rate', 'index_ref', 'security_desc', + 'corr_attach', 'corr_detach']); $('#portfolio').val('IR'); $('#settlement_type').val('Cash'); break; case 'CD_INDEX_OPTION': - to_hide = ['orig_attach', 'orig_detach', - 'corr_attach', 'corr_detach']; - to_hide.forEach(function(id) { - $('#' + id).parent().parent().css('display', 'none'); - }); - $('#fixed_rate').parent().parent().css('display', 'block'); - $('#index_ref').parent().parent().css('display', 'block'); - $('#security_desc').parent().parent().css('display', 'block'); + hide(['orig_attach', 'orig_detach', + 'corr_attach', 'corr_detach']); + show(['fixed_rate', 'index_ref', 'security_desc']); $('#portfolio').val('OPTIONS'); $('#settlement_type').val('Delivery'); break; @@ -173,7 +154,7 @@ $(function() { $('#partial_termination').change(); $('#swap_type').change(); var datalist = $('#index_list'); - index_list.forEach(function(item) { + index_list.forEach(item => { var option = document.createElement('option'); option.value = item; datalist.append(option); |
