aboutsummaryrefslogtreecommitdiffstats
path: root/python/Dawn/static/dawn.js
blob: a282d6c1cfcf827a1b4285b46a647db381bef236 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
function $(s){
    return document.getElementById(s)
}
var index_list = [];
var bbg_map = {'CDX': ["IG", "HY"], 'ITRX': ["EUR", "XOVER"]}
var index_series = ["21", "23", "24", "25"];
var index_tenor = ["3Y", "5Y", "7Y", "10Y"];
for(var begin_index in bbg_map){
    for(var i=0; i<bbg_map[begin_index].length; i++){
        for(var j=0; j<index_series.length; j++){
            for(var k = 0; k<index_tenor.length; k++){
                index_list.push([begin_index, bbg_map[begin_index][i], 'CDSI',
                                 'S'+index_series[j], index_tenor[k]].join(' '));
            }
        }
    }
};

function callback(t) {
    console.log(t);
};

function query_id(secur_id) {
    var xhr = new XMLHttpRequest();
    xhr.open('GET', "/_ajax?bbg_id="+encodeURIComponent(secur_id));
    xhr.onreadystatechange = function() {
        if( xhr.readyState === 4 ){
            callback(xhr.responseText );
        }
    }
    xhr.send();
}

var datalist = $('index_list');
index_list.forEach(function(item){
    var option = document.createElement('option');
    option.value = item;
    datalist.appendChild(option);
});

document.addEventListener("DOMContentLoaded", function(){
    $('swap_type').addEventListener('change',
                                    function(){
                                        if(this.value=='CD_INDEX_TRANCHE'){
                                            $('attach').parentNode.parentNode.style.display='block';
                                            $('detach').parentNode.parentNode.style.display='block';
                                        }else{
                                            $('attach').parentNode.parentNode.style.display='none';
                                            $('detach').parentNode.parentNode.style.display='none';
                                        }
                                    });
    $('security_desc').setAttribute('list', 'index_list');
    $('security_desc').addEventListener('change', function(){
        query_id(this.value);
    });
    var event = new Event('change');
    $('swap_type').dispatchEvent(event);
})