-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathparser.js
More file actions
59 lines (43 loc) · 1.27 KB
/
parser.js
File metadata and controls
59 lines (43 loc) · 1.27 KB
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
/**
* @author: Nikita Dezzpil Orlov
* @date: 2/11/14
*/
var RAL = {}, count = 0;
function add_row_to_list($elem, i) {
var code, rgb_approx, rgb_hex, name, data = [];
data[i] = [];
$elem.each(function() {
var txt = $(this).html().replace(/<[^>]*>/g, '');
txt = txt.replace(/\s+/g, ' ').trim();
txt = txt.replace(/ /g, ' ').trim();
if (txt.length == 0) return ;
data[i].push(txt);
})
if (data[i].length == 0) return;
code = data[i][0].split(' ')[1];
rgb_approx = data[i][1];
rgb_hex = data[i][2];
name = data[i][4];
RAL[code] = {
'code' : code,
'rgb_approx' : rgb_approx,
'rgb_hex' : rgb_hex,
'name' : name
};
count++;
}
$(document).ready(function() {
var row_list = $('div.Section1 table.MsoNormalTable').find('tr').get(),
i = 0, target_elem;
for (i = 10; i < row_list.length - 7; i++) {
target_elem = $(row_list[i]).children('td');
if (target_elem.length && target_elem[0].tagName == 'TD') {
if (target_elem.length > 7 && target_elem.length < 12) {
add_row_to_list(target_elem, i);
}
}
}
console.log(count);
console.log(RAL);
console.log(JSON.stringify(RAL));
});