-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
99 lines (85 loc) · 2.68 KB
/
index.html
File metadata and controls
99 lines (85 loc) · 2.68 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
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
<!DOCTYPE HTML>
<html>
<head>
<script>
function writeLog(object) {
var pTag = document.createElement("p");
pTag.appendChild(document.createTextNode(JSON.stringify(object)));
document.getElementById('content').appendChild(pTag);
}
/*
* This is an example Class with annotations
*/
function Auto(name) {
//@Entity
//@Präfix{"test_"}
this.id = name;
//@Color{"red","blue","yellow"}
//@Präfix{"color_", "title":"foobar"}
this.color = "blue";
}
/*
* This is the Annotation-Method.
* This will find annotations in your Class and produces an object
*/
function Annotation(className) {
var annotations = [];
var aLines = className.toString().split('\n');
function getParameters(sParameters) {
var params = new Array();
var aParams = sParameters.split(',');
for(var a = 0; a < aParams.length; a++) {
if(aPropertyParams = aParams[a].match(/\"?([^\"]*)\"?:\"?([^\"]*)\"?/)) {
params[aPropertyParams[1]] = aPropertyParams[2];
} else {
params.push(aParams[a].replace(/\"/g,''));
}
}
return params;
}
function getAnnotationObject(aLines, iIndex) {
data = {};
data.fromLine = iIndex;
var iLimiter = 25, iCounter = 0;
while(!data.object) {
var sLine = aLines[iIndex];
iCounter++;
if(sLine.match(/\/\/@/)) {
var sLine = sLine.replace(/^.*?\/\/@/, '');
if(!data.annotation)
data.annotation = [];
var iAnnotationIndex = data.annotation.push({annotation:sLine.match(/^([^\{]*)/)[0]})-1;
if(sParameters = sLine.match(/\{(.*?)\}/)) {
data.annotation[iAnnotationIndex].parameters = getParameters(sParameters[1]);
}
} else {
if(!data.annotation)
return null;
data.object = sLine.replace(/^\s*/, '');
break;
}
if(iCounter >= iLimiter)
break;
iIndex++;
}
data.toLine = iIndex;
return data;
};
for(var i = 1;i<aLines.length;i++) {
var data = getAnnotationObject(aLines,i);
annotations.push(data);
if(data)
i = data.toLine;
}
}
writeLog("Example Class:");
writeLog(Auto.toString());
// Let's find annotations
writeLog("Annotations:");
writeLog(Annotation(Auto));
</script>
</head>
<body>
<div id="content"></div>
</body>
</html>