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