-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
148 lines (142 loc) · 4.44 KB
/
test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<script type="text/javascript" src="https://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="jquery.ete.js"></script>
<script type="text/javascript">
$(document).ready(function(){
//1. E.T. call - template is not cached yet...
var templ = $('script#template').ete({
callback: function(sel, template){
return($('#firstTarget').replaceWith(template));
},
data: {
caption: '1. Space-Taxi Α-Centauri Timetable (1.1.1982):',
th: ['Space-Taxi','Neptun','Uranus','Saturn','Jupiter','Earth'],
table: [
['Alan',6,'','','',22],
['Ida',12,15,'17:30',18,20],
['Enterprise',8,'9:30','10:30',11,12],
['Clingonian spaceship',16,'17:30','',19,null]
]
}
});
//2. E.T. call - load template from cache and feed with different data...
$('script#template').ete({
callback: function(sel, template){ $('#secondTarget').append(template); },
data: {
caption:'2. Space-Taxi Timetable (2.1.1982):',
th: ['Space-Taxi','Neptun','Uranus','Saturn','Jupiter','Earth'],
table: [
['Alan',3,'','','',19],
['Ida',12,15,'17:30',18,20],
['Enterprise',8,'9:30','10:30',11,12]
]
}
});
//3. E.T. call - do not cache compiled template...
$('#thirdTarget').ete({
cache: false,
data: {
colorOdd: 'red',
colorEven: 'green',
caption: '3. Space-Taxi Timetable (3.1.1982):',
th: ['Space-Taxi','Neptun','Uranus','Saturn','Jupiter','Earth'],
table: [
['Alan',6,'','','',22],
['Ida',12,15,'17:30',18,20],
['Enterprise',8,'9:30','10:30',11,12],
['Clingonian spaceship',16,'17:30','',19,null]
]
}
});
});
</script>
</head>
<body style="background:url(./et.jpg);background-attachment:fixed;background-repeat: no-repeat;">
<script type="application/ete" id="template">
<h2>
<%= data['caption']; %>
</h2>
<div>
<table>
<thead>
<tr>
<th>#</th>
<% for(var i = 0; i < data['th'].length; ++i){ %>
<th><b><%= data['th'][i] %></b></th>
<% } %>
</tr>
</thead>
<tbody>
<%# Any kind of embedded javascript is possible... %>
<% for(var i = 0; i < data['table'].length; ++i){ %>
<tr>
<td><%= (i+1); %></td>
<% for(var j = 0; j < data['table'][i].length; ++j){ %>
<td>
<% if(data['table'][i][j] && data['table'][i][j] != ''){
<%= data['table'][i][j]; %>
<% }else{ %>
<b>Stop on request</b>
<% } %>
</td>
<% } %>
</tr>
<% } %>
</tbody>
</table>
</div>
</script>
<p id="firstTarget"></p>
<p id="secondTarget"></p>
<script type="application/ete" id="thirdTarget">
<div>
<h2><%= data['caption']; %></h2>
<div>
<table>
<thead>
<tr>
<th>#</th>
<% for(var i = 0; i < data['th'].length; ++i){ %>
<th><b><%= data['th'][i] %></b></th>
<% } %>
</tr>
</thead>
<tbody>
<% for(var i = 0; i < data['table'].length; ++i){ %>
<% if((i+1) % 2 == 0){ //Red color for every 2nd line...%>
<tr style="color:#%= data.colorEven; %#">
<td> <%= (i+1); %></td>
<% for(var j = 0; j < data['table'][i].length; ++j){ %>
<td>
<% if(data['table'][i][j] && data['table'][i][j] != ''){
template += data['table'][i][j];
}else{ %>
<b>Stop on request</b>
<% } %>
</td>
<% } %>
</tr>
<%}else{ %>
<tr style="color:#%= data.colorOdd; %#">
<td><%= (i+1); %></td>
<% for(var j = 0; j < data['table'][i].length; ++j){ %>
<td>
<% if(data['table'][i][j] && data['table'][i][j] != ''){
template += data['table'][i][j];
}else{ %>
<b>Stop on request</b>
<% } %>
</td>
<% } %>
</tr>
<% } %>
<% } %>
</tbody>
</table>
</div>
</div>
</script>
</body>
</html>