ryanmkilt
10-08-2008, 11:49 AM
I have the following code:
//stock code:
function el(tid) {return document.getElementById(tid);}
if (!Array.prototype.map) {// from http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:map
Array.prototype.map = function (fun) {var len = this.length;if (typeof fun != "function") {throw new TypeError;}var res = new Array(len);var thisp = arguments[1];for (var i = 1; i < len; i++) {if (i in this) {res[i] = fun.call(thisp, this[i], i, this);}}return res;};}
function IO(U, V) { var X = !window.XMLHttpRequest ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest();
X.open(V ? 'PUT' : 'GET', U, false); X.setRequestHeader('Content-Type', 'text/html'); X.send(V ? V : '');return X.responseText;}
//custom code:
function boot(){
showColumn(5); // show 6th column
}
function splitter(a){ return a.split(/\|/g); }
function grabCol(a){ return a[this]; }
function showColumn( numCol ){
var elm = el("viewer");
if(!elm){ //create the data container on first run
elm = document.createElement("div");
elm.id = "viewer";
document.body.appendChild(elm); // change this to point to destination
}
var data = showColumn.data || (showColumn.data = IO("test.txt").split(/\r?\n/g).map(splitter) );
var myCol = data.map(grabCol, numCol );
var buffer = myCol.join(" ");
elm.innerHTML = buffer;
}
When I click a button it runs the boot(). This prints out the 6th column of my file, which are the values A, B, or C only. In my CSS i want to use A {color: blue} B{color: red} C{color: black}. I also have a table that is generated when I click that button that displays my file. There you can see each row and the 6th column will have a A, B, or C. For all the rows with A, I want it to apply the CSS sheet to it, and same for B and C. If anyone understands what I am saying, I was wondering if they could help me out here.
//stock code:
function el(tid) {return document.getElementById(tid);}
if (!Array.prototype.map) {// from http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:map
Array.prototype.map = function (fun) {var len = this.length;if (typeof fun != "function") {throw new TypeError;}var res = new Array(len);var thisp = arguments[1];for (var i = 1; i < len; i++) {if (i in this) {res[i] = fun.call(thisp, this[i], i, this);}}return res;};}
function IO(U, V) { var X = !window.XMLHttpRequest ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest();
X.open(V ? 'PUT' : 'GET', U, false); X.setRequestHeader('Content-Type', 'text/html'); X.send(V ? V : '');return X.responseText;}
//custom code:
function boot(){
showColumn(5); // show 6th column
}
function splitter(a){ return a.split(/\|/g); }
function grabCol(a){ return a[this]; }
function showColumn( numCol ){
var elm = el("viewer");
if(!elm){ //create the data container on first run
elm = document.createElement("div");
elm.id = "viewer";
document.body.appendChild(elm); // change this to point to destination
}
var data = showColumn.data || (showColumn.data = IO("test.txt").split(/\r?\n/g).map(splitter) );
var myCol = data.map(grabCol, numCol );
var buffer = myCol.join(" ");
elm.innerHTML = buffer;
}
When I click a button it runs the boot(). This prints out the 6th column of my file, which are the values A, B, or C only. In my CSS i want to use A {color: blue} B{color: red} C{color: black}. I also have a table that is generated when I click that button that displays my file. There you can see each row and the 6th column will have a A, B, or C. For all the rows with A, I want it to apply the CSS sheet to it, and same for B and C. If anyone understands what I am saying, I was wondering if they could help me out here.