Statistics
| Branch: | Tag: | Revision:

root / snf-app / synnefo / helpdesk / templates / helpdesk.html @ 483c9197

History | View | Annotate | Download (4.5 kB)

1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2
        "http://www.w3.org/TR/html4/loose.dtd">
3
<html>
4
<head>
5
    <title>Σύννεφο -- Εφαρμογή HelpDesk</title>
6
    <script src="/static/jquery.tools.min.js"></script>
7
    <script src="/static/jquery.cookie.js"></script>
8
    
9
    <style>
10
        body, html {height: 99%;}
11
        iframe     {display:block; width:100%; border:none; height: 90%}
12
        .center    {text-align: center;}
13
        .header    {height: 10%;}
14
    </style>
15

    
16
    <script type="text/javascript">
17

18
        jQuery.fn.countdown = function(options) {
19

20
            if(!options) options = '()';
21
            if(jQuery(this).length == 0) return false;
22
            var obj = this;
23

24
            if(options.seconds < 0 || options.seconds == 'undefined') {
25
                if(options.callback) eval(options.callback);
26
                return null;
27
            }
28

29
            window.setTimeout(
30
                function() {
31
                    jQuery(obj).html(String(options.seconds));
32
                    --options.seconds;
33
                    jQuery(obj).countdown(options);
34
                }
35
                , 1000
36
            );
37

38
            return this;
39
        }
40

41
        jQuery.fn.countdown.stop = function() {
42
                window.clearTimeout(setTimeout("0")-1);
43
        }
44

45
        function setCookie(name, value, expires, path, domain, secure) {
46
            var expires_date = new Date( expires * 1000 );
47

48
            document.cookie = name + "=" +escape(value) +
49
                (( expires ) ? ";expires=" + expires_date.toGMTString() : "") +
50
                (( path ) ? ";path=" + path : "") +
51
                (( domain ) ? ";domain=" + domain : "") +
52
                (( secure ) ? ";secure" : "");
53
        }
54

55
        function delCookie(name) {
56
            document.cookie = name + '=foo; expires=Fri, 27 Jul 2001 02:47:11 UTC; path=/';
57
        }
58

59
        $(document).ready(function() {
60

61
            delCookie('X-Auth-Tmp-Token');
62

63
            $("#username").change(function() {
64
                if ($("#username").val() != '') {
65
                    $("#go").removeAttr("disabled");
66
                } else {
67
                    $("#go").attr('disabled', 'disabled');
68
                }
69
            });
70

71
            $("#go").click(function() {
72

73
                var val = $('#username').val();
74
                if (val == '')
75
                    return;
76

77
                $.ajax({
78
                    url:  '/helpdesk/token',
79
                    data: {user_id: $("#username").val()},
80
                    type: 'GET',
81
                    dataType: 'json',
82
                    success: function(data) {
83
                        $('#remtime').countdown.stop();
84
                        $('#countdown').css('display', 'block');
85

86
                        var secs = data.expires - parseInt((new Date()).getTime() / 1000);
87

88
                        $('#remtime').countdown({seconds: secs,
89
                            callback: function(){
90
                                alert('Το token του χρήστη έληξε')
91
                            }});
92

93
                        setCookie('X-Auth-Tmp-Token', data.token, data.expires, '/', '', false);
94

95
                        $('#content').attr('src', '/');
96
                    },
97
                    error : function(xhr, textStatus, errorThrown) {
98
                        alert(errorThrown)
99
                    }
100
                });
101
            });
102

103
            $("#clear").click(function(){
104
                delCookie('X-Auth-Tmp-Token');
105
                $($('#username option').get(0)).attr('selected', 'selected')
106
                $('#remtime').countdown.stop();
107
                $('#countdown').css('display', 'none');
108
                $('#go').attr('disabled', 'disabled');
109
                $('#content').attr('src', '/');
110
            });
111
        });
112

    
113
    </script>
114
</head>
115

    
116
<body>
117

    
118
<div id="header" class="center">
119
    Επιλέξτε το όνομα του χρήστη:
120
    <select id="username">
121
            <option value="">--Επιλογή--</option>
122
         {% for user in users %}
123
             <option value="{{ user.id }}">{{ user.name }}</option>
124
         {% endfor %}
125
    </select>
126
    <input id="go" type="button" value="Go" disabled="true"/>
127
    <input id="clear" type="button" value="Clear"/>
128
    <div id="countdown" style="display:none">
129
        <span id="remtime"> </span><span> δευτερόλεπτα πριν το token λήξει</span>
130
    </div>
131
</div>
132

    
133
<iframe id="content" src="/" class="center frame">
134
    <p>
135
        Your browser does not support iframes.
136
        Use a current millenium browser.
137
    </p>
138
</iframe>
139

    
140
</body>
141
</html>