From e8a09794c48a6496c6d0d0fb14d35d7a8246d299 Mon Sep 17 00:00:00 2001
From: ulrich <not disclosed>
Date: Thu, 04 Jan 2018 11:10:04 +0000
Subject: [PATCH] Doku ergänzt

---
 app.js |   56 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 53 insertions(+), 3 deletions(-)

diff --git a/app.js b/app.js
index 1d258d7..2c6bd4d 100644
--- a/app.js
+++ b/app.js
@@ -1,22 +1,72 @@
 var TPL_HOME = 'home';
 var TPL_PREFS = 'prefs';
 var TPL_SENDER = 'sender';
+var TPL_DLG_MSG = 'dlg-msg';
+var TPL_DLG_INFO = 'dlg-info';
 var templateCache = {}; // mustache templates 'home', 'prefs', 'sender'
 var prefsRendered = false;
 
 function app_init() {
+  $('.dialog').hide();
   $('.ost').hide();
-  app_menu_init("menu/", "hauptmenue.json", "../jslib/app-menu/app-menu.tpl", ".west");
-  app_get_template('tpl/sender.tpl', TPL_SENDER);
+  app_menu_init("data/menu/", "hauptmenue.json", "../jslib/app-menu/app-menu.tpl", ".west");
+  app_get_template('data/tpl/dlg-msg.tpl', TPL_DLG_MSG);
+  app_get_template('data/tpl/dlg-info.tpl', TPL_DLG_INFO);
+  app_get_template('data/tpl/sender.tpl', TPL_SENDER);
   //app_get_template('tpl/prefs.tpl', 'prefs');
   $('.sued').text('Bereit.');
   setTimeout(function() {
-    $("#sender").html(Mustache.render(templateCache[TPL_SENDER], ''));
+    app_get_sender();
   }, 200);
 }
 
+/* --- Menüfunktionen --- */
+
+function app_nachricht_test() {
+  app_nachricht_zeigen(templateCache[TPL_DLG_MSG], 'data/msg-test.json');
+}
+
+function app_info_dialog_zeigen() {
+  app_nachricht_zeigen(templateCache[TPL_DLG_INFO], '');
+}
+
+/* --- Sonstiges --- */
+
+function app_dialog_zeigen(vorlage, inhalt) {
+  $(".dialog").html(Mustache.render(vorlage, inhalt));
+  $(".close-btn").on('click', function() {
+    $('.close-btn').attr('onclick','').unbind('click');
+    $('.dialog').slideUp(300);
+  });
+  $('.dialog').slideDown(300);
+}
+
 /* --- Ajax-Aufrufe --- */
 
+function app_get_sender() {
+  $.ajax({
+    url: "data/sender.json",
+    type: "GET",
+    dataType : "json"
+  }).done(function( senderliste ) {
+    $(".sender-behaelter").html(Mustache.render(templateCache[TPL_SENDER], senderliste));
+  });
+}
+
+function app_nachricht_zeigen(vorlage, adresse) {
+  if(adresse !== '') {
+    $.ajax({
+      url: adresse,
+      type: "GET",
+      dataType : "json"
+    }).done(function( msg ) {
+      app_dialog_zeigen(vorlage, msg);
+    });
+  } else {
+    app_dialog_zeigen(vorlage, '');
+  }
+}
+
 /*
   Ein Template vom Server in den Cache laden
   template_url - home.tpl, prefs.tpl, sender.tpl

--
Gitblit v1.9.3