adding css classes to most of the structured printing values.

This commit is contained in:
Danny Yoo 2013-04-04 17:56:30 -06:00
parent 15885bd6a2
commit e60f96f97c
3 changed files with 30 additions and 27 deletions

View File

@ -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 = $('<span/>');
var i;
node.append($('<span/>').text("(").addClass('lParen'));
node.append($('<span/>').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($('<span/>').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));
}(this.plt.baselib, jQuery));

View File

@ -55,23 +55,23 @@
Symbol.prototype.toDomNode = function(params) {
if (params.getMode() === 'write') {
return $("<span/>").text(this.val).get(0);
return $("<span/>").text(this.val).addClass('wescheme-symbol').get(0);
}
if (params.getMode() === 'display') {
return $("<span/>").text(this.val).get(0);
return $("<span/>").text(this.val).addClass('wescheme-symbol').get(0);
}
if (params.getMode() === 'print') {
if (params.getDepth() === 0) {
return $("<span/>").text("'" + this.val).get(0);
return $("<span/>").text("'" + this.val).addClass('wescheme-symbol').get(0);
} else {
return $("<span/>").text(this.val).get(0);
return $("<span/>").text(this.val).addClass('wescheme-symbol').get(0);
}
}
if (params.getMode() === 'constructor') {
return $("<span/>").text("'" + this.val).get(0);
return $("<span/>").text("'" + this.val).addClass('wescheme-symbol').get(0);
}
return $("<span/>").text(this.val).get(0);
return $("<span/>").text(this.val).addClass('wescheme-symbol').get(0);
};

View File

@ -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 = $('<span/>'), i;
if (params.getMode() === 'constructor') {
node.appendChild(document.createTextNode("(vector"));
node.append($('<span/>').text('(').addClass('lParen'));
node.append($('<span/>').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($('<span/>').text(')').addClass('rParen'));
} else {
node.appendChild(document.createTextNode("#("));
node.append($('<span/>').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($('<span/>').text(')').addClass('rParen'));
}
return node;
return node.get(0);
};
@ -126,4 +127,4 @@
exports.makeVectorImmutable = makeVectorImmutable;
}(this.plt.baselib));
}(this.plt.baselib, jQuery));