From 3a57822e7d18e353c57e973ab11777e34c63f756 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Wed, 2 Feb 2011 16:24:50 -0500 Subject: [PATCH] Fixing mess.Reference --- lib/mess/tree/reference.js | 46 ++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/lib/mess/tree/reference.js b/lib/mess/tree/reference.js index 6a8d606..5effc39 100644 --- a/lib/mess/tree/reference.js +++ b/lib/mess/tree/reference.js @@ -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;