Skip to content

Commit

Permalink
More syntax fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fbennett committed Feb 22, 2019
1 parent dba1fab commit 96d9b6c
Show file tree
Hide file tree
Showing 25 changed files with 270 additions and 309 deletions.
2 changes: 1 addition & 1 deletion src/.jshintrc
Expand Up @@ -27,7 +27,7 @@


// Code Complexity
"maxparams" : 6, // max number of formal parameters allowed per function
"maxparams" : 8, // max number of formal parameters allowed per function
"maxdepth" : 9, // control how nested do you want your blocks to be
"maxstatements" : 370, // max number of statements allowed per function
"maxcomplexity" : 128, // control cyclomatic complexity throughout your code
Expand Down
27 changes: 15 additions & 12 deletions src/util_dateparser.js
@@ -1,7 +1,7 @@
/*global CSL: true */


CSL.DateParser = new function () {
CSL.DateParser = function () {

/*
* Fixed values
Expand All @@ -24,9 +24,12 @@ CSL.DateParser = new function () {
}

var epochMatchStrings = [];
var epochMap = {};
for (var i=0,ilen=epochPairs.length; i<ilen; i++) {
var val = epochPairs[i][0];
var pair = epochPairs[i];
var val = pair[0];
epochMatchStrings.push(val);
epochMap[pair[0]] = pair[1];
}
var epochMatchString = epochMatchStrings.join("|");

Expand Down Expand Up @@ -322,7 +325,7 @@ CSL.DateParser = new function () {
lst.push(slst[i]);
if (i !== (ilen - 1)) {
// pos is undeclared, and multiplying by 2 here is insane.
var mmpos = (pos * 2);
var mmpos = (i * 2);
lst.push(mmx[mmpos]);
lst.push(mmx[mmpos + 1]);
}
Expand All @@ -332,7 +335,7 @@ CSL.DateParser = new function () {
}
// workaround duly applied, this now works
for (var i=1,ilen=lst.length; i<ilen; i+=3) {
lst[i + 1] = jiy[lst[i]] + parseInt(lst[i + 1], 10);
lst[i + 1] = epochMap[lst[i]] + parseInt(lst[i + 1], 10);
lst[i] = "";
}
txt = lst.join("");
Expand Down Expand Up @@ -430,6 +433,12 @@ CSL.DateParser = new function () {
continue;
}
//
// If it's a fuzzy marker, record it.
//
if (element === "~" || element === "?" || element === "c" || element.match(/^cir/)) {
thedate.circa = "" + 1;
}
//
// If it's a month, record it.
//
for (var k=0,klen=this.monthRexes.length; k<klen; k++) {
Expand Down Expand Up @@ -460,13 +469,6 @@ CSL.DateParser = new function () {
continue;
}
//
// If it's a fuzzy marker, record it.
//
if (element === "~" || element === "?" || element === "c" || element.match(/^cir/)) {
thedate.circa = "" + 1;
continue;
}
//
// If it's cruft, make a note of it
//
if (element.toLocaleLowerCase().match(/(?:mic|tri|hil|eas)/) && !thedate[("season" + suff)]) {
Expand All @@ -488,7 +490,7 @@ CSL.DateParser = new function () {
// cruft there.
//
if (note && !thedate[("season" + suff)]) {
thedate[("season" + suff)] = note;
thedate[("season" + suff)] = note.trim();
note = "";
}
suff = "_end";
Expand Down Expand Up @@ -547,3 +549,4 @@ CSL.DateParser = new function () {
this.setOrderMonthDay();
this.resetDateParserMonths();
};
CSL.DateParser = new CSL.DateParser();
6 changes: 3 additions & 3 deletions src/util_dates.js
Expand Up @@ -31,7 +31,7 @@ CSL.Util.Dates.year["long"] = function (state, num) {
* Crudely convert to Japanese Imperial form.
* <p>Returns the result as a string.</p>
*/
CSL.Util.Dates.year.imperial = function (state, num, end, makeShort) {
CSL.Util.Dates.year.imperial = function (state, num, end) {
var year = "";
if (!num) {
if ("boolean" === typeof num) {
Expand Down Expand Up @@ -79,7 +79,7 @@ CSL.Util.Dates.year.imperial = function (state, num, end, makeShort) {
}
if (state.transform.abbrevs['default']['number'][normalizedKey]) {
label = state.transform.abbrevs['default']['number'][normalizedKey];
};
}
year = label + (num - offset);
}
return year;
Expand Down Expand Up @@ -153,7 +153,7 @@ CSL.Util.Dates.normalizeMonth = function (num, useSeason) {
ret = num;
}
return ret;
}
};

CSL.Util.Dates.month = {};

Expand Down
6 changes: 3 additions & 3 deletions src/util_disambig.js
@@ -1,7 +1,7 @@
/*global CSL: true */

CSL.ambigConfigDiff = function(a, b) {
var ret, pos, len, ppos, llen;
var pos, len, ppos, llen;
// return of true means the ambig configs differ
if (a.names.length !== b.names.length) {
//print(" (1)");
Expand Down Expand Up @@ -32,8 +32,8 @@ CSL.ambigConfigDiff = function(a, b) {
return 0;
};

CSL.cloneAmbigConfig = function (config, oldconfig, tainters) {
var i, ilen, j, jlen, k, klen, param;
CSL.cloneAmbigConfig = function (config, oldconfig) {
var i, ilen, j, jlen, param;
var ret = {};
ret.names = [];
ret.givens = [];
Expand Down

0 comments on commit 96d9b6c

Please sign in to comment.