]>
Commit | Line | Data |
---|---|---|
61caacda | 1 | local skel_1 = [[ |
2 | <html> | |
3 | <head> | |
4 | <style> | |
5 | * { | |
6 | background-color: #2F3440; | |
7 | background-color:#232323; | |
8 | color : #F5E5C0; | |
9 | text-transform: uppercase; | |
10 | font-size: 1.05em; | |
11 | font-family: monospace,Arial; | |
12 | } | |
13 | table{ | |
14 | float:left; | |
15 | border: 1px solid white; | |
16 | } | |
57d38400 | 17 | td{ |
18 | empty-cells : show; | |
19 | } | |
61caacda | 20 | td.blockzero { |
21 | color: rgb(140, 245, 193); | |
22 | } | |
23 | td.key_a{ | |
24 | color : #F8CA4D; | |
25 | } | |
26 | td.key_b{ | |
27 | color : #3F5666; | |
28 | } | |
29 | td.accessconditions{ | |
30 | color : #EA6045; | |
31 | } | |
32 | ||
33 | td.sectorhdr{ | |
34 | border-top: 1px solid white; | |
35 | } | |
36 | </style> | |
37 | <script> | |
38 | function dc(x){return document.createElement(x)} | |
39 | ||
40 | function addClass(el, line, byte) | |
41 | { | |
42 | if (line == 0) | |
43 | { | |
44 | el.className += " blockzero"; | |
45 | } | |
46 | ||
47 | if(line < 128){ | |
48 | linesPerSector = 4; | |
49 | }else | |
50 | { | |
51 | //Quadruple size sectors | |
52 | linesPerSector = 16; | |
53 | line = line - 128; | |
54 | ||
55 | } | |
56 | ||
57 | if(line % linesPerSector == 0) | |
58 | { | |
59 | el.className += " sectorhdr"; | |
60 | } | |
61 | if(line % linesPerSector == (linesPerSector -1)) | |
62 | { | |
63 | el.className += " sectortrailer"; | |
64 | if(byte == undefined) | |
65 | { | |
66 | return; | |
67 | } | |
68 | ||
69 | if(byte < 6) el.className += " key_a"; | |
57d38400 | 70 | else if(byte < 10) el.className += " accessconditions"; |
61caacda | 71 | else el.className += " key_b"; |
72 | } | |
73 | ||
74 | } | |
75 | ||
76 | ||
77 | function loadMifare(data) | |
78 | { | |
79 | var data = data.data; | |
80 | var t = dc("table") | |
81 | for(var i = 0 ; i < data.length ; i++) | |
82 | { | |
83 | line = data[i]; | |
84 | var tr = dc("tr"); | |
85 | t.appendChild(tr); | |
86 | addClass(tr,i); | |
87 | var bytes = line.match(/(.{1,2})/g); | |
88 | for(var b = 0 ; b < bytes.length ; b++) | |
89 | { | |
90 | var td = dc('td'); | |
91 | tr.appendChild(td); | |
92 | td.appendChild(document.createTextNode(bytes[b])); | |
93 | addClass(td,i,b); | |
94 | } | |
95 | } | |
96 | document.body.appendChild(t); | |
97 | } | |
98 | function to_ascii(hexval) | |
99 | { | |
100 | var intval = parseInt(hexval,16); | |
101 | if(intval > 31 && intval < 127) | |
102 | { | |
103 | return String.fromCharCode(intval); | |
104 | } | |
105 | return "."; | |
106 | } | |
107 | ||
108 | function loadAscii(data) | |
109 | { | |
110 | var data = data.data; | |
111 | var t = dc("table") | |
112 | for(var i = 0 ; i < data.length ; i++) | |
113 | { | |
114 | line = data[i]; | |
115 | var tr = dc("tr"); | |
116 | t.appendChild(tr); | |
117 | var bytes = line.match(/(.{1,2})/g); | |
118 | for(var b = 0 ; b < bytes.length ; b++) | |
119 | { | |
120 | var td = dc('td'); | |
121 | tr.appendChild(td); | |
122 | td.appendChild(document.createTextNode(to_ascii(bytes[b]))) | |
123 | addClass(td,i,b); | |
124 | } | |
125 | } | |
126 | document.body.appendChild(t); | |
127 | } | |
128 | ||
129 | ||
130 | function load(data) | |
131 | { | |
132 | loadMifare(data); | |
133 | loadAscii(data); | |
134 | } | |
135 | </script> | |
136 | ||
137 | </head> | |
138 | <body> | |
139 | </body> | |
140 | <script> | |
141 | (function(){ | |
142 | ||
143 | var x = { | |
144 | data : | |
145 | ]] | |
146 | local skel_2 = [[ | |
147 | ||
148 | } | |
149 | load(x); | |
150 | })(); | |
151 | </script> | |
152 | </html> | |
153 | ]] | |
154 | local function getHTML(data) | |
155 | return skel_1 .. data .. skel_2 | |
156 | end | |
157 | ||
158 | return {getHTML = getHTML} |