diff --git a/src/JBrowse/parse.js b/src/JBrowse/parse.js index 7d10ef522b..e01e0c2c89 100644 --- a/src/JBrowse/parse.js +++ b/src/JBrowse/parse.js @@ -22,15 +22,15 @@ function parseGBConfig(data){ //Process each line - for (var i = 0; i < n; i++){ - if(this.regex.comment.test(this.lines[i])){ // #this is a comment + for (var i = 0; i < n; i++) { + if (this.regex.comment.test(this.lines[i])) { // #this is a comment // do nothing, since it's a comment. - }else if(this.regex.halfParam.test(this.lines[i])){ // name = - i = isMultiLine(i); // skips lines, so get where to continue - }else if(this.regex.param.test(this.lines[i])){ // name = value - isParam(i); - }else if(this.regex.section.test(this.lines[i])){ // [section_name] - isSection(i); + } else if (this.regex.halfParam.test(this.lines[i])) { // name = + i = MultiLine(i); // skips lines, so get where to continue + } else if (this.regex.param.test(this.lines[i])) { // name = value + Param(i); + } else if (this.regex.section.test(this.lines[i])) { // [section_name] + Section(i); } }; @@ -38,29 +38,29 @@ function parseGBConfig(data){ return this.value; //Returns the JS object } -function isParam(i){ +function Param(i) { var match = this.lines[i].match(this.regex.param); - if(this.section){ - if (!isNaN(match[2])){ + if (this.section) { + if (!isNaN(match[2])) { match[2] = parseInt(match[2]); } this.value[this.section][match[1].trim()] = match[2]; - }else{ - if (!isNaN(match[2].trim())){ + } else { + if (!isNaN(match[2].trim())) { match[2] = parseInt(match[2].trim()); } this.value[match[1].trim()] = match[2].trim(); } } -function isMultiLine (i){ - line = this.lines; rx = this.regex; +function MultiLine (i){ + var line = this.lines; var rx = this.regex; var lineNum = i+1; var tmpStrVal = ''; // while (line is defined, not a parameter or function) while (typeof line[lineNum] !== 'undefined' && (! ( rx.param.test(line[lineNum]) || rx.section.test(line[lineNum])))){ //if (line not comment or empty) - if (! ( rx.comment.test(line[lineNum]) || rx.emptyLine.test(line[lineNum]) )){ + if (! ( rx.comment.test(line[lineNum]) || rx.emptyLine.test(line[lineNum]) )) { if (tmpStrVal === ''){ tmpStrVal += line[lineNum].trim(); } else { @@ -70,15 +70,15 @@ function isMultiLine (i){ lineNum++; } var match = this.lines[i].match(this.regex.param); - if(this.section){ + if (this.section) { this.value[this.section][match[1].trim()] = tmpStrVal; - }else{ + } else { this.value[match[1].trim()] = tmpStrVal; } return lineNum - 1; //The line it should continue at. } -function isSection (i){ +function Section (i) { var match = this.lines[i].match(this.regex.section); this.value[match[1].trim()] = {}; this.section = match[1].trim();