Skip to content

Auto generate tracers - fixing bugs #204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions js/create/array2d.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const tableToInputFields = (numRows, numColumns) => {
for(var i = 0; i < numRows; i++){
for(var j = 0; j < numColumns; j++){
var elem = document.createElement('input');
elem.type = 'Number';
elem.type = 'Text';
elem.value = Math.floor(Math.random() * 10 + 1);
elem.classList.add('mtbl-col','inputField');
table.childNodes[i].childNodes[j].innerHTML = '';
Expand All @@ -56,22 +56,40 @@ const generateJS = (logger, tracer, tracerName) => {
logger.print('Copy and paste this code in your data.js file!');
logger.print('');

logger.print('let myTable = [');
if(numRows > 1) {
logger.print('let myTable = [');
}

var line = '';
var line = 'let myTable = [';
var i;
var j;
var comma = ',';
var currVal;
var nors;
for(i = 0; i < numRows; i++){
line = '[';
if(numRows > 1){
line = '[';
}
for(j = 0; j < numColumns-1; j++){
line += table.childNodes[i].childNodes[j].childNodes[0].value + ',';
currVal = table.childNodes[i].childNodes[j].childNodes[0].value;
nors = Number(currVal);
if(isNaN(nors)){
currVal = "'" + currVal + "'";
}
line += currVal + ',';
}
if(i === numRows - 1){comma = '';}
line += table.childNodes[i].childNodes[j++].childNodes[0].value + ']' + comma;
currVal = table.childNodes[i].childNodes[j++].childNodes[0].value;
nors = Number(currVal);
if(isNaN(nors)){
currVal = "'" + currVal + "'";
}
line += currVal + ']' + comma;
logger.print(line);
}
logger.print(']');
if(numRows > 1){
logger.print(']');
}


logger.print("let myTableTracer = new "+ tracer +" ('"+tracerName+"')");
Expand Down
1 change: 1 addition & 0 deletions js/create/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ const init = () => {
array2d.setup();
array1d.setup();
closeCreate();
util.clickTraceTab();
}
};

Expand Down
10 changes: 9 additions & 1 deletion js/create/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,16 @@ const enabledHightlighting = () =>{
}
}

const clickTraceTab = () => {
var btn = document.getElementById('btn_trace');
if(btn){
btn.click();
}
}

module.exports = {
enabledHightlighting,
positionModules,
clearModules
clearModules,
clickTraceTab
};
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy