Bedienoberfläche für Webradio
ulrich
2018-01-04 5226a2e67c7dec0fa19e9adafb6dd6f95b0a364d
commit | author | age
623a61 1 var TPL_HOME = 'home';
U 2 var TPL_PREFS = 'prefs';
47a970 3 var TPL_SENDER = 'sender';
9e336a 4 var TPL_DLG_MSG = 'dlg-msg';
36646e 5 var TPL_DLG_INFO = 'dlg-info';
5226a2 6 var TPL_DLG_SENDER = 'dlg-sender';
47a970 7 var templateCache = {}; // mustache templates 'home', 'prefs', 'sender'
623a61 8 var prefsRendered = false;
U 9
10 function app_init() {
9f0d54 11   $('.dialog').hide();
623a61 12   $('.ost').hide();
ec55bf 13   app_menu_init("data/menu/", "hauptmenue.json", "../jslib/app-menu/app-menu.tpl", ".west");
8881ca 14   app_get_template('data/tpl/dlg-msg.tpl', TPL_DLG_MSG);
U 15   app_get_template('data/tpl/dlg-info.tpl', TPL_DLG_INFO);
16   app_get_template('data/tpl/sender.tpl', TPL_SENDER);
5226a2 17   app_get_template('data/tpl/dlg-sender-edit.tpl', TPL_DLG_SENDER);
623a61 18   //app_get_template('tpl/prefs.tpl', 'prefs');
U 19   $('.sued').text('Bereit.');
20   setTimeout(function() {
a480d0 21     app_get_sender();
623a61 22   }, 200);
47a970 23 }
U 24
8881ca 25 /* --- Menüfunktionen --- */
U 26
9f0d54 27 function app_nachricht_test() {
36646e 28   app_nachricht_zeigen(templateCache[TPL_DLG_MSG], 'data/msg-test.json');
U 29 }
30
31 function app_info_dialog_zeigen() {
32   app_nachricht_zeigen(templateCache[TPL_DLG_INFO], '');
8881ca 33 }
U 34
5226a2 35 function app_neuer_sender() {
U 36   app_nachricht_zeigen(templateCache[TPL_DLG_SENDER], '');
37 }
38
39
8881ca 40 /* --- Sonstiges --- */
U 41
42 function app_dialog_zeigen(vorlage, inhalt) {
43   $(".dialog").html(Mustache.render(vorlage, inhalt));
44   $(".close-btn").on('click', function() {
45     $('.close-btn').attr('onclick','').unbind('click');
46     $('.dialog').slideUp(300);
47   });
48   $('.dialog').slideDown(300);
9f0d54 49 }
U 50
47a970 51 /* --- Ajax-Aufrufe --- */
U 52
a480d0 53 function app_get_sender() {
U 54   $.ajax({
0c85a2 55     url: "data/sender.json",
a480d0 56     type: "GET",
U 57     dataType : "json"
58   }).done(function( senderliste ) {
21dcfa 59     $(".sender-behaelter").html(Mustache.render(templateCache[TPL_SENDER], senderliste));
a480d0 60   });
U 61 }
62
36646e 63 function app_nachricht_zeigen(vorlage, adresse) {
U 64   if(adresse !== '') {
65     $.ajax({
66       url: adresse,
67       type: "GET",
68       dataType : "json"
69     }).done(function( msg ) {
8881ca 70       app_dialog_zeigen(vorlage, msg);
36646e 71     });
U 72   } else {
8881ca 73     app_dialog_zeigen(vorlage, '');
36646e 74   }
9e336a 75 }
U 76
47a970 77 /*
U 78   Ein Template vom Server in den Cache laden
79   template_url - home.tpl, prefs.tpl, sender.tpl
80   tname - 'home', 'prefs', 'sender'
81 */
82 function app_get_template(template_url, tname) {
83   $.ajax({
84     url: template_url,
85     type: "GET",
86     dataType : "text"
87   }).done(function( template ) {
88     templateCache[tname] = template;
89   });
623a61 90 }