Bedienoberfläche für Webradio
..
ulrich
2018-01-04 0c85a2e4e25b4e921514e179391e2d7465dcb84c
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';
47a970 5 var templateCache = {}; // mustache templates 'home', 'prefs', 'sender'
623a61 6 var prefsRendered = false;
U 7
8 function app_init() {
9f0d54 9   $('.dialog').hide();
623a61 10   $('.ost').hide();
851c9c 11   app_menu_init("menu/", "hauptmenue.json", "../jslib/app-menu/app-menu.tpl", ".west");
9e336a 12   app_get_template('tpl/dlg-msg.tpl', TPL_DLG_MSG);
47a970 13   app_get_template('tpl/sender.tpl', TPL_SENDER);
623a61 14   //app_get_template('tpl/prefs.tpl', 'prefs');
U 15   $('.sued').text('Bereit.');
16   setTimeout(function() {
a480d0 17     app_get_sender();
623a61 18   }, 200);
47a970 19 }
U 20
9f0d54 21 function app_nachricht_test() {
0c85a2 22   app_nachricht_zeigen('data/msg-test.json');
9f0d54 23 }
U 24
47a970 25 /* --- Ajax-Aufrufe --- */
U 26
a480d0 27 function app_get_sender() {
U 28   $.ajax({
0c85a2 29     url: "data/sender.json",
a480d0 30     type: "GET",
U 31     dataType : "json"
32   }).done(function( senderliste ) {
33     $("#sender").html(Mustache.render(templateCache[TPL_SENDER], senderliste));
34   });
35 }
36
0c85a2 37 function app_nachricht_zeigen(addr) {
9e336a 38   $.ajax({
U 39     url: addr,
40     type: "GET",
41     dataType : "json"
42   }).done(function( msg ) {
43     $(".dialog").html(Mustache.render(templateCache[TPL_DLG_MSG], msg));
44     $(".close-btn").on('click', function() {
45       $('.close-btn').attr('onclick','').unbind('click');
46       $('.dialog').slideUp(300);
47     });
48     $('.dialog').slideDown(300);
49   });
50 }
51
47a970 52 /*
U 53   Ein Template vom Server in den Cache laden
54   template_url - home.tpl, prefs.tpl, sender.tpl
55   tname - 'home', 'prefs', 'sender'
56 */
57 function app_get_template(template_url, tname) {
58   $.ajax({
59     url: template_url,
60     type: "GET",
61     dataType : "text"
62   }).done(function( template ) {
63     templateCache[tname] = template;
64   });
623a61 65 }