/adei/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/adei/trunk

« back to all changes in this revision

Viewing changes to patches/riku-weather/xslt/riku.xsl

  • Committer: Suren A. Chilingaryan
  • Date: 2012-07-14 17:44:09 UTC
  • Revision ID: csa@dside.dyndns.org-20120714174409-cuzsy4vupyjx9lia
Update of setups

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?xml version="1.0" encoding="utf-8"?>
2
 
<xsl:stylesheet version="1.0"  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3
 
 <xsl:output method="html" encoding="utf-8"/>
4
 
 <xsl:template match="/">
5
 
    <!--page styles found in adei.css-->
6
 
    <!--jQuery libraries hosted by google-->
7
 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
8
 
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
9
 
    <script type="text/javascript">
10
 
    <![CDATA[
11
 
    //standard way to initialize jQuery sliders
12
 
    //has some problems on initial load with Firefox, needs another click of the Apply button in source tab
13
 
    //Opera works fine
14
 
    $("#page_wrapper_div").ready(function()
15
 
    {
16
 
    
17
 
        $("#start_slider").slider(
18
 
        { 
19
 
            handle: $('.knob'),
20
 
            animate:'true',
21
 
            min:1,
22
 
            max:]]><xsl:value-of select="result/start_slider_max"/><![CDATA[,
23
 
            step:1,
24
 
            startValue:1,
25
 
            change: function(e,ui)
26
 
            {
27
 
                var s = ]]><xsl:value-of select="result/start"/><![CDATA[;
28
 
                
29
 
                if(s != ui.value)
30
 
                {
31
 
                    adei.SetCustomProperties("start=" + ui.value + "&pic_id=" + (Math.floor(]]><xsl:value-of select="result/data_amount"/><![CDATA[/]]><xsl:value-of select="result/start_slider_max"/><![CDATA[) * (ui.value - 1)) + "&window=" + 0);
32
 
                }
33
 
            }
34
 
        });
35
 
    
36
 
        $("#zoom_slider").slider(
37
 
        { 
38
 
            handle: $('.knob'),
39
 
            animate:'true',
40
 
            min:1,
41
 
            max:5,
42
 
            step:1,
43
 
            startValue:1,
44
 
            orientation:'vertical',
45
 
 
46
 
            change: function(e,ui)
47
 
            {
48
 
                var z = ]]><xsl:value-of select="result/zoom"/><![CDATA[;
49
 
                
50
 
                if(z != ui.value)
51
 
                {
52
 
                    adei.SetCustomProperties("zoom=" + ui.value + "&window=" + 0);
53
 
                }
54
 
            }
55
 
        });
56
 
    
57
 
    });
58
 
 
59
 
    //when the main image is clicked, we get the mouse X position
60
 
    //and use that and the amount of data in the graph to determine what to show on the 
61
 
    //secondary image, this function won't work correctly if the window property is used to select the shown data
62
 
    function GetMouseX(event)
63
 
    {
64
 
        var g_width = document.getElementById("image").width;//get the width of the whole image
65
 
        
66
 
        //get the X position of the mouse pointer in relation to the edge of the main sidebar
67
 
        var pos_x = event.pageX-document.getElementById("image").offsetLeft-document.getElementById("main_sidebar").offsetWidth;
68
 
        
69
 
        pos_x = pos_x - 50;//remove from the X position the width of the graph's left margin
70
 
        
71
 
        //get the amount of datapoints read by the service and the start_slider's maximum value
72
 
        var data_amount = ]]><xsl:value-of select="result/data_amount"/><![CDATA[;
73
 
        var start_slider_max = ]]><xsl:value-of select="result/start_slider_max"/><![CDATA[;
74
 
        
75
 
        //if the user clicks outside the bounds of the graph's background image set the position at the edge of the image
76
 
        if(pos_x < 0) pos_x = 0;
77
 
        if(pos_x > g_width - (50 + 20)) pos_x = (g_width - (50 + 20));
78
 
        
79
 
        var zoom = ]]><xsl:value-of select="result/zoom"/><![CDATA[;
80
 
        
81
 
        var slice_amount = (180 - (zoom * 30));//calculate the amount of slices
82
 
        var slice_width = (g_width - (50 + 20)) / slice_amount;//calculate the width of the slices
83
 
        
84
 
        var start = ]]><xsl:value-of select="result/start"/><![CDATA[;
85
 
        
86
 
        var id = Math.floor(pos_x / slice_width) + (Math.floor(data_amount/start_slider_max) * (start - 1));//determine the id of the clicked slice
87
 
        
88
 
        adei.SetCustomProperties("pic_id=" + id);
89
 
 
90
 
    }
91
 
 
92
 
    //when the secondary image has been loaded, we adjust the slider values based on what was returned by the service as XML
93
 
    $("#image2").ready(function ()
94
 
    {
95
 
        var startValue = ]]><xsl:value-of select="result/start"/><![CDATA[;
96
 
        var zoomValue = ]]><xsl:value-of select="result/zoom"/><![CDATA[;
97
 
        
98
 
        $("#start_slider").slider("option", "value", startValue);
99
 
        $("#zoom_slider").slider("option", "value", zoomValue);
100
 
    });
101
 
    
102
 
    
103
 
    //function to change the service based on the calling button's value
104
 
    
105
 
    function ChangeService(event)
106
 
    {
107
 
        var target = (event.currentTarget.value);
108
 
        adei.SetCustomProperties("image_target=" + target);
109
 
    }
110
 
    
111
 
    ]]>
112
 
    </script>
113
 
    <!--Module start-->
114
 
    <div id="page_wrapper_div">
115
 
        <div id="upper_wrapper_div">
116
 
            <div id="image_zoom_wrapper_div">
117
 
                <div id="image_div">
118
 
                    <!--main image-->
119
 
                    <img id="image" src="{result/image}" alt="Loading..." onmousedown="javascript:GetMouseX(event);"></img>
120
 
                </div>
121
 
                <div id="zoom_wrapper_div">
122
 
                    <div id="zoom_slider"></div>
123
 
                </div>
124
 
            </div>
125
 
            <div id="start_wrapper_div">
126
 
                <div id="start_slider"></div>
127
 
            </div>
128
 
        </div>
129
 
        <div id="lower_wrapper_div">
130
 
            <!--secondary image-->
131
 
            <img id="image2" src="{result/image2}" alt="Loading..."></img>
132
 
        </div>
133
 
        <button value="cloud" onclick="javascript:ChangeService(event);">Clouds</button>
134
 
        <button value="ceilo" onclick="javascript:ChangeService(event);">Ceilometer</button>
135
 
        <button value="temp" onclick="javascript:ChangeService(event);">Temperature</button>
136
 
    </div>
137
 
   <!--Module end-->
138
 
 </xsl:template>
139
 
</xsl:stylesheet>
 
 
b'\\ No newline at end of file'