From b520d14fa174b912c319cd245edae6620147977a Mon Sep 17 00:00:00 2001 From: ulrich <not disclosed> Date: Fri, 05 Jan 2018 10:48:56 +0000 Subject: [PATCH] Speichern als Dummy in Arbeit --- app.js | 78 ++++++++++++++++++++++++++++++--------- 1 files changed, 60 insertions(+), 18 deletions(-) diff --git a/app.js b/app.js index 6d38c15..178ee3f 100644 --- a/app.js +++ b/app.js @@ -2,15 +2,19 @@ var TPL_PREFS = 'prefs'; var TPL_SENDER = 'sender'; var TPL_DLG_MSG = 'dlg-msg'; +var TPL_DLG_INFO = 'dlg-info'; +var TPL_DLG_SENDER = 'dlg-sender'; 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/dlg-msg.tpl', TPL_DLG_MSG); - 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('data/tpl/dlg-sender-edit.tpl', TPL_DLG_SENDER); //app_get_template('tpl/prefs.tpl', 'prefs'); $('.sued').text('Bereit.'); setTimeout(function() { @@ -18,35 +22,73 @@ }, 200); } +/* --- Menüfunktionen --- */ + function app_nachricht_test() { - app_get_nachricht('api/msg-test.json'); + app_dialog_laden_und_zeigen(templateCache[TPL_DLG_MSG], 'data/msg-test.json'); +} + +function app_info_dialog_zeigen() { + app_dialog_laden_und_zeigen(templateCache[TPL_DLG_INFO], ''); +} + +function app_neuer_sender() { + app_dialog_laden_und_zeigen(templateCache[TPL_DLG_SENDER], ''); + $('#sender-speichern').on('click', function() { + $('#sender-speichern').attr('onclick','').unbind('click'); + app_dialog_schliessen(); + $('.sued').text('Speichern gewaehlt'); + setTimeout(function() { + $('.sued').text('Bereit.'); + }, 1500); + }); + app_menu_toggle(); +} + + +/* --- Sonstiges --- */ + +function app_dialog_zeigen(vorlage, inhalt) { + $(".dialog").html(Mustache.render(vorlage, inhalt)); + $(".close-btn").on('click', function() { + app_dialog_schliessen(); + /* + $('.close-btn').attr('onclick','').unbind('click'); + $('.dialog').slideUp(300); + */ + }); + $('.dialog').slideDown(300); +} + +function app_dialog_schliessen() { + $('.close-btn').attr('onclick','').unbind('click'); + $('.dialog').slideUp(300); } /* --- Ajax-Aufrufe --- */ function app_get_sender() { $.ajax({ - url: "api/sender.json", + url: "data/sender.json", type: "GET", dataType : "json" }).done(function( senderliste ) { - $("#sender").html(Mustache.render(templateCache[TPL_SENDER], senderliste)); + $(".sender-behaelter").html(Mustache.render(templateCache[TPL_SENDER], senderliste)); }); } -function app_get_nachricht(addr) { - $.ajax({ - url: addr, - type: "GET", - dataType : "json" - }).done(function( msg ) { - $(".dialog").html(Mustache.render(templateCache[TPL_DLG_MSG], msg)); - $(".close-btn").on('click', function() { - $('.close-btn').attr('onclick','').unbind('click'); - $('.dialog').slideUp(300); +function app_dialog_laden_und_zeigen(vorlage, adresse) { + if(adresse !== '') { + $.ajax({ + url: adresse, + type: "GET", + dataType : "json" + }).done(function( msg ) { + app_dialog_zeigen(vorlage, msg); }); - $('.dialog').slideDown(300); - }); + } else { + app_dialog_zeigen(vorlage, ''); + } } /* -- Gitblit v1.9.3