Finish framework, include W3.css build web site via templates and jQuery
[infodrom/musiikki-web.git] / html / musiikki.js
index e69de29..14d61e5 100644 (file)
@@ -0,0 +1,88 @@
+// Script to open and close sidebar
+function w3_open()
+{
+    $('#mySidebar').css('display', 'block');
+    $('#myOverlay').css('display', 'block');
+}
+
+function w3_close()
+{
+    $('#mySidebar').hide();
+    $('#myOverlay').hide();
+}
+
+function open_page(page) {
+    w3_close();
+    $('div.w3-container').hide();
+
+    if ($('div.w3-container#'+page + ' form').length)
+       $.post('index.php',
+              'action=get'+page,
+              function(data){
+                  if (typeof data == 'object') {
+                      for (name in data) {
+                          obj = $('div.w3-container#'+page + ' [name="'+name+'"]');
+                          if (obj.length)
+                              obj.val(data[name]);
+                      }
+                  }
+              });
+    $('div.w3-container#'+page).show();
+}
+
+function response(text, stay)
+{
+    $('div.w3-container').hide();
+    $('div.w3-container#response #msg').html(text);
+    $('div.w3-container#response').show();
+    if (!stay)
+       setTimeout(function(){
+           open_page('home');
+       }, 5000);
+}
+
+function submit_datetime() {
+    $.post('index.php',
+          'action=datetime&' + $('div.w3-container#datetime form').serialize(),
+          function(data){
+              if (data)
+                  response('Aktuelle Uhrzeit und Datum gesetzt');
+          });
+
+    return false;
+}
+
+function submit_wifi() {
+    $.post('index.php',
+          'action=wifi&' + $('div.w3-container#wifi form').serialize());
+    response('WLAN neu konfiguriert.<br>Sie müssen sich mit neuem Paßwort im WLAN anmelden.', true);
+
+    return false;
+}
+
+function submit_shares() {
+    $.post('index.php',
+          'action=shares&' + $('div.w3-container#shares form').serialize(),
+          function(data){
+              if (data)
+                  response('Passwörter für die Netzwerk-Laufwerke gesetzt');
+          });
+
+    return false;
+}
+
+function submit_halt() {
+    $.post('index.php',
+          'action=halt',
+          function(data){
+              if (data)
+                  response('Der Server kann jetzt vom Strom getrennt und eingepackt werden.', true);
+          });
+
+    return false;
+}
+
+$(function(){
+    $('div.w3-container').hide();
+    $('div.w3-container#home').show();
+});