From e60f96f97c2696c42497f6529fdd55d7c05a9140 Mon Sep 17 00:00:00 2001 From: Danny Yoo Date: Thu, 4 Apr 2013 17:56:30 -0600 Subject: [PATCH] adding css classes to most of the structured printing values. --- .../runtime-src/baselib-structs.js | 20 ++++++++------- .../runtime-src/baselib-symbols.js | 12 ++++----- .../runtime-src/baselib-vectors.js | 25 ++++++++++--------- 3 files changed, 30 insertions(+), 27 deletions(-) diff --git a/whalesong/js-assembler/runtime-src/baselib-structs.js b/whalesong/js-assembler/runtime-src/baselib-structs.js index ec1f20c..870e909 100644 --- a/whalesong/js-assembler/runtime-src/baselib-structs.js +++ b/whalesong/js-assembler/runtime-src/baselib-structs.js @@ -10,7 +10,7 @@ ////////////////////////////////////////////////////////////////////// var Struct = function (constructorName, fields, structType) { - this._constructorName = constructorName; + this._constructorName = constructorName; // Symbol this._fields = []; this.structType = structType; }; @@ -33,15 +33,17 @@ }; Struct.prototype.toDomNode = function (params) { - var node = document.createElement("span"), i; - $(node).append(document.createTextNode("(")); - $(node).append(document.createTextNode(this._constructorName)); + var node = $(''); + var i; + node.append($('').text("(").addClass('lParen')); + node.append($('').text(this._constructorName+'')); for(i = 0; i < this._fields.length; i++) { - $(node).append(document.createTextNode(" ")); - $(node).append(params.recur(this._fields[i])); + node.append(" "); + node.append(params.recur(this._fields[i])); } - $(node).append(document.createTextNode(")")); - return node; + node.append($('').text(")").addClass('rParen')); + console.log(node); + return node.get(0); }; @@ -308,4 +310,4 @@ exports.isStruct = isStruct; exports.isStructType = isStructType; exports.isStructTypeProperty = isStructTypeProperty; -}(this.plt.baselib, jQuery)); \ No newline at end of file +}(this.plt.baselib, jQuery)); diff --git a/whalesong/js-assembler/runtime-src/baselib-symbols.js b/whalesong/js-assembler/runtime-src/baselib-symbols.js index 801f470..e9fa697 100644 --- a/whalesong/js-assembler/runtime-src/baselib-symbols.js +++ b/whalesong/js-assembler/runtime-src/baselib-symbols.js @@ -55,23 +55,23 @@ Symbol.prototype.toDomNode = function(params) { if (params.getMode() === 'write') { - return $("").text(this.val).get(0); + return $("").text(this.val).addClass('wescheme-symbol').get(0); } if (params.getMode() === 'display') { - return $("").text(this.val).get(0); + return $("").text(this.val).addClass('wescheme-symbol').get(0); } if (params.getMode() === 'print') { if (params.getDepth() === 0) { - return $("").text("'" + this.val).get(0); + return $("").text("'" + this.val).addClass('wescheme-symbol').get(0); } else { - return $("").text(this.val).get(0); + return $("").text(this.val).addClass('wescheme-symbol').get(0); } } if (params.getMode() === 'constructor') { - return $("").text("'" + this.val).get(0); + return $("").text("'" + this.val).addClass('wescheme-symbol').get(0); } - return $("").text(this.val).get(0); + return $("").text(this.val).addClass('wescheme-symbol').get(0); }; diff --git a/whalesong/js-assembler/runtime-src/baselib-vectors.js b/whalesong/js-assembler/runtime-src/baselib-vectors.js index f2e0ad3..fd5b272 100644 --- a/whalesong/js-assembler/runtime-src/baselib-vectors.js +++ b/whalesong/js-assembler/runtime-src/baselib-vectors.js @@ -1,6 +1,6 @@ // vectors /*jslint devel: false, browser: true, vars: true, plusplus: true, maxerr: 500, indent: 4 */ -(function (baselib) { +(function (baselib, $) { "use strict"; var exports = {}; baselib.vectors = exports; @@ -83,25 +83,26 @@ }; Vector.prototype.toDomNode = function (params) { - var node = document.createElement("span"), i; + var node = $(''), i; if (params.getMode() === 'constructor') { - node.appendChild(document.createTextNode("(vector")); + node.append($('').text('(').addClass('lParen')); + node.append($('').text('vector')); for (i = 0; i < this.length(); i++) { - node.appendChild(document.createTextNode(" ")); - node.appendChild(params.recur(this.ref(i))); + node.append(" "); + node.append(params.recur(this.ref(i))); } - node.appendChild(document.createTextNode(")")); + node.append($('').text(')').addClass('rParen')); } else { - node.appendChild(document.createTextNode("#(")); + node.append($('').text('#(').addClass('lParen')); for (i = 0; i < this.length(); i++) { - node.appendChild(params.recur(this.ref(i))); + node.append(params.recur(this.ref(i))); if (i !== this.length() - 1) { - node.appendChild(document.createTextNode(" ")); + node.append(" "); } } - node.appendChild(document.createTextNode(")")); + node.append($('').text(')').addClass('rParen')); } - return node; + return node.get(0); }; @@ -126,4 +127,4 @@ exports.makeVectorImmutable = makeVectorImmutable; -}(this.plt.baselib)); \ No newline at end of file +}(this.plt.baselib, jQuery));