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'; |
47a970
|
6 |
var templateCache = {}; // mustache templates 'home', 'prefs', 'sender' |
623a61
|
7 |
var prefsRendered = false; |
U |
8 |
|
|
9 |
function app_init() { |
9f0d54
|
10 |
$('.dialog').hide(); |
623a61
|
11 |
$('.ost').hide(); |
851c9c
|
12 |
app_menu_init("menu/", "hauptmenue.json", "../jslib/app-menu/app-menu.tpl", ".west"); |
9e336a
|
13 |
app_get_template('tpl/dlg-msg.tpl', TPL_DLG_MSG); |
36646e
|
14 |
app_get_template('tpl/dlg-info.tpl', TPL_DLG_INFO); |
47a970
|
15 |
app_get_template('tpl/sender.tpl', TPL_SENDER); |
623a61
|
16 |
//app_get_template('tpl/prefs.tpl', 'prefs'); |
U |
17 |
$('.sued').text('Bereit.'); |
|
18 |
setTimeout(function() { |
a480d0
|
19 |
app_get_sender(); |
623a61
|
20 |
}, 200); |
47a970
|
21 |
} |
U |
22 |
|
9f0d54
|
23 |
function app_nachricht_test() { |
36646e
|
24 |
app_nachricht_zeigen(templateCache[TPL_DLG_MSG], 'data/msg-test.json'); |
U |
25 |
} |
|
26 |
|
|
27 |
function app_info_dialog_zeigen() { |
|
28 |
app_nachricht_zeigen(templateCache[TPL_DLG_INFO], ''); |
9f0d54
|
29 |
} |
U |
30 |
|
47a970
|
31 |
/* --- Ajax-Aufrufe --- */ |
U |
32 |
|
a480d0
|
33 |
function app_get_sender() { |
U |
34 |
$.ajax({ |
0c85a2
|
35 |
url: "data/sender.json", |
a480d0
|
36 |
type: "GET", |
U |
37 |
dataType : "json" |
|
38 |
}).done(function( senderliste ) { |
21dcfa
|
39 |
$(".sender-behaelter").html(Mustache.render(templateCache[TPL_SENDER], senderliste)); |
a480d0
|
40 |
}); |
U |
41 |
} |
|
42 |
|
36646e
|
43 |
function app_nachricht_zeigen(vorlage, adresse) { |
U |
44 |
if(adresse !== '') { |
|
45 |
$.ajax({ |
|
46 |
url: adresse, |
|
47 |
type: "GET", |
|
48 |
dataType : "json" |
|
49 |
}).done(function( msg ) { |
|
50 |
$(".dialog").html(Mustache.render(vorlage, msg)); |
|
51 |
$(".close-btn").on('click', function() { |
|
52 |
$('.close-btn').attr('onclick','').unbind('click'); |
|
53 |
$('.dialog').slideUp(300); |
|
54 |
}); |
|
55 |
$('.dialog').slideDown(300); |
|
56 |
}); |
|
57 |
} else { |
|
58 |
$(".dialog").html(Mustache.render(vorlage, '')); |
9e336a
|
59 |
$(".close-btn").on('click', function() { |
U |
60 |
$('.close-btn').attr('onclick','').unbind('click'); |
|
61 |
$('.dialog').slideUp(300); |
|
62 |
}); |
|
63 |
$('.dialog').slideDown(300); |
36646e
|
64 |
} |
9e336a
|
65 |
} |
U |
66 |
|
47a970
|
67 |
/* |
U |
68 |
Ein Template vom Server in den Cache laden |
|
69 |
template_url - home.tpl, prefs.tpl, sender.tpl |
|
70 |
tname - 'home', 'prefs', 'sender' |
|
71 |
*/ |
|
72 |
function app_get_template(template_url, tname) { |
|
73 |
$.ajax({ |
|
74 |
url: template_url, |
|
75 |
type: "GET", |
|
76 |
dataType : "text" |
|
77 |
}).done(function( template ) { |
|
78 |
templateCache[tname] = template; |
|
79 |
}); |
623a61
|
80 |
} |