Move HTML files into admin/ directory
[infodrom/musiikki-web.git] / html / admin / 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.');
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_admin() {
75     $.post('index.php',
76            'action=admin&' + $('div.w3-container#admin form').serialize());
77     response('Admin-Passwort neu gesetzt.<br>Sie müssen sich erneut anmelden.');
78
79     return false;
80 }
81
82 function submit_halt() {
83     $.post('index.php',
84            'action=halt',
85            function(data){
86                if (data)
87                    response('Der Server kann jetzt vom Strom getrennt und eingepackt werden.', true);
88            });
89
90     return false;
91 }
92
93 $(function(){
94     $('div.w3-container').hide();
95     $('div.w3-container#home').show();
96 });