carto/test/index.html

48 lines
1.4 KiB
HTML
Raw Normal View History

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Carto Test</title>
<script src='underscore.js' type='text/javascript'></script>
<script src='../dist/carto.js' type='text/javascript'></script>
<script>
function test() {
carto_initialize(carto, '/~tmcw/carto/lib/carto/tree/reference.json', function(carto) {
var style = document.getElementById('style').innerHTML;
var parse_env = {
error: function(obj) {
document.getElementById('error').innerHTML += JSON.stringify(obj);
}
};
(new carto.Parser(parse_env)).parse(style,
function(err, ruleset) {
var definition = ruleset.toList(parse_env);
console.log(definition);
// for (var i in ruleset.rules) {
// for (var j in ruleset.rules[i].rules) {
// document.getElementById('output').innerHTML += ruleset.rules[i].rules[j].eval(parse_env).toXML(parse_env) + ' ';
// }
// }
});
});
}
</script>
</head>
<body onload='test()'>
<h3>Style</h3>
<pre id='style'>
#world {
line-width: 2;
line-color: #f00;
}
</pre>
<h3>Error</h3>
<pre id='error'>
</pre>
<h3>Output</h3>
<pre id='output'>
</pre>
</body>
</html>