Fixing mess.Reference

This commit is contained in:
Tom MacWright 2011-02-02 16:24:50 -05:00
parent 490b51c6fd
commit 3a57822e7d

View File

@ -1,15 +1,17 @@
(function(tree) {
var fs = require('fs');
tree.Reference = JSON.parse(fs.readFileSync(__dirname + '/reference.json'));
tree.Reference = {
data: JSON.parse(fs.readFileSync(__dirname + '/reference.json'))
}
for (var i in tree.Reference.colors) {
var c = tree.Reference.colors[i];
tree.Reference.colors[i] = new(tree.Color)(c);
for (var i in tree.Reference.data.colors) {
var c = tree.Reference.data.colors[i];
tree.Reference.data.colors[i] = new(tree.Color)(c);
}
tree.Reference.color_frames = function() {
var variables = tree.Reference.colors;
var variables = tree.Reference.data.colors;
variables = Object.keys(variables).map(function (k) {
var value = variables[k];
if (!(value instanceof tree.Value)) {
@ -27,10 +29,10 @@ tree.Reference.required_prop_list_cache = {};
tree.Reference.selectors = tree.Reference.selectors || (function() {
var list = [];
for (var i in tree.Reference.symbolizers) {
for (var j in tree.Reference.symbolizers[i]) {
if (tree.Reference.symbolizers[i][j].hasOwnProperty('css')) {
list.push(tree.Reference.symbolizers[i][j].css);
for (var i in tree.Reference.data.symbolizers) {
for (var j in tree.Reference.data.symbolizers[i]) {
if (tree.Reference.data.symbolizers[i][j].hasOwnProperty('css')) {
list.push(tree.Reference.data.symbolizers[i][j].css);
}
}
}
@ -42,9 +44,9 @@ tree.Reference.validSelector = function(selector) {
};
tree.Reference.selectorName = function(selector) {
for (var i in tree.Reference.symbolizers) {
for (var j in tree.Reference.symbolizers[i]) {
if (selector == tree.Reference.symbolizers[i][j].css) {
for (var i in tree.Reference.data.symbolizers) {
for (var j in tree.Reference.data.symbolizers[i]) {
if (selector == tree.Reference.data.symbolizers[i][j].css) {
return j;
}
}
@ -52,19 +54,19 @@ tree.Reference.selectorName = function(selector) {
};
tree.Reference.selector = function(selector) {
for (var i in tree.Reference.symbolizers) {
for (var j in tree.Reference.symbolizers[i]) {
if (selector == tree.Reference.symbolizers[i][j].css) {
return tree.Reference.symbolizers[i][j];
for (var i in tree.Reference.data.symbolizers) {
for (var j in tree.Reference.data.symbolizers[i]) {
if (selector == tree.Reference.data.symbolizers[i][j].css) {
return tree.Reference.data.symbolizers[i][j];
}
}
}
};
tree.Reference.symbolizer = function(selector) {
for (var i in tree.Reference.symbolizers) {
for (var j in tree.Reference.symbolizers[i]) {
if (selector == tree.Reference.symbolizers[i][j].css) {
for (var i in tree.Reference.data.symbolizers) {
for (var j in tree.Reference.data.symbolizers[i]) {
if (selector == tree.Reference.data.symbolizers[i][j].css) {
return i;
}
}
@ -76,9 +78,9 @@ tree.Reference.requiredPropertyList = function(symbolizer_name) {
return this.required_prop_list_cache[symbolizer_name];
}
var properties = [];
for (var j in tree.Reference.symbolizers[symbolizer_name]) {
if (tree.Reference.symbolizers[symbolizer_name][j].required) {
properties.push(tree.Reference.symbolizers[symbolizer_name][j].css);
for (var j in tree.Reference.data.symbolizers[symbolizer_name]) {
if (tree.Reference.data.symbolizers[symbolizer_name][j].required) {
properties.push(tree.Reference.data.symbolizers[symbolizer_name][j].css);
}
}
return this.required_prop_list_cache[symbolizer_name] = properties;