1<!--
 2CHART-GSAR project SID-specific HTML and javascript code.
 3Included by plot.html
 4-->
 5
 6<span id="mainSIDSelector">
 7    <div class='row vc'>
 8        <div class='col-md-2 col-xs-2'>
 9            GSID
10        </div>
11        <div class='col-md-10 col-xs-10 menu-container'>
12            <select class="sid-selector" data="gsid" title="Select primary (default) data source" style="width:100%" accesskey="a">
13                {% for s in SID.django_all %}
14                    <option value="{{s.menu_value.gsid}}">{{s.menu_name}}</option>
15                {% endfor %}
16            </select>
17        </div>
18    </div>
19</span>
20
21<script>
22
23// Convert GUI setting to sid object (part of eventual query object)
24function sidGUItoURL(selector) {
25    selector = (typeof selector !== 'undefined') ? selector : $('#mainSIDSelector');
26    return {'gsid': selector.find('*[data="gsid"]').val()};
27}
28
29// Set sid in GUI according to the URL
30function sidURLtoGUI(qo, selector) {
31    var gsid = null;
32    selector = (typeof selector !== 'undefined') ? selector : $('#mainSIDSelector');
33    for (item in qo) {
34        if (item == 'gsid') {
35            gsid = qo[item];
36        }
37    }
38    if (!gsid) {
39        var sid = sidGUItoURL();
40        gsid = sid.gsid;
41    }
42    selector.find('*[data="gsid"]').multiselect('select', gsid).multiselect('refresh');
43}
44
45// Get sid from a datapoint (if any). Can return empty object.
46// Used in $.extend() function to build a dp object.
47function sidFromDP(dp) {
48    var result = {};
49    for (item in dp) {
50        if (item == 'gsid') {
51            result.gsid = dp[item];
52        }
53    }
54    return result;
55}
56
57</script>