-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
79 lines (71 loc) · 2.3 KB
/
main.js
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
var classes=[];
var taglists;
$(document).ready(function() {
srcPath = getNativeBracketsDirectoryPath();
var cssContent=httpGet(window.location.origin+srcPath+'/css/bootstrap.min.css');
var text = cssContent;
text=text.replace(/\/\*(.|\s)*?\*\//g,'');
text=text.replace(/\@media.*?}}/g,'');
text=text.replace(/\{[^\}]*\}/g,'|');
text=text.replace(/,/g,'|');
//console.log(text);
var mt=text.match(/\.[^|]*/g);
//console.log(mt);
//var classes=text.split('|');
//console.log(classes);
uniqueArray=[];
uniqueArray = mt.filter(function(elem, pos, self) {
return self.indexOf(elem) == pos;
});
var classTxt='';
$.each(uniqueArray, function(i, el){
classTxt +=el+'|';
//if($.inArray(el, uniqueNames) === -1) uniqueNames.push(el);
});
classTxt=classTxt.replace(/(?=\s)[^\.]*/g,'|');
classTxt=classTxt.replace(/>[^\.]*/g,'|');
classTxt=classTxt.replace(/\|\.[^|]*:[^|]*(?=|)/g,'');
classTxt=classTxt.replace(/\+/g,'|');
classTxt=classTxt.replace(/\[[^|]*\]/g,'');
classTxt=classTxt.replace(/(\.[^\.|]*(?=\.))/g,'$1|');
mt=[];
mt=classTxt.split('|');
uniqueArray=[];
uniqueArray = mt.filter(function(elem, pos, self) {
return self.indexOf(elem) == pos;
});
console.log(mt);
console.log(uniqueArray);
classes=uniqueArray;
var taglist=httpGet(window.location.origin+srcPath+'/json/taglist.json');
console.log(JSON.parse(JSON.stringify(eval('('+taglist+')'))));
taglists=JSON.parse(JSON.stringify(eval('('+taglist+')')));
$.each(taglists,function(i,el){
$('#tags').append('<li><a href="#'+i+'">'+i+'</a></li>');
//console.log(i);
});
$.each(classes,function(i,el){
$('#classname').append('<li><a href="#'+el+'">'+el+'</a></li>');
console.log(el);
});
function httpGet(theUrl)
{
var xmlHttp = null;
xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", theUrl, false );
xmlHttp.send( null );
return xmlHttp.responseText;
}
function convertToNativePath(path) {
path = unescape(path);
if (path.indexOf(":") !== -1 && path[0] === "/") {
return path.substr(1);
}
return path;
}
function getNativeBracketsDirectoryPath() {
var pathname = decodeURI(window.location.pathname);
var directory = pathname.substr(0, pathname.lastIndexOf("/"));
return convertToNativePath(directory);
}
});