Finish framework, include W3.css build web site via templates and jQuery
[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 submit_datetime() {
45     $.post('index.php',
46            'action=datetime&' + $('div.w3-container#datetime form').serialize(),
47            function(data){
48                if (data)
49                    response('Aktuelle Uhrzeit und Datum gesetzt');
50            });
51
52     return false;
53 }
54
55 function submit_wifi() {
56     $.post('index.php',
57            'action=wifi&' + $('div.w3-container#wifi form').serialize());
58     response('WLAN neu konfiguriert.<br>Sie müssen sich mit neuem Paßwort im WLAN anmelden.', true);
59
60     return false;
61 }
62
63 function submit_shares() {
64     $.post('index.php',
65            'action=shares&' + $('div.w3-container#shares form').serialize(),
66            function(data){
67                if (data)
68                    response('Passwörter für die Netzwerk-Laufwerke gesetzt');
69            });
70
71     return false;
72 }
73
74 function submit_halt() {
75     $.post('index.php',
76            'action=halt',
77            function(data){
78                if (data)
79                    response('Der Server kann jetzt vom Strom getrennt und eingepackt werden.', true);
80            });
81
82     return false;
83 }
84
85 $(function(){
86     $('div.w3-container').hide();
87     $('div.w3-container#home').show();
88 });