Rename admin to passwd, and index to admin
[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_rescan() {
75     $.post('index.php',
76            'action=rescan',
77            function(data){
78                if (data) {
79                    if (data.info)
80                        response(data.info);
81                    else
82                        response('Rescan wurde getriggert.<br>Die Medienliste wird neu aufgebaut.');
83                }
84            });
85
86     return false;
87 }
88
89 function submit_passwd() {
90     $.post('index.php',
91            'action=passwd&' + $('div.w3-container#passwd form').serialize());
92     response('Admin-Passwort neu gesetzt.<br>Sie müssen sich erneut anmelden.');
93
94     return false;
95 }
96
97 function submit_halt() {
98     $.post('index.php',
99            'action=halt',
100            function(data){
101                if (data)
102                    response('Der Server kann jetzt vom Strom getrennt und eingepackt werden.', true);
103            });
104
105     return false;
106 }
107
108 $(function(){
109     $('div.w3-container').hide();
110     $('div.w3-container#home').show();
111 });