e22475b47ff36800832c48ec9cc113e3ed79a9a7
[infodrom/musiikki-web.git] / html / musiikki.js
1 // Script to open and close sidebar
2 function w3_open()
3 {
4     $('#mySidebar').css('display', 'block');
5     $('#myOverlay').css('display', 'block');
6 }
7
8 function w3_close()
9 {
10     $('#mySidebar').hide();
11     $('#myOverlay').hide();
12 }
13
14 function open_page(page) {
15     w3_close();
16     $('div.w3-container').hide();
17
18     if ($('div.w3-container#'+page + ' form').length)
19         $.post('index.php',
20                'action=get'+page,
21                function(data){
22                    if (typeof data == 'object') {
23                        for (name in data) {
24                            obj = $('div.w3-container#'+page + ' [name="'+name+'"]');
25                            if (obj.length)
26                                obj.val(data[name]);
27                        }
28                    }
29                });
30     $('div.w3-container#'+page).show();
31 }
32
33 function response(text, stay)
34 {
35     $('div.w3-container').hide();
36     $('div.w3-container#response #msg').html(text);
37     $('div.w3-container#response').show();
38     if (!stay)
39         setTimeout(function(){
40             open_page('home');
41         }, 5000);
42 }
43
44 $(function(){
45     $('div.w3-container').hide();
46     $('div.w3-container#home').show();
47 });